Dan Cole Posted May 1, 2016 Posted May 1, 2016 @Dan Cole No, I tried but it doesn't work, no search more. @@Gyakutsuki Loic...if you are using the Modular Shopping Cart and would like to try this again I've worked up a module for it based on the excellent work done by Lambros @@Tsimi . It's a bit crude yet but seems to work okay. At this point I haven't added your fix and still have work to do to clean it up but if your interested let me know. Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 2, 2016 Posted May 2, 2016 @Dan Cole is it possible to display your work ? I'm developping something but not yet finish. Good news I am able to display the discount amount without customer session Bad news : the total amount is not calculate. Below an example on the code in execute function. if (isset($_POST['coupon'])) { //verifier intégrité coupon if (!isset($_SESSION['coupon'])) { $_SESSION['coupon'] = HTML::sanitize($_POST['coupon']); } //this needs to be set before the order object is created, but we must process it after //this needs to be set before the order object is created, but we must process it after // $coupon = osc_db_prepare_input($_POST['coupon']); if (isset($_SESSION['coupon'])) { $coupon = ''; if (tep_not_null($_SESSION['coupon'])) { $_SESSION['coupon'] = tep_db_prepare_input($_SESSION['coupon']); } } require_once(DIR_WS_CLASSES . 'order.php'); $order = new order; // discount coupons if (isset( $_SESSION['coupon']) && is_object($order->coupon) ) { $order->coupon->verify_code(); // erreur quand le nbr de coupon permis = 0 et debug = false } $form = tep_draw_form('coupon', osc_href_link('sopping_cart.php', '', 'SSL'), 'post', 'id ="coupon"onsubmit="return check_form();"', true); $endform = '</form>'; $coupon = tep_draw_input_field('coupon', '', 'id="inputCoupon" class="input-sm" placeholder="' . ENTRY_DISCOUNT_COUPON . '"' );; $button_coupon = tep_draw_button(IMAGE_BUTTON_CONTINUE, null, null, 'secondary', null, 'sm'); if (MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true') { // call template with $form . $coupon . $button_coupon . $endform } } } Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 2, 2016 Posted May 2, 2016 @@Gyakutsuki I have that working too ie without customer logging in but I have the same problem with the order total...when the customer logins in the total is correct but when they are not...it shows the discount but doesn't remove it from the total. Are you using the new shopping_cart modules? Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 2, 2016 Posted May 2, 2016 try to insert unset($_SESSION['coupon']); just a litlle improve if it can help you (HTML::sanitize change by good osc 2.3.x synthax) //verifier intégrité coupon if (!isset($_SESSION['coupon'])) { $_SESSION['coupon'] = HTML::sanitize($_POST['coupon']); } //this needs to be set before the order object is created, but we must process it after if (isset($_SESSION['coupon'])) { if (osc_not_null($_SESSION['coupon'])) { $_SESSION['coupon'] = HTML::sanitize($_SESSION['coupon']); } else { unset($_SESSION['coupon']); } } else { unset($_SESSION['coupon']); } Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 2, 2016 Posted May 2, 2016 @@Gyakutsuki Loic...not sure I understand....did that correct the order total? Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 2, 2016 Posted May 2, 2016 @Dan Cole no inside coupon discount Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 2, 2016 Posted May 2, 2016 @@Gyakutsuki Loic...here is the code I'm working with...my form is inside the module. Try not to laugh to hard....I know just enough about coding to be dangerous.... require('includes/application_top.php'); if (!tep_session_is_registered('coupon')) tep_session_register('coupon'); //this needs to be set before the order object is created, but we must process it after $coupon = tep_db_prepare_input($HTTP_POST_VARS['coupon']); if (tep_not_null($coupon)) { include(DIR_WS_CLASSES . 'order.php'); $order = new order; if( is_object( $order->coupon ) ) { //verify coupon $order->coupon->verify_code(); } if( (!$order->coupon->is_errors()) && is_object( $order->coupon )) { //if we have passed all tests (no error message) $messageStack->add_session('product_action', ENTRY_DISCOUNT_COUPON_SUCCESS, 'success'); }else{ $messageStack->add_session('product_action', implode( ' ', $order->coupon->get_messages() ), 'warning'); } } if (!tep_not_null($coupon)) $messageStack->add_session('product_action', ENTRY_DISCOUNT_COUPON_NO_ENTRY, 'warning'); tep_redirect(tep_href_link('shopping_cart.php', 'SSL' ) ); With the exception of the order_total issue when not logged in....it does seem to work well. Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 2, 2016 Posted May 2, 2016 Do you tried with different configuration taxe, no tax, above sub total, after sub total, after total ? Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 2, 2016 Posted May 2, 2016 No I didn't...it works fine when you are logged in so I figured the sort order stuff is okay...the only problem is when you're not logged in and in that case it doesn't seem to update the totals to recognize the coupon. I'll have a look at the order total class and see if I can figure it out when I get a chance. Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 2, 2016 Posted May 2, 2016 @Dan Cole A first way, but not tested in deep with all options after this in ot_discount.php $this->output[] = array('title' => $OSCOM_Order->coupon->format_display($tax_group) . ':', 'text' => $text, 'value' => $display_type . $discount ); add $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; $OSCOM_Order->info['subtotal'] -= $discount; in other case, it's possible to add also for conflict problem with checkout_confirmation.php if (MODULE_SHOPPING_CART_COUPON_DISCOUNT_CONTENT_WIDTH == 'true'&& $PHP_SEL="shopping_cart.php) { $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; $OSCOM_Order->info['subtotal'] -= $discount; } Let me know if it's first idea works; Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
♥Gyakutsuki Posted May 3, 2016 Posted May 3, 2016 Seem to work in different configuration with the module. No work with me if I insertt a limited price (pb), limit coupon (normal), number available, categories, products, manufacturers error on coupon name Could you test on your part Tk Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 3, 2016 Posted May 3, 2016 @@Gyakutsuki Loic...just added your code to ot_discount_coupon.php as follows: //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 ); } // added at the suggestion of Loic $order->info['total'] = $order->info['total'] - $discount; $order->info['subtotal'] -= $discount; } else $this->enabled = false; When I do that I get this when I'm logged in.... and when NOT logged in I get this.... I lose the tax and shipping but you've given me something to think about. I've not tried it with different coupon types yet. Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 3, 2016 Posted May 3, 2016 (edited) I don't text with canada tax, tomorrow but work with normal tax. include this adapted at your case if (MODULE_SHOPPING_CART_COUPON_DISCOUNT_CONTENT_WIDTH == 'true'&& $PHP_SEL="shopping_cart.php) { $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; $OSCOM_Order->info['subtotal'] -= $discount; } Edited May 3, 2016 by Gyakutsuki Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 3, 2016 Posted May 3, 2016 I don't text with canada tax, tomorrow but work with normal tax. include this adapted at your case if (MODULE_SHOPPING_CART_COUPON_DISCOUNT_CONTENT_WIDTH == 'true'&& $PHP_SEL="shopping_cart.php) { $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; $OSCOM_Order->info['subtotal'] -= $discount; } You lost me with this piece...where is it going? Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
Dan Cole Posted May 3, 2016 Posted May 3, 2016 Loic I played around with this a bit more and it looks like this works... // added at the suggestion of Loic $order->info['total'] = $order->info['total'] - $discount; $order->info['subtotal'] -= $discount; when there is no user logged in with the exception of the tax....it seems to calculate the tax without taking the discount into consideration. The other problem with it is that it duplicates the discount when a user is logged in....so we just need a condition to bypass your code when a user is logged in and sort out the tax issue when the user isn't. I'm going to check now to see if there are issues when I get to the checkout confirmation page. I'll post more once I do that. Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 3, 2016 Posted May 3, 2016 (edited) I also have a problem with the taxes, it diseapear ! Step by step This element does'nt allow in checkout_confirmation to use this code (below) This code go in ot_discount_coupon.php $PHP_SEL = $PHP_SELF $this->output[] = array('title' => $OSCOM_Order->coupon->format_display($tax_group) . ':', 'text' => $text, 'value' => $display_type . $discount ); if (MODULE_SHOPPING_CART_COUPON_DISCOUNT_STATUS == 'true' && $PHP_SELF == 'shopping_cart.php') { $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; $OSCOM_Order->info['subtotal'] -= $discount; } Edited May 3, 2016 by Gyakutsuki Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 3, 2016 Posted May 3, 2016 This element does'nt allow in checkout_confirmation to use this code (below) It doesn't seem to be an issue for me....I get the same result in checkout_confirmation as I get on the shopping_cart page. So in summary....I think I just need to sort out the tax issue and then bypass that piece you added when the user is logged in. Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
Dan Cole Posted May 3, 2016 Posted May 3, 2016 (edited) @@Gyakutsuki Loic I wrapped your routine in this if statement and it seems to have sorted out the duplication issue... // added at the suggestion of Loic if ( !tep_session_is_registered('customer_id') ) { $order->info['total'] = $order->info['total'] - $discount; $order->info['subtotal'] -= $discount; } Now I just need to get the tax to calculate on the subtotal instead of the total when the user is not logged in but for now I'm off to bed. Dan Edited May 3, 2016 by Dan Cole Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 3, 2016 Posted May 3, 2016 yes it's another solution and better idea Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
♥Gyakutsuki Posted May 3, 2016 Posted May 3, 2016 @@Dan Cole How many clic do you need to see the result. For me it's weird : 3 clics to see the discount (good coupon) 2 clics after to delete the discount (bas coupon) Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 3, 2016 Posted May 3, 2016 @@Gyakutsuki Loic....on the shopping cart page....right away....I enter the code and hit apply and it refreshes the page with the updated info....the only problem I'm having is with the tax when not logged in....in my shopping cart order total module I can pick up the tax rate but can't seem to pick up the discount amount...I can see the discount amount in the order object but I'm not sure how to access it. If you know how I'd be interested in learning that...if I can get that I think I can calculate the tax and remove it from the tax amount/rate that is displayed to users not logged in. Here is my order Object.... order Object ( [info] => Array ( [total] => 419.62 [currency] => CAD [currency_value] => 1.00000000 [subtotal] => 408.74 [shipping_method] => (Canada Post Expedited) [shipping_cost] => 10.88 ) [totals] => Array ( ) [products] => Array ( [0] => Array ( [qty] => 1 [name] => Laguna Mechanical/Biological Filter Pad [Coarse] [model] => PDFM-PT1775 [tax] => 0 [tax_description] => Unknown tax rate [price] => 75.2990 [final_price] => 75.299 [weight] => 0.00 [id] => 6460 ) [1] => Array ( [qty] => 1 [name] => ClearGuard Pond Filter 2700 w/9w UV [model] => PDFI-05615 [tax] => 0 [tax_description] => Unknown tax rate [price] => 333.4380 [final_price] => 333.438 [weight] => 25.00 [id] => 7300 ) ) [customer] => Array ( [firstname] => [lastname] => [company] => [street_address] => [suburb] => [city] => [postcode] => [state] => [zone_id] => [country] => Array ( [id] => [title] => [iso_code_2] => [iso_code_3] => ) [format_id] => [telephone] => [email_address] => ) [delivery] => Array ( [postcode] => [country] => Array ( [id] => 38 [title] => Canada [iso_code_2] => CA [iso_code_3] => CAN ) [country_id] => 38 [format_id] => 2 [zone_id] => 74 ) [content_type] => physical [billing] => Array ( [firstname] => [lastname] => [company] => [street_address] => [suburb] => [city] => [postcode] => [state] => [zone_id] => [country] => Array ( [id] => [title] => [iso_code_2] => [iso_code_3] => ) [country_id] => [format_id] => ) [coupon] => discount_coupon Object ( [messages] => Array ( ) [coupon] => Array ( [coupons_id] => ANNIVERSARY [coupons_description] => Anniversary Program [coupons_discount_amount] => 0.10 [coupons_discount_type] => percent [coupons_date_start] => 2012-02-01 00:00:00 [coupons_date_end] => [coupons_max_use] => 0 [coupons_min_order] => 0.0000 [coupons_min_order_type] => price [coupons_number_available] => 0 ) [applied_discount] => Array ( [Unknown tax rate] => 40.8737 ) [cart_info] => Array ( [valid_products] => Array ( [count] => 2 [line_items] => 2 [total] => 408.737 ) [total_products] => Array ( [count] => 2 [line_items] => 2 [total] => 408.737 ) [exclusions] => Array ( [categories] => Array ( ) [products] => Array ( ) [manufacturers] => Array ( ) ) ) [discount_tax] => Array ( [Unknown tax rate] => 0 ) ) ) I'm trying to pick up the 40.8737....the discount amount shown here... [applied_discount] => Array ( [Unknown tax rate] => 40.8737 ) Any idea....or can it get to it some where else? Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 3, 2016 Posted May 3, 2016 look the order_total in the module shopping cart, you have the first way. Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 3, 2016 Posted May 3, 2016 @@Gyakutsuki look the order_total in the module shopping cart, you have the first way. Sorry Loic...I'm not following you....can you lead me by the nose? Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
♥Gyakutsuki Posted May 3, 2016 Posted May 3, 2016 the code included in order total calcul (module) $products = $OSCOM_ShoppingCart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $products_tax = Tax::getTaxRate($products[$i]['tax_class_id'], $OSCOM_Order->delivery['country_id'], $OSCOM_Order->delivery['zone_id']); $products_tax_description = Tax::getTaxRateDescription($products[$i]['tax_class_id'], $OSCOM_Order->delivery['country_id'], $OSCOM_Order->delivery['zone_id']); if ( DISPLAY_PRICE_WITH_TAX == 'true' ) { //Modified by Strider 42 to correct the tax calculation when a customer is not logged in $tax_val = (($products[$i]['final_price']/100)*$products_tax)*$products[$i]['quantity']; } else { $tax_val = (($products[$i]['final_price']*$products_tax)/100)*$products[$i]['quantity']; } if ( !empty($OSCOM_Order->info['tax']) ) { $OSCOM_Order->info['tax'] += $tax_val; } else { $OSCOM_Order->info['tax'] = $tax_val; } if (!empty($OSCOM_Order->info['tax_groups']) ) { $OSCOM_Order->info['tax_groups']['' . $products_tax_description . ''] += $tax_val; } else { $OSCOM_Order->info['tax_groups']['' . $products_tax_description . ''] = $tax_val; } // Modified by Strider 42 to correct the order total figure when shop displays prices with tax if ( DISPLAY_PRICE_WITH_TAX == 'true' ) { $OSCOM_Order->info['total']; } else { $OSCOM_Order->info['total'] += $tax_val; } Quote Regards ----------------------------------------- Loïc Contact me by skype for business Contact me @gyakutsuki for an answer on the forum
Dan Cole Posted May 3, 2016 Posted May 3, 2016 @@Gyakutsuki Loic... My module looks similar but it doesn't seem to access the actual discount coupon amount....or at least I don't see that in the above? Dan Quote Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
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.