Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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";  
  }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wp #wc #cart #item #attribute
ADD COMMENT
Topic
Name
3+2 =