Jump to content
kgt

[Contribution] Discount Coupon Codes

Recommended Posts

Further to the issues on integrating Paypal Pro and Paypal Express, I have the same issue.

 

Using PayPal Pro to process credit cards is fine because the client is taken through checkout_payment.php which is where the discount code is gathered and processed

 

If the client opts for PayPal Express, they never see the checkout_payment.php code but jump from:

 

checkout_shipping.php -> Paypal -> checkout_shipping.php -> checkout_confirmation.php

 

Any solutions would be greatly appreciated as this is a superb mod with a ton of potential for my shop.

 

Kind regards

 

Jay

Share this post


Link to post
Share on other sites
Further to the issues on integrating Paypal Pro and Paypal Express, I have the same issue.

 

Using PayPal Pro to process credit cards is fine because the client is taken through checkout_payment.php which is where the discount code is gathered and processed

 

If the client opts for PayPal Express, they never see the checkout_payment.php code but jump from:

 

checkout_shipping.php -> Paypal -> checkout_shipping.php -> checkout_confirmation.php

 

Any solutions would be greatly appreciated as this is a superb mod with a ton of potential for my shop.

 

Kind regards

 

Jay

Getting closer - I noted that using the installed Paypal Pro contribution by dynamoeffects I can steer PayPal Express clients through the checkout payments page

 

Only issue I have now is a 'shortfall' email from paypal when the payment comes through - I'll take a look later and hack it a little.

Share this post


Link to post
Share on other sites

Have this installed and its working great. One slight tweak I'd like to make is with regards to the contents of the email sent to the customers.

 

I'd like the coupons appearing on the next line, below shipping. Currently they are appearing on the same line so it looks like this:

 

Sub-Total: £25.25

Royal Mail Standard Parcels (3-5 days delivery): £3.95 Discount Coupon august07 applied: -£2.81

Total: £29.20

 

Where would I add a new line break to the string that generates the second line?

 

Thanks in advance

Share this post


Link to post
Share on other sites

Solved it - just added the '\n' to this code in includes/languages/english/modules/order_total/ot_discount_coupon.php

 

define('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_FILE', '\nDiscount Coupon [code] applied');

Share this post


Link to post
Share on other sites

This is the most awesome mod for osCommerce I've ever used. It works flawlessly for me so far. I appreciate you actively supporting this mod. You are a credit to the community.

Share this post


Link to post
Share on other sites

Is there any way possible to add the data entry of the coupon code in the shopping cart?

 

I would like to give 100% discount on some things, enabling the customer to bypass the payment page.

 

Thanks

Share this post


Link to post
Share on other sites
Everything seems to be working properly. I have not encountered any issues with the coupon yet except after I have installed the module I cannot access my admin interface. Everytime I try to get to the admin interface I get a error 404 page cannot be displayed.

 

This might have been answered but 72 pages is a lot to sift through! Thanks for any help!

 

I am having the same problem. Any suggestions?

 

Thank you!

Share this post


Link to post
Share on other sites
I am having the same problem. Any suggestions?

 

Thank you!

 

Also, I just happened to notice that when adding this contribution and attributes are added to a product, the price doubles.

 

Example:

Yellow Ball (no attributes) $50.00 (only price) shows correct price of $50.00 when checkout.

Red Ball (with attributes) Base price $50.00 (attribute of a different size makes it $100.00) when checking out it does not show $100.00 (if I select the attribute for a different size for the $100.00 product) when checking out, it doubles the price to $200.00 and it should be $100.00

 

Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites

I got a problem.

 

Few days ago I installed the contribution without any problem, and it is working fine after testing.

 

However, today, after upgrading PERL from 5.8.7 to 5.8.8, I notice that there are now some problem with the discount coupon. The TOTAL is not right, discount coupon is not being deducted. Eg.:

 

Sub-Total: RM349.50

PosLaju / EMS Shipping (1~2 business days to arrive): RM0.00

Discount Coupon SHASHINKI-01 applied:: -RM5.00

Total: RM349.50 (Should be RM344.00)

 

