Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

Did you update the database file?

 

 

Hi David,

 

Yes from the admin - as in the instructs.

I'm not getting any sql errors at all.

 

As mentioned, all other functions are working just fine.

 

any ideas?

 

EDIT:

ooops I misread your post ( database file). Yes, I sure did. went over all edits twice.

Edited by vegasbeach
Link to comment
Share on other sites

Hello,

anyone can use coupon excllusions?

I mean the javascript code in coupons esclusions class do not work. I tried some code hack but when JS functions works it cannot pass post arrays to php, when the posts works, the select multple js function stop working

Link to comment
Share on other sites

yes - I had to hand edit the database_tables.php and filenames.php files in admin/includes and /includes to get it to work. It would be nice to have it fixed but I also want to make sure I'm not going to hit anything else.

 

Thanks!

 

Any chance you could tell me what edits you needed to make to the files and I'll do the same if it's going to take a while to get a fix.

 

Thanks in advance.

Link to comment
Share on other sites

ok after 2 days of hard work the coupons works great. Just a little doubt about zone exclusions.

If someone is interest i can repack all the files to a new zip and post it on the contribution page

Link to comment
Share on other sites

ok after 2 days of hard work the coupons works great. Just a little doubt about zone exclusions.

If someone is interest i can repack all the files to a new zip and post it on the contribution page

Yes, such fixes should be posted or uploaded as a new version since others may have the same problem.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Hi Wonder some wonderful soul can help me? Bear with me i am a php novice :rolleyes:

 

This a fantastic cont and i have installed it on my OSC 2.2 great and did a manual edit of the exsisting files due to other contributions included. Exrything works but..............

 

I have one contribution which solved my prob with paypal payments where i was not getting the order one in a email and two into the orders on the database so i used the cont fix for paypal payment received without order which basically puts in another confirmation.php page in to force the order details to come to me before payment is made through paypal.

 

With this cont all works as it should up till the 1st checkout comfirmation.php which shows the discount coupon deducted but when i click confirm order on that page to go on to my confirmation2.php the discount coupon line is not there. so the full order without the discount goes to the payment systems.

 

I have added the code from this mod to both the confirmation1 and confirmation2 php's.

 

I have looked at the differences between these two php's and below is the script in confirmation2 php which is not in confirmation1 php all the rest os the same. I see that confirmation2 php is calling in info but i don't know what to add to his extra bit so it calls in the discount coupon line.

Poss in the bit re order totals??

 

Any help will be muchly appreciated :D

 

This is the extra script in my confirmation2.php

<<?php
// load the before_process function from the payment modules


 $sql_data_array = array('customers_id' => $customer_id,
					  'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],
					  'customers_company' => $order->customer['company'],
					  'customers_street_address' => $order->customer['street_address'],
					  'customers_suburb' => $order->customer['suburb'],
					  'customers_city' => $order->customer['city'],
					  'customers_postcode' => $order->customer['postcode'],
					  'customers_state' => $order->customer['state'],
					  'customers_country' => $order->customer['country']['title'],
					  'customers_telephone' => $order->customer['telephone'],
					  'customers_email_address' => $order->customer['email_address'],
					  'customers_address_format_id' => $order->customer['format_id'],
					  'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],
					  'delivery_company' => $order->delivery['company'],
					  'delivery_street_address' => $order->delivery['street_address'],
					  'delivery_suburb' => $order->delivery['suburb'],
					  'delivery_city' => $order->delivery['city'],
					  'delivery_postcode' => $order->delivery['postcode'],
					  'delivery_state' => $order->delivery['state'],
					  'delivery_country' => $order->delivery['country']['title'],
					  'delivery_address_format_id' => $order->delivery['format_id'],
					  'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'],
					  'billing_company' => $order->billing['company'],
					  'billing_street_address' => $order->billing['street_address'],
					  'billing_suburb' => $order->billing['suburb'],
					  'billing_city' => $order->billing['city'],
					  'billing_postcode' => $order->billing['postcode'],
					  'billing_state' => $order->billing['state'],
					  'billing_country' => $order->billing['country']['title'],
					  'billing_address_format_id' => $order->billing['format_id'],
					  'payment_method' => $order->info['payment_method'],
					  'cc_type' => $order->info['cc_type'],
					  'cc_owner' => $order->info['cc_owner'],
					  'cc_number' => $order->info['cc_number'],
					  'cc_expires' => $order->info['cc_expires'],
					  'date_purchased' => 'now()',
					  'orders_status' => $order->info['order_status'],
					  'currency' => $order->info['currency'],
					  'currency_value' => $order->info['currency_value']);
 tep_db_perform(TABLE_ORDERS, $sql_data_array);
 $insert_id = tep_db_insert_id();
 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
