1

我正在尝试为我的自定义结帐表单添加折扣我使用了商务折扣,它在我的本地 drupal 7 上运行良好,安装了商务。所以我在出租车网站上试过,但在现场没有添加折扣金额。因此,我在折扣规则上添加了测试操作,以在网站上显示“已添加折扣”消息。
更令人困惑的是消息正在显示,这意味着规则有效但折扣未添加找到我用来将产品添加到购物车的以下代码

    function xxx_commerce_cart_product_add($order, $product, $quantity, $line_item) {
    if ($product->type == 'xxx') {
        $order_wrapper = entity_metadata_wrapper('commerce_order', $order);

    foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
      if ($line_item_wrapper->commerce_product->product_id->value() == $product->product_id) {
         $miles = $_SESSION['booking']['miles'];
         $title = $line_item_wrapper->line_item_label->value();
         $line_item_wrapper->line_item_label->set($title);
         $line_item_wrapper->quantity->set($miles);  
         $line_item_wrapper->save();  
      }
      else {
          // only one cab can be booked in an order, so remove any other cab added previously.
        commerce_cart_order_product_line_item_delete($order, $line_item_wrapper->line_item_id->value());
      }
    }

    $checkout_panes = &drupal_static('commerce_checkout_panes');
    unset($checkout_panes);
  }
  if(arg(0) == 'system') { // on homepage, we have action url to system/ajax for add to cart form.
  // so to avoid viewing a non-viewable path, we are redirecting it here.
    drupal_goto('checkout');
  }
  elseif(arg(0) =='checkout'){
    drupal_goto($_SERVER['REQUEST_URI']);
  }
}`

如何解决上述问题

有什么我想念的吗

请指出我正确的方向

4

0 回答 0