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