Support » Plugin: Extra Product Options (Product Addons) for WooCommerce » get attribute value in cart template file

  • Resolved tonio7788

    (@tonio7788)


    Hi,

    How to display attribute value in template like cart :

    I tried :

    $custom_field = get_post_meta( $product_id, 'attribute_name', true); 
    echo $custom_field 

    Doesn’t work…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    We believe that you want to show the data filled in the product page from a custom field created by our extra product option addon.

    If so, you need to iterate data from cart item data. The code is given below.

    global $woocommerce;
    $products = $woocommerce->cart->get_cart();

    foreach($products as $key => $product) { // Iterate cart items
    if (array_key_exists(“thwepof_options”,$product)){
    $data = $product[“thwepof_options”];
    if(!empty($data)){
    foreach($data as $item){ // Iterate item options
    //var_dump($item);
    echo $item[‘label’];
    echo $item[‘value’];
    }
    }
    }
    }

    Hope this help 🙂

    Thank you!

    Hello,

    I have created custom field for other product and added to product page. Now, i want add custom field product to cart with the existing product value so what can i do for it?

    explanation- I have product ‘A’ and i set custom field exact below to add to cart button on Product ‘A’ page for product ‘B’ to add both product to cart.

    Plugin Author ThemeHigh

    (@themehigh)

    @webkinds We are a little bit unclear about your exact requirement. Could you please clarify us with more details?

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get attribute value in cart template file’ is closed to new replies.