Skip to content

Instantly share code, notes, and snippets.

@karthikw3cert
Created October 27, 2022 11:51
Show Gist options
  • Save karthikw3cert/cb1657abf65b6526ddd4ed2295e85ade to your computer and use it in GitHub Desktop.
Save karthikw3cert/cb1657abf65b6526ddd4ed2295e85ade to your computer and use it in GitHub Desktop.
foreach ($cart->get_cart() as $cart_item) {
if (isset($cart_item['fooevent_class_date'])) {
$product = $cart_item['data'];
$product_id = $cart_item['variation_id'] > 0 ? $cart_item['variation_id'] : $cart_item['product_id'];
$eventtype=get_post_meta($product_id, "WooCommerceEventsType", true);
if(is_user_logged_in() && $eventtype == 'sequential'){
$roles = wp_get_current_user()->roles;
if(in_array('subscriber',$roles)){
$custom_price = (float) number_format(0, wc_get_price_decimals(), '.', '');
method_exists( $product, 'set_price' ) ? $product->set_price( $custom_price ) : $product->price = $custom_price;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment