Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Validation on select Free Products › Reply To: Validation on select Free Products
December 5, 2018 at 9:28 am
#4347
Soft79
Keymaster
Hi,
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.