aaronstpierre
Forum Replies Created
-
Forum: Plugins
In reply to: [Jigoshop Grouped Products Pro] Issue with Product VariationsHi Chris,
Pull request submitted!
Forum: Plugins
In reply to: [Jigoshop Grouped Products Pro] Issue with Product VariationsOh that is great! Sure! I’ll pull it right now. Thanks!
Forum: Plugins
In reply to: [Jigoshop Grouped Products Pro] Issue with Product VariationsFound 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 +}