WC Product Attributes to Merge Tag
-
Hi guys, I’m having a problem adding WooCommerce Product Attributes to a Merge Tag.
For Example: I have 1 Product (WooCommerce Subscription) which has 2 variations:
1. Duration(6 months, 1 year, lifetime)
&
2. Type(Couple, Etudiant, Normal)
both has 3 attributes as above.
I am trying to add something here but not sure how to make it work, any help is welcome, thanks ahead.function product_mailchimp_tag($tags, $email) { $new_tags = []; $query = new WC_Order_Query(); $query->set('customer', $email); $customer_orders = $query->get_orders(); if ($customer_orders) { $last_order = $customer_orders[0]; $products = $last_order->get_items(); foreach ($products as $product) { // Get the product attribute first value. $duration = $product->get_attribute('pa_plan-duration'); $product_tags = [ 'name' => strpos($duration), 'status' => 'active' ]; array_push($new_tags, $product_tags); } } return array_merge($tags, $new_tags); add_filter('mailchimp_user_tags', 'product_mailchimp_tag', 10, 2);
This is for “Duration” and I’m not sure it works well. How can I add both Duration and Type and insert 1 of 3 values that people choose under product variations into merge-tags and insert them into my audience?
cheers
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘WC Product Attributes to Merge Tag’ is closed to new replies.