Created
June 19, 2022 13:13
-
-
Save MasterHans/b8f8800b18fcc507ac15d4d6ec93b7fe to your computer and use it in GitHub Desktop.
get variation name of cart item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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