$sql_data_array = array('orders_id' => $insert_id,
						'title' => $order_totals[$i]['title'],
						'text' => $order_totals[$i]['text'],
						'value' => $order_totals[$i]['value'],
						'class' => $order_totals[$i]['code'],
						'sort_order' => $order_totals[$i]['sort_order']);
tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
 }

 $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
 $sql_data_array = array('orders_id' => $insert_id,
					  'orders_status_id' => $order->info['order_status'],
					  'date_added' => 'now()',
					  'customer_notified' => $customer_notification,
					  'comments' => $order->info['comments']);
 tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

// initialized for the email confirmation
 $products_ordered = '';
 $subtotal = 0;
 $total_tax = 0;

 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
// Stock Update - Joao Correia
if (STOCK_LIMITED == 'true') {
  if (DOWNLOAD_ENABLED == 'true') {
	$stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename
						FROM " . TABLE_PRODUCTS . " p
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
						 ON p.products_id=pa.products_id
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
						 ON pa.products_attributes_id=pad.products_attributes_id
						WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
	$products_attributes = $order->products[$i]['attributes'];
	if (is_array($products_attributes)) {
	  $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
	}
	$stock_query = tep_db_query($stock_query_raw);
  } else {
	$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
  }
  if (tep_db_num_rows($stock_query) > 0) {
	$stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
	if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
	  $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
	} else {
	  $stock_left = $stock_values['products_quantity'];
	}
	tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
	if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
	  tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
	}
  }
}

// Update products_ordered (for bestsellers list)
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

$sql_data_array = array('orders_id' => $insert_id,
						'products_id' => tep_get_prid($order->products[$i]['id']),
						'products_model' => $order->products[$i]['model'],
						'products_name' => $order->products[$i]['name'],
						'products_price' => $order->products[$i]['price'],
						'final_price' => $order->products[$i]['final_price'],
						'products_tax' => $order->products[$i]['tax'],
						'products_quantity' => $order->products[$i]['qty']);
tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
$order_products_id = tep_db_insert_id();

//------insert customer choosen option to order--------
$attributes_exist = '0';
$products_ordered_attributes = '';
if (isset($order->products[$i]['attributes'])) {
  $attributes_exist = '1';
  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	if (DOWNLOAD_ENABLED == 'true') {
	  $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
						   from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
						   left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
							on pa.products_attributes_id=pad.products_attributes_id
						   where pa.products_id = '" . $order->products[$i]['id'] . "'
							and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'
							and pa.options_id = popt.products_options_id
							and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'
							and pa.options_values_id = poval.products_options_values_id
							and popt.language_id = '" . $languages_id . "'
							and poval.language_id = '" . $languages_id . "'";
	  $attributes = tep_db_query($attributes_query);
	} else {
	  $attributes = 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 = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
	}
	$attributes_values = tep_db_fetch_array($attributes);

	$sql_data_array = array('orders_id' => $insert_id,
							'orders_products_id' => $order_products_id,
							'products_options' => $attributes_values['products_options_name'],
							'products_options_values' => $order->products[$i]['attributes'][$j]['value'],
							'options_values_price' => $attributes_values['options_values_price'],
							'price_prefix' => $attributes_values['price_prefix']);
	tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

	if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
	  $sql_data_array = array('orders_id' => $insert_id,
							  'orders_products_id' => $order_products_id,
							  'orders_products_filename' => $attributes_values['products_attributes_filename'],
							  'download_maxdays' => $attributes_values['products_attributes_maxdays'],
							  'download_count' => $attributes_values['products_attributes_maxcount']);
	  tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
	}
	//clr 030714 changing to use values from $orders->products and adding call to tep_decode_specialchars()
	$products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . tep_decode_specialchars($order->products[$i]['attributes'][$j]['value']);
  //$products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];
  }
}
//------insert customer choosen option eof ----
$total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
$total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
$total_cost += $total_products_price;