I am not sure if this is due to PERL upgrade or not, but can anybody help me or teach me what I should check? :'(


Best regards,

Koh Kho King

Share this post


Link to post
Share on other sites

Hi guys/girls,

 

I'm having an issue getting the discount coupons offering a postage cost reduction to work. They just don't seem to ammend the price at all?

 

Sorry if this has been questioned before. I scanned through and searched but I may well have missed it!

 

Thanks

 

:)

Share this post


Link to post
Share on other sites
Also, I just happened to notice that when adding this contribution and attributes are added to a product, the price doubles.

 

Example:

Yellow Ball (no attributes) $50.00 (only price) shows correct price of $50.00 when checkout.

Red Ball (with attributes) Base price $50.00 (attribute of a different size makes it $100.00) when checking out it does not show $100.00 (if I select the attribute for a different size for the $100.00 product) when checking out, it doubles the price to $200.00 and it should be $100.00

 

Any help would be greatly appreciated.

 

Still having the same issues as above as well as 404 error (logging in and out) when this contribution is applied.

 

Any advice, anyone???

Share this post


Link to post
Share on other sites

I recently installed v 3.3 but I am getting wacky results. At first I thought it wasn't working. Everything works fine on the admin side. However, on the customer side, they can enter the code, but it doesn't always apply the discount.

 

1) Discount only works with the "shipping discount" and will not work with "percentage discount" or "fixed amount"

2) If there is a minimum requirement for product quantity or price total, it will not work and results in an error message, even though the requirement is met.

 

 

Any help would be greatly appreciated!

Share this post


Link to post
Share on other sites

I went through the instructions for Discount Coupon Code 3.3 but when I go to open the module in admin/modules./order total the "discount code" module does not exist for me to install...what am I missing?

Share this post


Link to post
Share on other sites

The "Display subtotal with applied discount?" when set to FALSE is not working. Subtotal still showing the discounted price. Is there a way to make this works?

 

I asked because I have shipping based on price. For order above $50, I give free shipping. If below that, I charged $10 shipping.

 

When a customer purchased a $70 product and use a $30 discount coupon, the subtotal becomes $40 and there will still be $10 shipping charged to it. This is wrong and I do not want to charge customer shipping based on subtotal after discount. It should be FREE SHIPPING as the original purchase is already over $50.

 

How to solve this?


Best regards,

Koh Kho King

Share this post


Link to post
Share on other sites
Discount dependent on shipping module.

 

Would it be possible to apply the discount just on a particular shipping module? Or, exclude a particular shipping module from discount. I don't use shipping zones.

 

A possible solution could be inserting an IF function in the checkout_payment.php file for example.

Not sure whether it's that easy or any impacts to that, but your suggestions are welcome.

 

Example:

active shipping module 1: UPS - 10.00

active shipping module 2: DHL - 10.00

active shipping module 3: UPS express - 20.00

 

The discount should only be applied to module 1 or 2. If customer chooses for shipping option 3 no discount should be applied.

 

Another scenario would be that if shipping discount is setup (100%) then for shipping module 1+2 the shipping fee becomes 0.

However, if customer chooses module 3 then 10.00 discount is applied.

 

Can either of the two scenarios be covered in this discount module (e.g. using IF function)?

If so, I would appreciate your input it's not ideal, but I don't mind to hard code anything in the files rather then to have a nice front end in admin. As long as I can cover this.).

 

thanks

 

Could someone assist me with the above please?

Share this post


Link to post
Share on other sites

Hello,

Great contribution by the way. I only have one problem, Im using the latest OSC and have managed to pretty much get the whole contribution working. The only file giving me problems is order.php in classes. As when I try to update this file using the instructions the order total automatically goes to 0.

 

My order.php shows the following code

        $shown_price = $currencies->calculate_price($this->products[$index]['final_price'], $this->products[$index]['tax'], $this->products[$index]['qty']);
       $this->info['subtotal'] += $shown_price;

 

Where as the instructions ask me to edit the following code

        $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];
       $this->info['subtotal'] += $shown_price;

 

