• Resolved anngelo0

    (@anngelo0)


    As the title says, I want to add different attributes to different products which will not be seen on the UI nor used for more variations, but in php.

    So for example, one product will have attr attr1, another product will have attr=”value1″ attr2=”value2″.

    I have an variable product with different variations. I have added a new attribute without checking “Visible on the product page” and “Used for variations”, but its value is not retrieved with the product. How can I achieve this result ?

    This is how am I trying to get it in the checkout page:

    add_action( 'template_redirect', 'retrieve_data' );
    function retrieve_data() {
      $cart = WC()->cart;
      $items = $cart->get_cart();
    	foreach ($items as $cart_item ) {
        $item_data = $cart_item['data'];
        $attributes = $item_data->get_attributes();
        print("<pre>".print_r($attributes,true)."</pre>")
      }
    }

    This print will only show my variation attributes with their values.

    • This topic was modified 4 years, 6 months ago by anngelo0.
    • This topic was modified 4 years, 6 months ago by anngelo0.
    • This topic was modified 4 years, 6 months ago by anngelo0.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Product custom attribute’ is closed to new replies.