Guest User

Untitled

a guest
Dec 13th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. <?php
  2. // For each item in cart
  3. foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
  4.  
  5. // Get product
  6. $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
  7.  
  8. // Get custom attribute
  9. $foobar = $_product->get_attribute( 'myCustomAttribute' );
  10. $foobar == true ? $foo = "true" : $foo = "false";
  11. ?>
  12.  
  13. // Add table row with custom attribute as a data attribute
  14. <tr data-foo=<?php echo "$foo"; ?>>...Content in here</tr>
  15. <?php
  16. }
Add Comment
Please, Sign In to add comment