Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

xndxndxnd

Archived
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Real Name
    Lyman

xndxndxnd's Achievements

  1. Thank you for your answer, but I'm not saying I need to add a new option in admin. I think it's easy to change the percentage option into what I want. case 'percent': $applied_discount = $product['final_price'] * $this->coupon['coupons_discount_amount'] * $product['qty']; I want to change the formula above into $applied_discount = $product['final_price'] * $this->coupon['coupons_discount_amount'] * $product['qty'] + " Shipping cost" * $this->coupon['coupons_discount_amount'] ; But I don't what's the shipping cost here. I tried "$info['shipping_cost'] ", but it doesn't work. Can anyone tell me?
  2. Can anyone help me? I'd like to include shipping cost when using percentage discount. Let's say I have a 10% percentage discount. I hope, the discount = 10% * ( price total + shipping cost). I found from the discout_coupon.php that there are two functions may be important. But I failed many times after I tried to modifiy them. Can you give me some advice? Thank you in advance. function calculate_discount( $product = array(), $current_product = 0 ) { if( !$this->is_allowed_product( tep_get_prid( $product['id'] ) ) ) { //check that the product isn't excluded $applied_discount = 0; //don't apply a discount if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG == 'true' ) $this->message( 'INFO: Excluded product '.$product['id'].'. Discount of '.$applied_discount.' not applied.', 'debug' ); } else { switch( $this->coupon['coupons_discount_type'] ) { case 'shipping': $applied_discount = 0; break; case 'fixed': //get the percentage of the total discount to apply to this item: $percentage_applied = $this->coupon['coupons_discount_amount'] / $this->cart_info['valid_products']['total']; if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG == 'true' ) $this->message( 'INFO: Percentage of discount applied to product '.$product['id'].': '.$percentage_applied.'.', 'debug' ); //calculate the applied discount: $applied_discount = $product['final_price'] - $percentage_applied; if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG == 'true' ) $this->message( 'INFO: Fixed discount applied to product '.$product['id'].': '.$applied_discount.'.', 'debug' ); //this section is to make sure that both the fixed discount and the tax are correct: if( $this->cart_info['valid_products']['line_items'] == ( $current_product + 1 ) ) { $difference = $this->coupon['coupons_discount_amount'] - ( array_sum( $this->applied_discount ) + $applied_discount ); if( $difference != 0 ) { if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG == 'true' ) $this->message( 'INFO: Fixed adjustment for product '.$product['id'].': difference: '.$difference.' unadjusted applied_discount: '.$applied_discount, 'debug' ); $applied_discount += $difference; } } //end code to ensure accurate fixed discount and tax break; case 'percent': $applied_discount = $product['final_price'] * $this->coupon['coupons_discount_amount'] * $product['qty']; break; } function finalize_discount( $info ) { //make sure we meet the order minimum if( !$this->check_coupons_min_order() ) { $this->applied_discount = array(); if( $this->is_exists_exclusions() ) $this->message( ENTRY_DISCOUNT_COUPON_EXCLUSION_ERROR ); //add on to the min_order error message since we have excluded items } if( !$this->is_errors() ) { //if there are no errors, we can apply the discount if( $this->coupon['coupons_discount_type'] == 'shipping' ) { //discount shipping if the coupon type is shipping $this->applied_discount['shipping'] = $info['shipping_cost'] * $this->coupon['coupons_discount_amount']; $this->applied_discount['shipping'] = $this->applied_discount['shipping']; $info['total'] -= $this->applied_discount['shipping']; if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG == 'true' ) $this->message( 'INFO: Shipping Discount of '.$this->applied_discount['shipping'].' applied.', 'debug' ); } else if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) { //subtract the discount from the order total if it's not displayed in the subtotal foreach( $this->applied_discount as $discount ) { $info['total'] -= $discount; if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG == 'true' ) $this->message( 'INFO: Discount of '.$discount.' applied to order total.', 'debug' ); } } if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_ALLOW_NEGATIVE == 'false' && $info['total'] < 0 ) $info['total'] = 0; } return $info['total']; }
×
×
  • Create New...