Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Validation on select Free Products
- This topic has 2 replies, 2 voices, and was last updated 5 years, 9 months ago by numep.
-
AuthorPosts
-
December 4, 2018 at 8:14 pm #4341numepParticipant
Hi, when user meets coupon requirements it let’s them Choose free Free in cart, but when clicked on PROCEED TO CHECKOUT it should validate that user selects GIFT otherwise gift wont be added. How to fix this?
December 5, 2018 at 9:28 am #4347Soft79KeymasterHi,
I removed this validation because in my opinion it’s more important that the user checks out whether a free gift has been selected or not. Maybe I will create a setting for this in a future version. For now you can fix this by ‘hacking’ the core plugin:
replace in woocommerce-auto-added-coupons-pro/pro/plugins/WJECF_Pro_Free_Products/WJECF_Pro_Free_Products.php around line 172:
public function woocommerce_before_checkout_process() { $this->process_form(); // //Don't checkout if no free gift selected // foreach( WC()->cart->get_applied_coupons() as $coupon_code ) { // $coupon = new WC_Coupon( $coupon_code ); // //Must the user select a free product? // if ( ! $this->must_select_free_product( $coupon ) ) { // continue; // } // $session_selected_products = $this->get_session_selected_products( $coupon_code ); // $selected_free_products = $this->count_selected_products( $coupon, $session_selected_products ); // if ( empty( $selected_free_products ) ) { // wc_add_notice( __('Please select your free gift.', 'woocommerce-jos-autocoupon'), 'error' ); // return; // } // } }
by this:
public function woocommerce_before_checkout_process() { $this->process_form(); //Don't checkout if no free gift selected foreach( WC()->cart->get_applied_coupons() as $coupon_code ) { $coupon = new WC_Coupon( $coupon_code ); //Must the user select a free product? if ( ! $this->must_select_free_product( $coupon ) ) { continue; } $session_selected_products = $this->get_session_selected_products( $coupon_code ); $selected_free_products = $this->count_selected_products( $coupon, $session_selected_products ); if ( empty( $selected_free_products ) ) { wc_add_notice( __('Please select your free gift.', 'woocommerce-jos-autocoupon'), 'error' ); return; } } }
Please not that this change will be undone when you update the plugin.
December 5, 2018 at 1:28 pm #4370numepParticipanthey thanks for the quick response! and yeah that will do.
-
AuthorPosts
- You must be logged in to reply to this topic.