The contribution code does not have $currencies->calculate_price, I dont know if this is the only issue. I am using 2.2 RC1, if anyone knows a workaround it would be greatly appreciated it.

 

Kind regards

 

M PArmar

Share this post


Link to post
Share on other sites
The only file giving me problems is order.php in classes.

I didn't study your question in enough detail to know if this is the problem, but I just installed the module and discovered the "New Install" instructions are missing a line for catalog/includes/classes/order.php. They need to say to add the following after line 15:

//kgt - discount coupon

var $coupon;

//end kgt - discount coupon

 

The above code is in the sample order.php file provided, it's just not mentioned in the instructions.

Share this post


Link to post
Share on other sites

Hi,

I just installed the discount coupon codes contribution to my catalog and all seemed to be working well, i noticed that with paypal ipn the discount does not transfer (i am using 2.2RC1) so i then changed code as stated in the documentation and also added the 3.3 bug fixes.

 

Now i get this message when i go to log into admin;

 

 

The requested URL /catalog/admin/FILENAME_LOGIN was not found on this server.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

 

What do i have to do please to fix?

 

catalog seems to be working ok, it is just the admin area which i cannot access.

 

Thank you.

Share this post


Link to post
Share on other sites

Just wondering if anyone knows of a way to modify this contribution to work for an individual product. I would like to make a coupon only apply to one product.

 

Thanks

Share this post


Link to post
Share on other sites
Just wondering if anyone knows of a way to modify this contribution to work for an individual product. I would like to make a coupon only apply to one product.

 

Thanks

 

There is setting in this mode to exclude the product/s you want to allow for the coupon. There is a select all, then remove the one you want to use the coupon.


Best regards,

Koh Kho King

Share this post


Link to post
Share on other sites

When I check out using PayPal, and have a discount applied, checkout_confirmation incorrectly calculates the "amount" output to PayPal.

 

$1.00 Price

$1.00 Sub Total

$2.25 Shipping

-$2.25 Shipping Discount Applied

 

$1.00 Total

 

I am giving a FREE SHIPPING ON FIRST ORDER incentive.

 

checkout_confirmation.php calculates this amount as -$1.25 as follows;

<input name="cmd" value="_xclick" type="hidden"><input name="business" value="me@mystore.com" type="hidden">

<input name="item_name" value="MYSTORE" type="hidden"><input name="amount" value="-1.25" type="hidden">

<input name="shipping" value="2.25" type="hidden"><input name="currency_code" value="USD" type="hidden">

<input name="return" value="http://www.mystore.com/catalog/checkout_process.php" type="hidden">

<input name="cancel_return" value="http://www.mystore.com/catalog/checkout_payment.php" type="hidden">

<input src="includes/languages/english/images/buttons/button_confirm_order.gif" alt="Confirm Order" title=" Confirm Order " border="0" type="image">

 

When clicking through to PayPal, PayPal doesn't like this -$1.25 and throws the following message;

"The link you have used to enter the PayPal system contains an incorrectly formatted item amount."

 

As long as the product purchased price is greater than the discount, everything works great, but when the discount is greater than the product price, the above error appears.

 

Where and how is the "amount" value calculated and how should I change it to output...

<input name="cmd" value="_xclick" type="hidden"><input name="business" value="me@mystore.com" type="hidden">

<input name="item_name" value="MYSTORE" type="hidden"><input name="amount" value="1.00" type="hidden">

<input name="shipping" value="0" type="hidden"><input name="currency_code" value="USD" type="hidden">

<input name="return" value="http://www.mystore.com/catalog/checkout_process.php" type="hidden">

<input name="cancel_return" value="http://www.mystore.com/catalog/checkout_payment.php" type="hidden">

<input src="includes/languages/english/images/buttons/button_confirm_order.gif" alt="Confirm Order" title=" Confirm Order " border="0" type="image">

 

OSC 2.2 RC1

Discount Coupon Codes 3.3

 

Thanks for any and all help!

Share this post


Link to post
Share on other sites
Still having the same issues as above as well as 404 error (logging in and out) when this contribution is applied.

 

