【问题标题】:Getting quantity and price of a specific item drupal ecommerce获取特定商品的数量和价格 drupal ecommerce
【发布时间】:2013-10-16 02:18:33
【问题描述】:

我正在尝试使用电子商务在 drupal 中创建一个异地支付模块。 我需要找到特定产品的数量和价格。 产品1数量 产品1价格 产品2数量 Product2Price 等等。

【问题讨论】:

    标签: php drupal e-commerce payment-gateway


    【解决方案1】:

    这就是我最终要做的。

        $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
    $quantityAndPrice = array();
    
    foreach ( $order_wrapper->commerce_line_items as $line_item_wrapper )
    {
        $quantityAndPrice .= round($line_item_wrapper->quantity->value()) ."";
        $quantityAndPrice .= $line_item_wrapper->commerce_unit_price->amount->value();
    }
    

    【讨论】:

      【解决方案2】:

      您需要获取您要查找的订单的 order_id。您可以使用 sql 查询来执行此操作。

      获得 order_id 后,您可以使用 commerce_order_load($order_id) 加载订单

      见:http://drupalcontrib.org/api/drupal/contributions!commerce!modules!order!commerce_order.module/function/commerce_order_load/7

      当您拥有 $order 对象时,您可以使用 echo "<pre>"; print_r($order); 探索它们,我相信您需要的所有变量都将包含在其中。

      【讨论】:

        猜你喜欢
        • 2017-04-04
        • 2011-10-03
        • 1970-01-01
        • 2014-04-10
        • 1970-01-01
        • 2023-01-04
        • 2022-01-24
        • 1970-01-01
        • 2019-05-07
        相关资源
        最近更新 更多