Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Can I require someone to choose a free product? › Reply To: Can I require someone to choose a free product?

#16529
Soft79
Keymaster

Currently that’s not possible. This used to be obligatory in older versions of our plugin but I disabled it because it prevented people from checking out.

If you wish you can ‘hack’ the plugin by uncommenting lines 197 .. 211 of wp-content/plugins/woocommece-auto-added-coupons-pro/pro/plugins/WJECF_Pro_Free_Products.php:


	//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 note that this change will be overwritten in case of an update. We’re thinking about implemententing a filter for this functionality in a future version of the plugin.