$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
 }

// lets start with the email confirmation
 include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);

 $email_order = STORE_NAME . "\n" .
			 EMAIL_SEPARATOR . "\n" .
			 EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
			 EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" .
			 EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
 if ($order->info['comments']) {
$email_order .= tep_db_output($order->info['comments']) . "\n\n";
 }
 $email_order .= EMAIL_TEXT_PRODUCTS . "\n" .
			  EMAIL_SEPARATOR . "\n" .
			  $products_ordered .
			  EMAIL_SEPARATOR . "\n";

 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
$email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n";
 }

 if ($order->content_type != 'virtual') {
$email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" .
				EMAIL_SEPARATOR . "\n" .
				tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";
 }

 $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" .
			  EMAIL_SEPARATOR . "\n" .
			  tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n";
 if (is_object($$payment)) {
$email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" .
				EMAIL_SEPARATOR . "\n";
$payment_class = $$payment;
$email_order .= $payment_class->title . "\n\n";
if ($payment_class->email_footer) {
  $email_order .= $payment_class->email_footer . "\n\n";
}
 }
 tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

// send emails to other people
 if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
 }

// load the after_process function from the payment modules
 $payment_modules->after_process();

 $cart->reset(true);

// unregister session variables used during checkout
 tep_session_unregister('sendto');
 tep_session_unregister('billto');
 tep_session_unregister('shipping');
 tep_session_unregister('payment');
 tep_session_unregister('comments');

?>



<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="5" cellpadding="2">

Link to comment
Share on other sites

Yes, such fixes should be posted or uploaded as a new version since others may have the same problem.

 

Jack

 

since i made my own mod on a n SPPC oscommerce heavly modified, I'm posting only the hack on coupons_exclusions.php class that was the real issue. Infact the original code cannot deal php and js parameters due to a malformed variable names. Here it is how it can work with both JS function for the 2 mutliple selects and PHP POST.

this patch should work on every Discount Coupons contrib version.

 

bye bye

 

 

/---------------------------------------/

in admin/includes/classes/coupons_exclusions.php

Near line 140 select

from '.tep_draw_form

to </form>

 

and replace with the following

 

