Try something like this, I am unable to test this at the moment.
add_action('woocommerce_before_calculate_totals', 'personalization_check_category_in_cart');
function personalization_check_category_in_cart() {
// loop through all products in the Cart
foreach (WC()->cart->get_cart() as $cart_item) {
// if cart has category term, set variable $cat_in_cart to true
if (has_term( 'Personalize', 'product_cat', $cart_item['product_id'])) {
$product = $cart_item['data']; // get product data
$product_id = $product->get_id(); // get product ID
$note = get_post_meta( $product->get_id(), 'product_personalization_note', true ); // get meta
echo '<div class="checkout-personalization-message-container"><p>' . $note . '</p></div>';
}
}
}
Related Posts:
- How to check if woocommerce is activated in theme
- Query WooCommerce orders grouped by several order statuses
- retrieve thumbnail from post ID of best selling product in category
- Display a selected custom product option in WooCommerce cart
- Automatically check the option “Enable stock management at product level” on product creation
- Replace existing content from specific WooCommerce admin orders list column
- Woocommerce – How to get products which have a sale between 20% to 40%? [closed]
- Woocommerce: Is it possible to overide the settings for allowing to purchase out of stock products [closed]
- How does WooCommerce ensure that a product doesn’t run out of stock during payment? [closed]
- How to get woocommerce cart content without an action?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- Woocommerce product download URL
- woocommerce – hide payment method in new order email
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- How can I use wp_query to show all product data using just the products ID?
- Get stock by custom meta field on all Woocommerce variable products
- Set a condition based on WooCommerce checkout city field while placing order
- woocommerce subscriptions – get expiration date [closed]
- Call global variable array() in woocommerce child/template
- Remove price from Woocommerce variable product dropdown menu
- Woocommerce hook run after an Order been created through REST API
- Get and insert order email address to the PHP template inside HTML text
- Woocommerce api: create product with images – bad request
- do search in two site and show the result in first site
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- How can I pass a custom/dynamic product to the Woocommerce cart?
- WooCommerce custom product dimensions
- WordPress Woocommerce – Product Type [closed]
- Pagination for custom shop loop woocommerce
- How to get private property in parent class into extended class?
- get_total () returns 0 – woocommerce [closed]
- email alert for product availability
- How to rename woocommerce-billing-fields
- WooCommerce pages looks unstyled
- Personalize checkout text
- Disable if there are no children – Woocommerce
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- Woocommerce: remove total sum from new order’s email [closed]
- Alter Woocommerce product archive structure
- custom post type with role Vendor
- WooCommerce: Display product categories to make IF statement
- Custom Taxonomy Select Menu: Setting default option value?
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Display Sibling WooCommerce Product Categories on Archive Page
- How to sort WooCommerce products page by latest in-stock items first?
- WP_Query for woocommerce products with a pattern as a post_title
- Replace category title with category description in woocommerce
- Generate images with html2canvas and the woocommerce api
- Add Custom Category Description When Empty
- I am having issue in divi woocomerce checkout module. (DIVI theme)
- How to update ticket price programatically when adding to cart and checkout in woocommerce
- Woocommerce My acount page
- Get WooCommerce products with similar SKU
- Woocommerce display orders with products from specific categories to specific admins
- Display div if category has a specific parent
- global $product is empty string when passed into function
- Use CSS tag inside PHP code
- Set ACF on order during checkout
- Use PHP Class in WordPress functions
- Hide payment method based on user role AND minimum cart value
- How can I show how much water got saved on this order (making use of the number of items bought) on a thank-you-page?
- IF statement not working – Any suggestions?
- Don’t update modified post date when user add a product review or comment?
- How do I change the “login” label in My Account page to “Registered Customer”
- Customize the “Available for back order” text for specific variation
- How to remove the replace the product image by video on shop page conditionally
- WooCommerce function not working correctly after moving from the functions.php into a class
- Filter for product subcategory listing page load
- Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)
- get_filtered_term_product_counts – Get product terms if any products
- Get x numbers of a woocommerce category products using Wp_Query
- Get field value and use as variable in php
- Set notification if is two product category in cart
- How to add custom attribute to all outofstock and all instock products automatically?
- Site infected by link
- AJAX to add to cart multiple products woocommerce
- sessionStorage saves input value in browser but it is not loaded in the form field
- Reverse Cross-Sells (WooCommerce)
- Search function not working
- loop to return tags in woocommerce in alphabetical order?
- WooCommerce – Add Shipping class below each product in Shopping Cart page
- WooCommerce Custom Tab with ACF Repeater Field
- I was wondering if it’s possible to implement card.js on WordPress
- Woocommerce custom field on emails outputs ‘Array’
- Display product attributes for current product
- WooCommerce Custom Pagination
- Adding placeholder text field to woocommerce checkout [closed]
- Getting custom field data from cart page to checkout page in woocomerce [closed]
- Send a custom notification to customer on WooCommerce cancelled order status
- How to code bulk order form in wordpress
- WCFM Custom form
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- Why does WordPress not send the user the email to add a password?
- Removing the add to cart button from specific product pages
- WooCommerce Modal Fly cart on add to cart – With AJAX
- Add Woocommerce Customers link to custom admin menu
- Hide ‘Downloadable’ and ‘Virtual’ checkbox options from Woocommerce Variations?
- PayPal button not showing and cannot retrieve order error in PayPal
- Add text below WooCommerce short description if metabox value is true