Any advice, anyone???

 

I have read through all 70+ pages of this thread. Cannot seem to find resolution on the above issues I posted (as well as others who are experiencing the same).

 

Any help or suggestions would be greatly appreciated. Do we need to send a cookie basket somewhere :)

 

Much thanks in advance for any help!

Share this post


Link to post
Share on other sites
Had that same problem, then I just got my backup file and did all the modfications from 3.3 manually again and removed /**** old code part***/ just to be safe. Problem solved.

Could you be more specific on the resolution? I am having the same problem.

 

Much thanks in advance!!!

Share this post


Link to post
Share on other sites
Could you be more specific on the resolution? I am having the same problem.

 

Much thanks in advance!!!

 

File directory: catalog>includes>classes>order.php

 

<?php

/*

$Id: order.php,v 1.33 2003/06/09 22:25:35 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

09/10/2007: Bug: Products with attributes, different prices per attribute = product price would double and coupon code would not be applied when at checkout_confirmation.php | lyonscreative.com

 

Released under the GNU General Public License

*/

 

class order {

var $info, $totals, $products, $customer, $delivery, $content_type;

 

function order($order_id = '') {

$this->info = array();

$this->totals = array();

$this->products = array();

$this->customer = array();

$this->delivery = array();

 

if (tep_not_null($order_id)) {

$this->query($order_id);

} else {

$this->cart();

}

}

 

function query($order_id) {

global $languages_id;

 

$order_id = tep_db_prepare_input($order_id);

 

$order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");

$order = tep_db_fetch_array($order_query);

 

$totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order");

while ($totals = tep_db_fetch_array($totals_query)) {

$this->totals[] = array('title' => $totals['title'],

'text' => $totals['text']);

}

 

$order_total_query = tep_db_query("select text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_total'");

$order_total = tep_db_fetch_array($order_total_query);

 

$shipping_method_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_shipping'");

$shipping_method = tep_db_fetch_array($shipping_method_query);

 

$order_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . $order['orders_status'] . "' and language_id = '" . (int)$languages_id . "'");

$order_status = tep_db_fetch_array($order_status_query);

 

$this->info = array('currency' => $order['currency'],

'currency_value' => $order['currency_value'],

'payment_method' => $order['payment_method'],

'cc_type' => $order['cc_type'],

'cc_owner' => $order['cc_owner'],

'cc_number' => $order['cc_number'],

'cc_expires' => $order['cc_expires'],

'date_purchased' => $order['date_purchased'],

'orders_status' => $order_status['orders_status_name'],

'last_modified' => $order['last_modified'],

'total' => strip_tags($order_total['text']),

'shipping_method' => ((substr($shipping_method['title'], -1) == ':') ? substr(strip_tags($shipping_method['title']), 0, -1) : strip_tags($shipping_method['title'])));

 

$this->customer = array('id' => $order['customers_id'],

'name' => $order['customers_name'],

'company' => $order['customers_company'],

'street_address' => $order['customers_street_address'],

'suburb' => $order['customers_suburb'],

'city' => $order['customers_city'],

'postcode' => $order['customers_postcode'],

'state' => $order['customers_state'],

'country' => array('title' => $order['customers_country']),

'format_id' => $order['customers_address_format_id'],

'telephone' => $order['customers_telephone'],

'email_address' => $order['customers_email_address']);

 

$this->delivery = array('name' => $order['delivery_name'],

'company' => $order['delivery_company'],

'street_address' => $order['delivery_street_address'],

'suburb' => $order['delivery_suburb'],

'city' => $order['delivery_city'],

'postcode' => $order['delivery_postcode'],

'state' => $order['delivery_state'],

'country' => array('title' => $order['delivery_country']),

'format_id' => $order['delivery_address_format_id']);

 

if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) {

$this->delivery = false;

}

 

$this->billing = array('name' => $order['billing_name'],

'company' => $order['billing_company'],

'street_address' => $order['billing_street_address'],

'suburb' => $order['billing_suburb'],

'city' => $order['billing_city'],

'postcode' => $order['billing_postcode'],

'state' => $order['billing_state'],

'country' => array('title' => $order['billing_country']),

'format_id' => $order['billing_address_format_id']);

 

$index = 0;

$orders_products_query = tep_db_query("select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");

while ($orders_products = tep_db_fetch_array($orders_products_query)) {

$this->products[$index] = array('qty' => $orders_products['products_quantity'],

'id' => $orders_products['products_id'],

'name' => $orders_products['products_name'],

'model' => $orders_products['products_model'],

'tax' => $orders_products['products_tax'],

'price' => $orders_products['products_price'],

'final_price' => $orders_products['final_price']);

 

$subindex = 0;

$attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");

if (tep_db_num_rows($attributes_query)) {

while ($attributes = tep_db_fetch_array($attributes_query)) {

$this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],

'value' => $attributes['products_options_values'],

'prefix' => $attributes['price_prefix'],

'price' => $attributes['options_values_price']);

 

$subindex++;

}

}

 

$this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1';

 

$index++;

}

}

 

function cart() {

global $HTTP_POST_VARS, $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment, $comments;

 

$this->content_type = $cart->get_content_type();

 

$customer_address_query = tep_db_query("select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int)$customer_id . "' and ab.customers_id = '" . (int)$customer_id . "' and c.customers_default_address_id = ab.address_book_id");

$customer_address = tep_db_fetch_array($customer_address_query);

 

$shipping_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$sendto . "'");

$shipping_address = tep_db_fetch_array($shipping_address_query);

 

$billing_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$billto . "'");

$billing_address = tep_db_fetch_array($billing_address_query);

 

$tax_address_query = tep_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $billto : $sendto) . "'");

$tax_address = tep_db_fetch_array($tax_address_query);

 

$this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,

'currency' => $currency,

'currency_value' => $currencies->currencies[$currency]['value'],

'payment_method' => $payment,

'cc_type' => (isset($HTTP_POST_VARS['cc_type']) ? $HTTP_POST_VARS['cc_type'] : ''),

'cc_owner' => (isset($HTTP_POST_VARS['cc_owner']) ? $HTTP_POST_VARS['cc_owner'] : ''),

'cc_number' => (isset($HTTP_POST_VARS['cc_number_nh-dns']) ? $HTTP_POST_VARS['cc_number_nh-dns'] : ''),

'cc_expires' => (isset($HTTP_POST_VARS['cc_expires']) ? $HTTP_POST_VARS['cc_expires'] : ''),

'shipping_method' => $shipping['title'],

'shipping_cost' => $shipping['cost'],

'subtotal' => 0,

'tax' => 0,

'tax_groups' => array(),

'comments' => (tep_session_is_registered('comments') && !empty($comments) ? $comments : ''));

 

if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) {

if (isset($GLOBALS[$payment]->public_title)) {

$this->info['payment_method'] = $GLOBALS[$payment]->public_title;

} else {

$this->info['payment_method'] = $GLOBALS[$payment]->title;

}

 

if ( isset($GLOBALS[$payment]->order_status) && is_numeric($GLOBALS[$payment]->order_status) && ($GLOBALS[$payment]->order_status > 0) ) {

$this->info['order_status'] = $GLOBALS[$payment]->order_status;

}

}

 

$this->customer = array('firstname' => $customer_address['customers_firstname'],

'lastname' => $customer_address['customers_lastname'],

'company' => $customer_address['entry_company'],

'street_address' => $customer_address['entry_street_address'],

'suburb' => $customer_address['entry_suburb'],

'city' => $customer_address['entry_city'],

'postcode' => $customer_address['entry_postcode'],

'state' => ((tep_not_null($customer_address['entry_state'])) ? $customer_address['entry_state'] : $customer_address['zone_name']),

'zone_id' => $customer_address['entry_zone_id'],

'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']),

'format_id' => $customer_address['address_format_id'],

'telephone' => $customer_address['customers_telephone'],

'email_address' => $customer_address['customers_email_address']);

 

$this->delivery = array('firstname' => $shipping_address['entry_firstname'],

'lastname' => $shipping_address['entry_lastname'],

'company' => $shipping_address['entry_company'],

'street_address' => $shipping_address['entry_street_address'],

'suburb' => $shipping_address['entry_suburb'],

'city' => $shipping_address['entry_city'],

'postcode' => $shipping_address['entry_postcode'],

'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']),

'zone_id' => $shipping_address['entry_zone_id'],

'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']),

'country_id' => $shipping_address['entry_country_id'],

'format_id' => $shipping_address['address_format_id']);

 

$this->billing = array('firstname' => $billing_address['entry_firstname'],

'lastname' => $billing_address['entry_lastname'],

'company' => $billing_address['entry_company'],

'street_address' => $billing_address['entry_street_address'],

'suburb' => $billing_address['entry_suburb'],

'city' => $billing_address['entry_city'],

'postcode' => $billing_address['entry_postcode'],

'state' => ((tep_not_null($billing_address['entry_state'])) ? $billing_address['entry_state'] : $billing_address['zone_name']),

'zone_id' => $billing_address['entry_zone_id'],

'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']),

'country_id' => $billing_address['entry_country_id'],

'format_id' => $billing_address['address_format_id']);

 

$index = 0;

$products = $cart->get_products();

 

//kgt - discount coupons

global $coupon;

if( tep_session_is_registered( 'coupon' ) && tep_not_null( $coupon ) ) {

require_once( DIR_WS_CLASSES.'discount_coupon.php' );

$this->coupon = new discount_coupon( $coupon, $this->delivery );

$this->coupon->total_valid_products( $products );

$valid_products_count = 0;

}

//end kgt - discount coupons

 

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

$this->products[$index] = array('qty' => $products[$i]['quantity'],

'name' => $products[$i]['name'],

'model' => $products[$i]['model'],

'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),

'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),

'price' => $products[$i]['price'],

'final_price' => $products[$i]['final_price'],

'weight' => $products[$i]['weight'],

'id' => $products[$i]['id']);

 

if ($products[$i]['attributes']) {

$subindex = 0;

reset($products[$i]['attributes']);

while (list($option, $value) = each($products[$i]['attributes'])) {

$attributes_query = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");

$attributes = tep_db_fetch_array($attributes_query);

 

$this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'],

'value' => $attributes['products_options_values_name'],

'option_id' => $option,

'value_id' => $value,

'prefix' => $attributes['price_prefix'],

'price' => $attributes['options_values_price']);

 

$subindex++;

}

}

 

 

 

//kgt - discount coupons

if( is_object( $this->coupon ) ) {

$applied_discount = 0;

$discount = $this->coupon->calculate_discount( $this->products[$index], $valid_products_count );

if( $discount['applied_discount'] > 0 ) $valid_products_count++;

$shown_price = $this->coupon->calculate_shown_price( $discount, $this->products[$index] );

$this->info['subtotal'] += $shown_price['shown_price'];

$shown_price = $shown_price['actual_shown_price'];

} else {

$shown_price = $currencies->calculate_price($this->products[$index]['final_price'], $this->products[$index]['tax'], $this->products[$index]['qty']);

$this->info['subtotal'] += $shown_price;

}

//end kgt - discount coupons

 

$products_tax = $this->products[$index]['tax'];

$products_tax_description = $this->products[$index]['tax_description'];

if (DISPLAY_PRICE_WITH_TAX == 'true') {

$this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));

if (isset($this->info['tax_groups']["$products_tax_description"])) {

$this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));

} else {

$this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));

}

} else {

$this->info['tax'] += ($products_tax / 100) * $shown_price;

if (isset($this->info['tax_groups']["$products_tax_description"])) {

$this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price;

} else {

$this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price;

}

}

 

$index++;

}

 

if (DISPLAY_PRICE_WITH_TAX == 'true') {

$this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];

} else {

$this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];

}

 

//kgt - discount coupon

if( is_object( $this->coupon ) ) {

$this->info['total'] = $this->coupon->finalize_discount( $this->info );

}

//end kgt - discount coupon

 

}

}

?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×