'.tep_draw_form( 'choose'.$this->type, FILENAME_DISCOUNT_COUPONS_EXCLUSIONS, 'cID='.$this->coupons_id.'&type='.$this->type, 'post', 'onsubmit="form_submission( document.getElementById([\'selected_'.$this->type.'[]\']) )"' ).'
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td align="center" class="main">'.HEADING_AVAILABLE.'</td>
		<td align="center"> </td>
		<td align="center" class="main">'.HEADING_SELECTED.'</td>
	</tr>
	<tr>
		<td rowspan="5" align="center">'.tep_draw_pull_down_menu('available_'.$this->type.'[]', $this->all_options, '', 'size="20" multiple="multiple" style="width: 300px" id="available_'.$this->type.'[]"').'</td>
		<td align="center"><input name="choose_all" type="button" id="choose_all" value="Choose All >" onclick="selectAll( document.getElementById([\'selected_'.$this->type.'[]\']), document.getElementById([\'available_'.$this->type.'[]\'])  )"></td>
		<td rowspan="5" align="center">'.tep_draw_pull_down_menu('selected_'.$this->type.'[]', $this->selected_options, '', 'size="20" multiple="multiple" style="width: 300px" id="selected_'.$this->type.'[]"').'</td>
	</tr>
	<tr>
		<td align="center"><input name="add" type="button" id="add" value="> >" onclick="updateSelect( document.getElementById([\'selected_'.$this->type.'[]\']), document.getElementById([\'available_'.$this->type.'[]\']) )"></td>
	</tr>
	<tr>
		<td align="center"><input name="subtract" type="button" id="subtract" value="< <" onclick="updateSelect( document.getElementById([\'available_'.$this->type.'[]\']), document.getElementById([\'selected_'.$this->type.'[]\']))"></td>
	</tr>
	<tr>
		<td align="center"><input name="remove_all" type="button" id="remove_all" value="< Remove All" onclick="selectAll( document.getElementById([\'available_'.$this->type.'[]\']), document.getElementById([\'selected_'.$this->type.'[]\']))"></td>
	</tr>
	<tr>
		<td align="center"><input name="action" type="submit" id="action" value="Save"> <input name="action" type="submit" id="action" value="Cancel"></td>
	</tr>

</table>
</form>

Link to comment
Share on other sites

Hi,

 

Thanks for your contribution. But after installing when I click on Discount Coupon there error appear

 

Fatal error: Cannot redeclare class currencies in /home/sherrlim/public_html/admin/includes/classes/currencies.php on line 16

 

 

Pls help,

Thanks

 

 

Hello,

I am getting the same error. Has anyone resolved this problem? I can't find any response to this post. I have an extensively modified site, and need some help urgently please. The site has gone live, and a discount offering has been negotiated but I can not get it to work!! (Sales team putting-cart-before-horse-cracks are well deserved) I am still new to PHP, so any help would be GREATLY appreciated...

 

I am using OSC v2.2rc2a. I only use one type of currency (GBP£) and one language (English). Some of the contribs I have installed: Quantity Discount, Pay Without Account, Stats_products_orders PDF Admin Invoice,

 

 

thanks to all,

 

Richard

 

www.faculty-one.com/

Edited by rselonke
Link to comment
Share on other sites

Hello,

I am getting the same error. Has anyone resolved this problem? I can't find any response to this post. I have an extensively modified site, and need some help urgently please. The site has gone live, and a discount offering has been negotiated but I can not get it to work!! (Sales team putting-cart-before-horse-cracks are well deserved) I am still new to PHP, so any help would be GREATLY appreciated...

 

I am using OSC v2.2rc2a. I only use one type of currency (GBP£) and one language (English). Some of the contribs I have installed: Quantity Discount, Pay Without Account, Stats_products_orders PDF Admin Invoice,

 

 

thanks to all,

 

Richard

 

www.faculty-one.com/

 

 

hello,

which version of discount coupon you have insalled?

Link to comment
Share on other sites

try to comment this line near 183

require(DIR_WS_CLASSES . 'currencies.php');

 

 

if it doesn't work you can try to replace the line with

require_once(DIR_WS_CLASSES . 'currencies.php');

Link to comment
Share on other sites

try to comment this line near 183

require(DIR_WS_CLASSES . 'currencies.php');

 

 

if it doesn't work you can try to replace the line with

require_once(DIR_WS_CLASSES . 'currencies.php');

 

 

THANK YOU SOOO MUCH!! Anyone having this problem, this is the solution.

 

First, I tried commenting out Line 183 require(DIR_WS_CLASSES . 'currencies.php');

IT WORKED!

 

Out of interest, I also tried replacing with require_once and

IT ALSO WORKED!

 

