function update
This commit is contained in:
parent
894dbcb566
commit
45c44f3406
|
@ -7,12 +7,27 @@ if (!defined('ABSPATH')) {
|
|||
* This File is a very important file, Because Its gettings Data from user selection on event details page, and prepare the data send to cart item and lastly save into order table after checkout
|
||||
*/
|
||||
|
||||
function mep_basic_before_cart_add_validation($passed)
|
||||
{
|
||||
|
||||
$wc_product_id = isset($_REQUEST['add-to-cart']) ? strip_tags($_REQUEST['add-to-cart']) : '';
|
||||
$product_id = isset($_REQUEST['add-to-cart']) ? strip_tags($_REQUEST['add-to-cart']) : '';
|
||||
$linked_event_id = get_post_meta($product_id, 'link_mep_event', true) ? get_post_meta($product_id, 'link_mep_event', true) : $product_id;
|
||||
$product_id = mep_product_exists($linked_event_id) ? $linked_event_id : $product_id;
|
||||
$event_id = $product_id;
|
||||
|
||||
if (get_post_type($event_id) == 'mep_events') {
|
||||
$not_in_the_cart = apply_filters('mep_check_product_into_cart',true,$wc_product_id);
|
||||
if (!$not_in_the_cart) {
|
||||
wc_add_notice("Sorry, This Event already added into the cart. Please First remove this event from the cart to add it again.", 'error');
|
||||
$passed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return $passed;
|
||||
}
|
||||
add_filter('woocommerce_add_to_cart_validation', 'mep_basic_before_cart_add_validation', 10, 90);
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue