AwoCoupon Redshop - show shipping discount in shipping total


  • Your avatar
    seyi    
     4 years ago
    0

    In www/components/com_redshop/helpers/cart.php, in function replaceTemplate around line 1986 is this
    <?php
        $cart_data 
    str_replace "{shipping_excl_vat}""" $this->_producthelper->getProductFormattedPrice $shipping-$cart['shipping_tax'], true ) . ""$cart_data );
    ?>


    add this after that
    <?php
        
    # seyi_code
            
    $shipping_discount 0;
            if(!empty(
    $cart['coupon'])) foreach($cart['coupon'] as $rcoup$shipping_discount += $rcoup['shipping_discount'];
            
    $cart_data str_replace "{shipping_total_including_discount}""" $this->_producthelper->getProductFormattedPrice $shipping-$shipping_discounttrue ) . ""$cart_data );
            
    $discount_amount -= $shipping_discount;
        }
    ?>


    and in function replaceOrderTemplate around line 2346 is this
    <?php
        $ReceiptTemplate     
    $this->replaceShippingAddress($ReceiptTemplate,$shippingaddresses);
    ?>


    add this after that
    <?php
        
    # seyi_code
            
    $db JFactory :: getDBO();
            
    $db->setQuery('SELECT SUM(shipping_discount) FROM #__awocoupon_history WHERE estore="redshop" AND order_id='.$order_id.' GROUP BY order_id');
            
    $shipping_discount = (float)$db->loadResult();

            
    $search[] = "{shipping_total_including_discount}";
            
    $replace[] = $row->order_shipping-$shipping_discount;
            
    $row->order_discount -= $shipping_discount;
        }
    ?>


    The variable {shipping_total_including_discount} now contains the shipping total including vat, with the discount included. You will then have to update your templates and emails to use the correct dynamic variable.

    Some of the templates that need updating include:
    - cart/cart
    - checkout/checkout template
    - order_detail/order detail
    - order_receipt/order receipt

    For email, you should update order mail.