Thanks for all the help...

 

Rich

Link to comment
Share on other sites

Hi, using version 3.3.3 I have everything working fine EXCEPT the minimum order and minimum order type.

 

I have it currently set as a minimum order of 2, and the type is product qty. However, if someone orders just 1 they are getting the discount. I changed this to try the price total option with the same results. no matter what I put in these fields they do not effect the final $ amount.

 

Anyone have any ideas what I should look for to track this problem down?

 

Thanks!

Link to comment
Share on other sites

Hello all,

 

I have recently installed this contrib (with help from some of you forum members) but in addition, I also provide quantity discounts (http://addons.oscommerce.com/info/6751). Is there a way to disable other discounts when the Discount Code is used? I know it will exlude product Specials, is there a way to amend this to work?

 

thanks for any help...

 

richard

 

I am using OSC v2.2rc2a. I only use one type of currency (GBP£) and one language (English).

www.faculty-one.com/training/

Link to comment
Share on other sites

I have it currently set as a minimum order of 2, and the type is product qty. However, if someone orders just 1 they are getting the discount. I changed this to try the price total option with the same results. no matter what I put in these fields they do not effect the final $ amount.

 

yes i confirm the the minimum order quantity does not work. let me take the time to view the bug and will reply with the patch

Link to comment
Share on other sites

(http://addons.oscommerce.com/info/6751). Is there a way to disable other discounts when the Discount Code is used? I know it will exlude product

 

very nice OT module.

well this hack it's not so simple. one way to proceed could be to modify the order_total.php file in include/classes.

Find the method process in the file.

function process() {

$order_total_array = array();

if (is_array($this->modules)) {

reset($this->modules);

while (list(, $value) = each($this->modules)) {

$class = substr($value, 0, strrpos($value, '.'));

if ($GLOBALS[$class]->enabled) {

$GLOBALS[$class]->output = array();

$GLOBALS[$class]->process();

 

for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {

if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {

$order_total_array[] = array('code' => $GLOBALS[$class]->code,

'title' => $GLOBALS[$class]->output[$i]['title'],

'text' => $GLOBALS[$class]->output[$i]['text'],

'value' => $GLOBALS[$class]->output[$i]['value'],

'sort_order' => $GLOBALS[$class]->sort_order);

}

}

}

}

}

 

return $order_total_array;

}

before returning $order_total_array you have to chek if it contains both coupons and discount. If so you have to cut the quantity discount elemento from the array.

the same thing could be done on the output method in the order_total class. Maybe this could be a little better because you can use string function on before returning the output string.

 

bye bye

Link to comment
Share on other sites

Hi, I have SPPC installed and I installed OT DCC (great contrib!), however, it all works great, except for the totals page, it doesn't show the discount line, but it calculates everything properly. Just missing the coupon code line showing the discount.. Anyone have a fix for this??

 

I double checked that my code is correct in the order.php and checkout_confirmation.php, it all looks good.

Any help would be greatly appreciated,

 

Thanks,

Angie

Link to comment
Share on other sites

Hi, I have SPPC installed and I installed OT DCC (great contrib!), however, it all works great, except for the totals page, it doesn't show the discount line, but it calculates everything properly. Just missing the coupon code line showing the discount.. Anyone have a fix for this??

 

I double checked that my code is correct in the order.php and checkout_confirmation.php, it all looks good.

Any help would be greatly appreciated,

 

Thanks,

Angie

 

you should check in admin-> Modules->Order Totals

if one or more of the other modules have the same sort number of DCC. This could overwrite the DCC module in checkout_confirmation.php

Link to comment
Share on other sites

before returning $order_total_array you have to chek if it contains both coupons and discount. If so you have to cut the quantity discount element from the array.

the same thing could be done on the output method in the order_total class. Maybe this could be a little better because you can use string function on before returning the output string.

 

bye bye

 

I am still new to PHP, so apologies for being dense, i have no idea how to cut the quantity discount from the array. :blush:

 

I think if i use

if (in_array("ot_discount_coupon", $order_total_array)) {

 

it will tell me if a coupon has been used, but don't know how to exclude 'ot_quantity_discount'. can you point me in the right direction? I've looked through the PHP.net documentation referencing all ARRAY functions, but am still quite lost...

 

-edit-

Just thinking further ahead, for compatibility with other discounts, i should search the array for anything the reduces the order total value and exclude ALL except the discount_coupon - similar to excluding specials from the coupon, but in reverse... does that make sense?

 

 

thanks for any help,

 

rich

Edited by rselonke
Link to comment
Share on other sites

I think if i use

if (in_array("ot_discount_coupon", $order_total_array)) {

 

it will tell me if a coupon has been used, but don't know how to exclude 'ot_quantity_discount'. can you point me in the right direction? I've looked through the PHP.net documentation referencing all ARRAY functions, but am still quite lost...

 

yes, it should tell you if there is a discount coupon inside the order_total array

next you can

// destroy a single element of an array

unset($order_total_array['ot_discount_coupon']);

Link to comment
Share on other sites

you should check in admin-> Modules->Order Totals

if one or more of the other modules have the same sort number of DCC. This could overwrite the DCC module in checkout_confirmation.php

 

Thanks for the reply, yes they each have a unique sort number, I even tried giving it the last number to see if it would appear at the end, and nothing... It's odd because when I enable the Display discount total lines for each tax group, and other module features it doesn't change anything but the total at the bottom is calculated correctly, just not showing the Coupon line to tell people that it was applied...

Link to comment
Share on other sites

Thanks for the reply, yes they each have a unique sort number, I even tried giving it the last number to see if it would appear at the end, and nothing... It's odd because when I enable the Display discount total lines for each tax group, and other module features it doesn't change anything but the total at the bottom is calculated correctly, just not showing the Coupon line to tell people that it was applied...

sometimes you have to uninstall all the ot modules and reinstall them from the admin order totals section.

try this: unistall all the modules than try only to reinstall counpons

Link to comment
Share on other sites

sometimes you have to uninstall all the ot modules and reinstall them from the admin order totals section.

try this: unistall all the modules than try only to reinstall counpons

 

I have had that happen to me before with a different module.. I just tried reinstalling this module, and it's still the same... Thanks for the tip :)

Link to comment
Share on other sites

yes, it should tell you if there is a discount coupon inside the order_total array

next you can

// destroy a single element of an array

unset($order_total_array['ot_discount_coupon']);

 

OK, i have inserted the following bit of code, but is not skipping the ot_quantity_discount entry. maybe i have it in the wrong position in the structure - sry, i AM new to php :blush:

 

 
   function process() {
     $order_total_array = array();
     if (is_array($this->modules)) {
       reset($this->modules);
       while (list(, $value) = each($this->modules)) {
         $class = substr($value, 0, strrpos($value, '.'));
         if ($GLOBALS[$class]->enabled) {
           $GLOBALS[$class]->output = array();
           $GLOBALS[$class]->process();

           for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
             if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {
               $order_total_array[] = array('code' => $GLOBALS[$class]->code,
                                            'title' => $GLOBALS[$class]->output[$i]['title'],
                                            'text' => $GLOBALS[$class]->output[$i]['text'],
                                            'value' => $GLOBALS[$class]->output[$i]['value'],
                                            'sort_order' => $GLOBALS[$class]->sort_order);
             }
           }
         }
       }
     }
// NEED TO DETERMINE IF DICOUNT COUPON CODE IS ENTERED, IF SO, IGNORE OTHER MODULES
if (in_array('ot_discount_coupon', $order_total_array)) {
       unset($order_total_array['ot_quantity_discount']);
}
     return $order_total_array;
   }

   function output() {
     $output_string = '';

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...