📌  相关文章
📜  wp wc 获取购物车项目属性 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:07.529000             🧑  作者: Mango

代码示例1
// 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";  
  }