I have a product where it has custom attribute(delivaryDate is attribute name) but no variations are created with it.
On the product page, the attribute is selected.
On the cart page, I am able to retrieve data on all attributes where it has variations. But the attribute where variations are not created cannot be retrieved.
Code used :
foreach ( WC()->cart->get_cart() as $cart_item ) {
$item_data = $cart_item['data'];
echo $item_data;
}
Screenshot of dump for reference.
So is a way to retrieve all attributes values even variation not created with those attributes.
I am looking to get attributeName1_attaributeName2 as a value from each product on cart. Any help would be appericated.
Thanks in advance.
2
Answers
I was able to get this done using a plugin :
Extra product options For WooCommerce and use the below code
When working with WooCommerce, it is always preferred to use their methods.
For getting attributes this would be, continuing as from
$cart_item['data'];
that you already have