Found a solution!
I noticed that the add to cart code was similar to the case in jigoshop_actions so I did my best to make things identical since basically the grouped plugins pro is trying to do the same when it comes to variable products.
I believe the real fix to be the passing of $variation_id and $variations to jigoship_cart::add_to_cart.
Hope this helps someone! It sure helped me! Thanks again Chris for the plugin it totally saved my butt! 🙂
Edited to correct the diff…Here is a diff -u which can be used with patch…
--- /home/asp/jigoshop-grouped-plugins-pro/jigoshop-grouped-products-pro.php 2013-07-04 17:20:15.000000000 +0000
+++ jigoshop-grouped-products-pro.php 2013-09-05 01:18:13.000000000 +0000
@@ -264,12 +264,21 @@
case 'variation':
- if ( empty( $_REQUEST['variation_id'] ) || !is_numeric( $_REQUEST['variation_id'] ) ) {
+ /*if ( empty( $_REQUEST['variation_id'] ) || !is_numeric( $_REQUEST['variation_id'] ) ) {
jigoshop::add_error( __( 'Please choose product options…', 'jigoshop' ) );
wp_safe_redirect( apply_filters( 'jigoshop_product_id_add_to_cart_filter', get_permalink( $_REQUEST['product_id'] ) ) );
exit;
- }
-
+ }*/
+
+ // ensure we have a valid quantity, product and variation id, that is numeric, without any SQL injection attempts.
+ $product_id = (isset($_REQUEST['product_id']) && is_numeric($_REQUEST['product_id'])) ? (int) $_REQUEST['product_id'] : -1;
+ if ( $product_id < 0 ) {
+ break; // drop out and put up message, unable to add product.
+ }
+ if ( empty($_REQUEST['variation_id']) || !is_numeric($_REQUEST['variation_id']) ) {
+ break; // drop out and put up message, unable to add product.
+ }
+
$product_id = apply_filters( 'jigoshop_product_id_add_to_cart_filter', (int) $_REQUEST['product_id'] );
$variation_id = apply_filters( 'jigoshop_variation_id_add_to_cart_filter', (int) $_REQUEST['variation_id'] );
$quantity = ( isset( $_REQUEST['quantity'] ) ) ? (int) $_REQUEST['quantity'] : 1;
@@ -304,7 +313,7 @@
$is_valid = apply_filters( 'jigoshop_add_to_cart_validation', true, $product_id, $quantity );
if ( $all_variations_set && $is_valid ) {
- jigoshop_cart::add_to_cart( $product_id, $quantity );
+ jigoshop_cart::add_to_cart( $product_id, $quantity, $variation_id, $variations );
$product_added = true;
}
@@ -473,4 +482,4 @@
exit;
}
}
-}
\ No newline at end of file
+}
That’s great news 🙂
Do you know by chance how to submit a pull request to a GitHub repository. This plugins has one here:
https://github.com/chriscct7/jigoshop-grouped-products-pro
If you submit a patch I could have this out to everyone late tonight or early tomorrow morning 🙂
-Chris
Oh that is great! Sure! I’ll pull it right now. Thanks!
Sweet!
Got it and it looks good.
Merged into core. Will be pushed as an official release tomorrow morning. In the meantime, you might want to increment the version number of your version to version 4.1, so you avoid a pointless update 🙂
-Chris
The middle “version” in there should’ve said “plugin”.
Anyways, its the number on (I believe line #3), at teh very top of the plugin
-Chris
OK cool will do! Thanks again!