Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MasterHans/b8f8800b18fcc507ac15d4d6ec93b7fe to your computer and use it in GitHub Desktop.
Save MasterHans/b8f8800b18fcc507ac15d4d6ec93b7fe to your computer and use it in GitHub Desktop.
get variation name of cart item
add_filter( 'woocommerce_checkout_fields', 'pulse_checkout_fields_validate_birthdate', 9999 );
function pulse_checkout_fields_validate_birthdate( $fields ) {
$cart = WC()->cart->get_cart();
foreach ( $cart as $cart_item ) {
$variation = wc_get_product($cart_item['variation_id']);
$variationFormattedName = $variation->get_formatted_name();
$cartItemVariationIsChildrenRace = (strpos($variationFormattedName, 'Детский')>0);
write_log($cartItemVariationIsChildrenRace);
}
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment