1

i am trying to add discount to my custom checkout form I have used commerce discount it is working fine on my local drupal 7 with commerce installation. so i have tried on the cab site,but on the live site is not adding the discount amount. So i have added the test action on the discount rule to show the message on the site "discount added".
what more confussing is the message is displaying which means the rule is working but the discount is not adding find the below code i have used to add product to cart

    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']);
  }
}`

how to solve the above issue

Is there some thing i am missing

Please point me in right direction

Dinkaran Ilango
  • 513
  • 1
  • 4
  • 11

0 Answers0