evbeej Posted August 10, 2016 Posted August 10, 2016 I will give that a go.. i think im using very 3 3.4. there are some fixes on the addon page, so working my way through those at the moment. fingers crossed. Quote
evbeej Posted August 18, 2016 Posted August 18, 2016 @@Gyakutsuki Thank you, i have managed to get rid of that error now. But still cant seem to get this module to show the discount in the checkout_confirmation page. This site is quite heavily modified in places, so not sure what to look at next. Everything else to do with the discount is working fine; creating a discount code, editing the code, if a wrong one is entered it shows the error message... it just never actually adds it. I have even gone through to enter card payments to check if it was at least taking it off there, but it isnt. ( it is also not passing through the discount for paypal). So something must be breaking between checkout_payment and checkout_confirmation. If I go through with the purchase, it does link the discount coupon to the order in the discount_coupons_to_orders table, which is added at the checkout_process stage. I will just have to keep digging. Quote
♥Gyakutsuki Posted August 18, 2016 Posted August 18, 2016 Look if the session is correct in confirmation echo $_SESSION['coupon']; exit; I you don't see the session,you have a pb. See the page above, I explain in details this pb. Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
evbeej Posted August 22, 2016 Posted August 22, 2016 @@Gyakutsuki Thank you, I am not sure what you meant, sorry. Should i be putting: echo $_SESSION['coupon']; exit; on the page somewhere? if so - nothing came up. Could you link me to the solution you talked about, as cant see where you have mentioned it previously on the previous page. Sorry, i am probably being really dumb with this, but i am just really struggling with it! :blush: :( Quote
♥Gyakutsuki Posted August 22, 2016 Posted August 22, 2016 look this : http://www.oscommerce.com/forums/topic/213019-contribution-discount-coupon-codes/page-171 Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
evbeej Posted August 23, 2016 Posted August 23, 2016 @@Gyakutsuki Brilliant, thank you for this.. I have found a problem at the first stage, after doing function process() { $order_total_array = array(); if (is_array($this->modules)) { foreach($this->modules as $value) { $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 (osc_not_null($GLOBALS[$class]->output[$i]['title']) && osc_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); } } } } }var_dump($order_total_array);exit; return $order_total_array; } the result is array(4) { [0]=> array(5) { ["code"]=> string(11) "ot_subtotal" ["title"]=> string(10) "Sub-Total:" ["text"]=> string(6) "£1.14" ["value"]=> float(1.14) ["sort_order"]=> string(1) "1" } [1]=> array(5) { ["code"]=> string(11) "ot_shipping" ["title"]=> string(45) "UK Mainland (DPD Homecall 3 - 5 Day Service):" ["text"]=> string(6) "£3.65" ["value"]=> float(3.648) ["sort_order"]=> string(1) "3" } [2]=> array(5) { ["code"]=> string(6) "ot_tax" ["title"]=> string(11) "VAT Amount:" ["text"]=> string(6) "£0.80" ["value"]=> float(0.798) ["sort_order"]=> string(1) "4" } [3]=> array(5) { ["code"]=> string(8) "ot_total" ["title"]=> string(6) "Total:" ["text"]=> string(23) "£4.79" ["value"]=> float(4.788) ["sort_order"]=> string(1) "5" } } It isnt even reading the discount coupon at this point.. any ideas? Quote
evbeej Posted August 23, 2016 Posted August 23, 2016 (edited) EDIT: i edited the code to match the one above and it made no difference. -------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@Gyakutsuki sorry, actually reading the code compared to the one you posted, its actually different, dont know how much a difference that will make but here is the code i actually have 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); } } } } } var_dump($order_total_array); exit; return $order_total_array; } Edited August 23, 2016 by evbeej Quote
♥Gyakutsuki Posted August 23, 2016 Posted August 23, 2016 (edited) your problem is the coupon value. It does'nt sent I think. Edited August 23, 2016 by Gyakutsuki Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
♥Gyakutsuki Posted August 23, 2016 Posted August 23, 2016 (edited) could you look in order class if you have $_SESSION['coupon'] if yes write this var_dump($_SESSION['coupon']) exit; and test Edited August 23, 2016 by Gyakutsuki Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
evbeej Posted August 23, 2016 Posted August 23, 2016 @@Gyakutsuki Nope, doesnt look like i have that, and when i add in the var_dump on classes/order.php it breaks it! Do you want to see my order.php file? Quote
♥Gyakutsuki Posted August 23, 2016 Posted August 23, 2016 it breaks it, normal, you need to see an information about $_SESSION['coupon']. If you see you coupon, it's ok, if not, pb. try to reinstall de contribution with a software like beyond compare. It's important to the value else in checkout confirmation you won't see the information. Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
evbeej Posted August 23, 2016 Posted August 23, 2016 @@Gyakutsuki Hmmm.. ive re installed this about 4 times, and its always the same. never appears in confirmation. Following this module ive added the following bits of code to order.php: $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++) { //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 = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; $this->info['subtotal'] += $shown_price; } /************** $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; $this->info['subtotal'] += $shown_price; **************/ //end kgt - discount coupons //kgt - discount coupon if( is_object( $this->coupon ) ) { $this->info['total'] = $this->coupon->finalize_discount( $this->info ); } //end kgt - discount coupon Are you suggesting i have something else missing from this page? - sorry im not to good with the order total Quote
evbeej Posted August 23, 2016 Posted August 23, 2016 if i add the var_dump in the first lot of KGT code on that page : $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; //testing coupon issue var_dump($coupon); } //end kgt - discount coupons it appears with string(6) "erika2" at the top of the confirmation page... does that help? greasemonkey 1 Quote
♥Gyakutsuki Posted August 23, 2016 Posted August 23, 2016 it appears with string(6) "erika2" at the top of the confirmation page... does that help? Seems the value is created. Try to test in order_total directory, discount_coupon.php if you see the calcul of the coupon by a var_dump($this->output); If you don't see the coupon line or not the calcul, it seems the $coupon does'nt pass, and it's better to use $_SESSION. It can be a pb with php version. Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
evbeej Posted August 23, 2016 Posted August 23, 2016 @@Gyakutsuki Please forgive me if i have misunderstood but... i have added the var_dump to the following code in ot_discount_coupon.php: function process() { global $order, $currencies; if( is_object( $order->coupon ) ) { //if the order total lines for multiple tax groups should be displayed as one, add them all together if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_LINES == 'false' ) $discount_lines = array( array_sum( $order->coupon->applied_discount ) ); else $discount_lines = $order->coupon->applied_discount; if( is_array( $discount_lines ) ) foreach( $discount_lines as $tax_group => $discount ) { if( $discount > 0 ) { //add in the tax if needed: if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TAX == 'Display discount with discounted tax applied' && is_array( $order->coupon->discount_tax ) ) $discount += array_sum( $order->coupon->discount_tax ); //determine the display type (with or without the minus sign): $display_type = ( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TYPE == 'true' ? '-' : '' ); $text = $display_type . $currencies->format( $discount, true, $order->info['currency'], $order->info['currency_value'] ); //add debug text if debug is on: if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG == 'true' ) $text .= print_r( "\n\n<!-- Discount Coupons DEBUG\n".print_r( $order, true )."\nEnd Discount Coupons DEBUG-->\n\n", true ); $this->output[] = array( 'title' => $order->coupon->format_display( $tax_group ) . ':', 'text' => $text, 'value' => $display_type . $discount ); } } //determine if we need to display a second line to show tax no longer applied if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TAX == 'Display discounted tax in separate line' && is_array( $order->coupon->discount_tax ) ) { $discounted_tax = array_sum( $order->coupon->discount_tax ); $text = $display_type . $currencies->format( $discounted_tax, true, $order->info['currency'], $order->info['currency_value'] ); $this->output[] = array( 'title' => MODULE_ORDER_TOTAL_DISCOUNT_COUPON_TAX_NOT_APPLIED . ':', 'text' => $text, 'value' => $display_type . $discounted_tax ); } var_dump($this->output); } else $this->enabled = false; } This has added the following to the top of the confirmation: string(6) "erika2" array(0) { } :( Quote
♥Gyakutsuki Posted August 23, 2016 Posted August 23, 2016 (edited) Ok, if you don'tl tel me the files I don't search everytime. I think your problem become in my opinion on the transfert value, I have some problem with that and that's why you need to use $_SESSION['coupon']. Go back on the page I sent you above and try to follow the debug and test every time if you see all the values. checkout_payment discount class checkout confirmation order_total checkout process Edited August 23, 2016 by Gyakutsuki Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
evbeej Posted August 23, 2016 Posted August 23, 2016 @@Gyakutsuki Thank you, i will do that - i really appreciate your patience, and help. Quote
evbeej Posted August 24, 2016 Posted August 24, 2016 (edited) Following the link you send me Loic , i didnt get it working. However i have found something that might point to the issue. While checking at every point i have found that doing a var_dump here (in checkout_confirmation.php): <?php //order total code if (MODULE_ORDER_TOTAL_INSTALLED) { echo $order_total_modules->output(); } var_dump($order->coupon); ?> The following comes up: object(discount_coupon)#10 (5) { ["messages"]=> array(0) { } ["coupon"]=> array(10) { ["coupons_id"]=> string(6) "erika2" ["coupons_description"]=> string(4) "test" ["coupons_discount_amount"]=> string(4) "0.10" ["coupons_discount_type"]=> string(7) "percent" ["coupons_date_start"]=> NULL ["coupons_date_end"]=> NULL ["coupons_max_use"]=> string(2) "10" ["coupons_min_order"]=> string(6) "0.0000" ["coupons_min_order_type"]=> string(5) "price" ["coupons_number_available"]=> string(2) "10" } ["applied_discount"]=> array(1) { ["VAT Amount"]=> int(0) } ["cart_info"]=> array(3) { ["valid_products"]=> array(3) { ["count"]=> int(0) ["line_items"]=> int(0) ["total"]=> int(0) } ["total_products"]=> array(3) { ["count"]=> int(1) ["line_items"]=> int(1) ["total"]=> float(26.66) } ["exclusions"]=> array(3) { ["categories"]=> array(0) { } ["products"]=> array(1) { [0]=> int(686) } ["manufacturers"]=> array(0) { } } } ["discount_tax"]=> array(1) { ["VAT Amount"]=> int(0) } } It looks as though whenever i have an item in my cart, it adds it to the 'exclusions' list? Anyone have any ideas? E Edited August 24, 2016 by evbeej Quote
evbeej Posted August 24, 2016 Posted August 24, 2016 Sorted it!! i had exclude specials as true in the setting :thumbsup: :blush: Quote
evbeej Posted August 26, 2016 Posted August 26, 2016 (edited) :- new problem! I have it set up so that the customer gets free shipping if they spend over £30. I have 2 items in the shopping cart, which totals £33.48 I add a discount of 50% which takes the total to 16.74 which now pushes the purchase to below the £30 free shipping limit, so i get the error: Your calculated shipping charges have changed. I have seen a couple if people mention this on theirs, and my version of the module (3.34 plus bug fixes) seems to have all those fixes incorporated already. as far as i can see, this bit of code which is on classes/discount_coupon.php, is meant to sort this... static function is_recalc_shipping() { global $order, $language; //calculate the order total: $order_total = $order->info['total'] - $order->info['shipping_cost']; if( DISPLAY_PRICE_WITH_TAX != 'true' ) $order_total -= $order->info['tax']; //check if there is free shipping if( strtolower(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING) == 'true' ) { include( DIR_WS_LANGUAGES.$language.'/modules/order_total/ot_shipping.php' ); //if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit if( $order->info['shipping_method'] == FREE_SHIPPING_TITLE ) { //if free shipping is the selected shipping method if( $order_total < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER ) { //if the discount lowers the total below the free shipping limit return true; } } } //check if table rate shipping has changed if( strtolower(MODULE_SHIPPING_TABLE_STATUS) == 'true' ) { include( DIR_WS_LANGUAGES.$language.'/modules/shipping/table.php' ); if( substr($order->info['shipping_method'], 0, strlen(MODULE_SHIPPING_TABLE_TEXT_TITLE)) == MODULE_SHIPPING_TABLE_TEXT_TITLE && MODULE_SHIPPING_TABLE_MODE == 'price' ) { $table_cost = split( "[:,]", MODULE_SHIPPING_TABLE_COST ); for( $i = 0; $i < count( $table_cost ); $i += 2 ) { if( $order_total <= $table_cost[$i] ) { $shipping = $table_cost[$i+1]; break; } } if( $order->info['shipping_cost'] != $shipping ) { //if the discount lowers the total below the table rate return true; } } } return false; } But it just doesnt seem to be doing it.. any ideas anyone? E Edited August 26, 2016 by evbeej frankl 1 Quote
pete2007 Posted September 15, 2016 Posted September 15, 2016 Hello, I've installed this discount code module, but I am unable to add anymore customers to the customer exclusions list Does anymore know how this can be increased or if this an error? Thank you in advance. Quote
metaminas2015 Posted September 27, 2016 Posted September 27, 2016 Hi It's possible to add something on checkout_success to send me a mail when a specific discount code is used? For example: if ( $coupon['coupons_id'] == 'testcupon') { $to = 'user@host'; $subject = 'Notification of testcupon'; $message = 'Discount cupon $coupon['coupons_id'] was used by "firstname" "lastname" - total of orders: "total" - value from discount: "discount" '; $from = "From: Owner Store <owner@hostt>"; mail($to,$subject,$message,$from); } Quote
GlenPig Posted October 6, 2016 Posted October 6, 2016 Looking through this forum I too got the following error when trying to add excluded zones for a discount code... 1136 - Column count doesn't match value count at row 1 INSERT INTO discount_coupons_to_zones VALUES ( "POST5", 3 ) [TEP STOP] ...to get around it I manually added the zones into the discount_coupons_to_zones table via PHPMyAdmin - hopefully that helps other people having the same issue. Quote
vmn Posted January 6, 2017 Posted January 6, 2017 (edited) The insert should specify the columns to be inserted. I'm still trying to figure out how to do in admin/includes/classes/coupons_exclusions.php The code is a bit too generic. Edited January 6, 2017 by vmn Quote
vmn Posted January 6, 2017 Posted January 6, 2017 This is my dirty hack: //VMN2017.01.06var $type, $display_fields, $coupons_id, $table_name, $selected_options, $all_options; var $type, $inserted_columns, $display_fields, $coupons_id, $table_name, $selected_options, $all_options; function save( $selected_options = array() ) { tep_db_query( $sql = 'DELETE FROM '.$this->table_name.' WHERE coupons_id="'.$this->coupons_id.'"' ); //VMN2017.01.06 start $inserted_columns = ''; if ($this->type === 'zones') { $inserted_columns = ' (coupons_id, geo_zone_id)'; } //VMN2017.01.06 end if( is_array( $selected_options ) && count( $selected_options ) > 0 ) { foreach( $selected_options as $ids ) { //VMN2017.06.1tep_db_query( $sql = 'INSERT INTO '.$this->table_name.' VALUES ( "'.$this->coupons_id.'", '.(int)$ids.' )' ); tep_db_query( $sql = 'INSERT INTO '.$this->table_name. $inserted_columns . ' VALUES ( "'.$this->coupons_id.'", '.(int)$ids.' )' ); } } else return false; } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.