Answers for "wp wc get cart item attribute"

0

wp wc get cart item attribute

// For each item in cart
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {

    // Get product
    $_product   = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );

    // Get custom attribute
    $foobar = $_product->get_attribute( 'myCustomAttribute' );
    $foobar == true ? $foo = "true" : $foo = "false";  
  }
Posted by: Guest on July-13-2021

Code answers related to "wp wc get cart item attribute"

Browse Popular Code Answers by Language