Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › customer must select for free gifts not working
- This topic has 1 reply, 2 voices, and was last updated 4 years, 5 months ago by Soft79.
-
AuthorPosts
-
March 31, 2020 at 4:52 pm #15278ahonshawParticipant
Hi,
I checked “customer must select ” box for free gifts. It does not works because customer still can checkout without adding any quantities to gifts. Please help to fix it.
note: I am using a very popular flatsome theme
Regards,
March 31, 2020 at 7:45 pm #15280Soft79KeymasterI made selecting the free product optional a couple of versions ago because it would prevent customers from checking out. I’m thinking about adding an option for this in a future version of the plugin. For now as a quick workaround you can do this (if you’re comfortable editing one of the plugin’s php files):
Find the following function in wp-content/plugins/woocommerce-auto-added-coupons-pro/pro/plugins/WJECF_Pro_Free_Products/WJECF_Pro_Free_Products.php :
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; // } // } }
and uncomment the commented lines; i.e. replace the function with:
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; } } }
-
AuthorPosts
- You must be logged in to reply to this topic.