【问题标题】:WooCommerce Cart Product of Qty and ACF Value, issue with VariablesWooCommerce 购物车产品的数量和 ACF 值,变量问题
【发布时间】:2020-05-03 16:59:27
【问题描述】:

我正在尝试获取来自 $cart_item['quantity']get_field('box_sqft') 的值的产品

我的尝试是根据数量框中的数量显示产品的总平方英尺。

每个产品都有包含平方英尺值的自定义字段。

<?php

$sqft = get_field('box_sqft');
$qty =  $cart_item['quantity'];

$total = $qty * $sqft;

echo $total;

?>

我认为解决方案与$_POST 有关,但不是 100% 确定。

【问题讨论】:

  • 我想我找到了问题和解决方案,但我很想看到大家对此的意见。
  • 使用foreach( WC()-&gt;cart-&gt;get_cart() as $cart_item ){ 遍历购物车项目时,您将使用$sqft = get_field('box_sqft', $cart_item['product_id']);$sqft = get_field('box_sqft', $cart_item['data']-&gt;get_id());

标签: wordpress woocommerce


【解决方案1】:

我的解决方案是:

$sqft = get_field('box_sqft', $product_id);
$qty =  $cart_item['quantity'];
echo ($qty * $sqft);

@LoicTheAztec 非常感谢您的帮助,但我认为没有理由探索您的解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-18
    • 2022-10-01
    • 2017-12-10
    • 1970-01-01
    • 2021-05-16
    • 1970-01-01
    • 2020-09-27
    • 2021-10-31
    相关资源
    最近更新 更多