kgt Posted October 3, 2006 Author Share Posted October 3, 2006 Hi Kristen you were right I had missed adding the first new element of code - this i have now done but get this error Parse error: syntax error, unexpected T_IF, expecting ')' in /home/sherpas1/public_html/catalog/includes/classes/order.php on line 168 I have looked through the other amendments but cannot see where I might have gone wrong. Line 162-168: 'tax_groups' => array(), //kgt - discount coupons 'coupon' => (isset($GLOBALS['coupon']) ? $GLOBALS['coupon'] : ''), 'applied_discount' => array(), //end kgt - discount coupons 'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : '')); if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) { When you insert code with comments, you need to be sure that existing code does not appear on the same line. In this block, you have left the last line of the discount codes comment, "//end kgt - discount coupons" on the same line as existing code, "'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : ''));". The existing code must be on it's own line, since by adding a comment before it on the same line, you have effectively commented out that code. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
sutherland Posted October 3, 2006 Share Posted October 3, 2006 Line 162-168: 'tax_groups' => array(), //kgt - discount coupons 'coupon' => (isset($GLOBALS['coupon']) ? $GLOBALS['coupon'] : ''), 'applied_discount' => array(), //end kgt - discount coupons 'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : '')); if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) { When you insert code with comments, you need to be sure that existing code does not appear on the same line. In this block, you have left the last line of the discount codes comment, "//end kgt - discount coupons" on the same line as existing code, "'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : ''));". The existing code must be on it's own line, since by adding a comment before it on the same line, you have effectively commented out that code. Hi Kristen Thanks for all your help and your patience - that has done the trick - several test purchases have all gone through smoothly. Excellent J Quote Link to comment Share on other sites More sharing options...
Guest Posted October 3, 2006 Share Posted October 3, 2006 just a suggestion on future releases: perhaps you could include a function that allows you to add products to a "non-discountable" list. reason being is that some items on my site have less than a 10% margin, and if i randomly give out 10% discounts to ppl, i'd actually be losing money... Quote Link to comment Share on other sites More sharing options...
rayge Posted October 3, 2006 Share Posted October 3, 2006 I have a customer that in some instances the coupon code will make the checkout amount $0 This is expected and wanted behavior. The problem is a couple of things. When the user puts in the coupon code the will end up with a $0 amount they still have to enter a CC# (thats not the BIG issue) THen when the user clicks to complete the process it comes back with a CC error. Im not sure what do to to handle this. I really need some help on this one. :( Quote Link to comment Share on other sites More sharing options...
rayge Posted October 3, 2006 Share Posted October 3, 2006 OK heres a theory on how i might get around it but may still need some help on it. IF i can move the coupon entry piece to the delivery page OR make it its own step in the checkout process. then if the total amount = 0 then i could make it SKIP the paypamt page alltogether which would solve my problem. this could also be a perm. addition to the contrib for later users because, you never know what people need. THanks for any help. Quote Link to comment Share on other sites More sharing options...
animatco Posted October 3, 2006 Share Posted October 3, 2006 These order totals don't add up at all! Did you upgrade to the latest version or did you install it from scratch? If you upgraded, from which version did you upgrade? Double check that you've made the correct changes to includes/classes/order.php, especially from around line 252 to the end of the file. I installed from scratch from the latest version. I check the order.php file now. Quote Link to comment Share on other sites More sharing options...
ken.yong Posted October 3, 2006 Share Posted October 3, 2006 Hi, I have a question on moving the input box of coupon code from checkout_payment.php to checkout_shipping.php. The reason is I have PayPal Express Checkout and it will skip checkout_payment.php and go straight to the order_confirmation.php. I have tried moving the coupon input box code to checkout_shipping.php but when I input a discount code in there it's not picking up at all. It seems the input box only works on the checkout_payment.php page. May I know is there a way to move the input coupon code box from checkout_payment.php to checkout_shipping.php? Are there any files that I need to edit as well? Thanks a lot! Quote Link to comment Share on other sites More sharing options...
rayge Posted October 3, 2006 Share Posted October 3, 2006 (edited) I moved the code from the payment page to the shipping page then used the code from the following contrib on hte payment page. http://www.oscommerce.com/community/contri...h,skip+checkout Looks like it will do the trick. I will keep you all posted. Edited October 3, 2006 by rayge Quote Link to comment Share on other sites More sharing options...
ken.yong Posted October 4, 2006 Share Posted October 4, 2006 Thank you very much! I should have stated in my earlier post that there are 2 scenarios: Scenario 1: When a customer picks PayPal Express Checkout, my original code will skip checkout_payment.php automatically since the customer has already chosen PayPal as his/her payment option. That's why I need to move the input for discount code to the checkout_shipping.php or else the customer has no place to put in the code. PayPal Express Checkout has this strange requirement that I need to put the Express Checkout option before showing checkout_shipping.php. This is how it is structured and I cannot change it, unfortunately. Scenario 2: When a customer wants to pay by "cash on delivery" or other options, my original code needs checkout_payment.php to show up since this is where the customer picks his/her payment options. Both scenarios will need to show checkout_shipping.php. Therefore, if I can move the input for discount code up one page to checkout_shipping.php, it will be great. Thanks again for any help! Quote Link to comment Share on other sites More sharing options...
kgt Posted October 4, 2006 Author Share Posted October 4, 2006 OK heres a theory on how i might get around it but may still need some help on it.IF i can move the coupon entry piece to the delivery page OR make it its own step in the checkout process. then if the total amount = 0 then i could make it SKIP the paypamt page alltogether which would solve my problem. this could also be a perm. addition to the contrib for later users because, you never know what people need. THanks for any help. This was originally written with the code box on the shipping page, but was moved to payment since some people may have virtual products. There's absolutely no reason why the coupon box can't be on the shipping page. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted October 4, 2006 Author Share Posted October 4, 2006 Hi, I have a question on moving the input box of coupon code from checkout_payment.php to checkout_shipping.php. The reason is I have PayPal Express Checkout and it will skip checkout_payment.php and go straight to the order_confirmation.php. I have tried moving the coupon input box code to checkout_shipping.php but when I input a discount code in there it's not picking up at all. It seems the input box only works on the checkout_payment.php page. May I know is there a way to move the input coupon code box from checkout_payment.php to checkout_shipping.php? Are there any files that I need to edit as well? Thanks a lot! For every box in the checkout, there's code that must process it. You can't just move a box and expect it to work. The code that processes the coupon box is in checkout_confirmation.php. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
ken.yong Posted October 4, 2006 Share Posted October 4, 2006 For every box in the checkout, there's code that must process it. You can't just move a box and expect it to work. The code that processes the coupon box is in checkout_confirmation.php. Thank you for your reply! I have very limited knowledge on php and I switched the additional codes from Discount Coupon Codes around to no avail. It will be greatly appreciated if you can show me where I should put the codes in checkout_confirmation.php if I want the code to process the input code from checkout_shipping.php. I have downloaded the very first version of this contribution to see how the input code got processed under checkout_shipping.php, but when I read the instructions the input code box is on the checkout_payment.php page instead of checkout_shipping.php page. Many thanks! Quote Link to comment Share on other sites More sharing options...
rayge Posted October 4, 2006 Share Posted October 4, 2006 kgt - What is considered a virtual Product? The client i am doing this for is useing the cart for Online based learning products. Thanks Quote Link to comment Share on other sites More sharing options...
kgt Posted October 4, 2006 Author Share Posted October 4, 2006 Thank you for your reply! I have very limited knowledge on php and I switched the additional codes from Discount Coupon Codes around to no avail. It will be greatly appreciated if you can show me where I should put the codes in checkout_confirmation.php if I want the code to process the input code from checkout_shipping.php. I have downloaded the very first version of this contribution to see how the input code got processed under checkout_shipping.php, but when I read the instructions the input code box is on the checkout_payment.php page instead of checkout_shipping.php page. Many thanks! The first version on the contributions site wasn't the first version of this code. PM me or email with with your email address and I will send it to you. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted October 4, 2006 Author Share Posted October 4, 2006 kgt - What is considered a virtual Product?The client i am doing this for is useing the cart for Online based learning products. Thanks This is what I am talking about: http://www.oscommerce.info/kb/osCommerce/A...nfiguration/162 If your customers order only downloadable products (virtual - there's no real physical product to be handled or shipped) then the shipping page is by default skipped in the checkout. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
ken.yong Posted October 4, 2006 Share Posted October 4, 2006 The first version on the contributions site wasn't the first version of this code. PM me or email with with your email address and I will send it to you. Thanks a lot! I have already PM you with my email address. Please let me know if you do not receive it. Quote Link to comment Share on other sites More sharing options...
rayge Posted October 4, 2006 Share Posted October 4, 2006 (edited) This is what I am talking about: http://www.oscommerce.info/kb/osCommerce/A...nfiguration/162 If your customers order only downloadable products (virtual - there's no real physical product to be handled or shipped) then the shipping page is by default skipped in the checkout. then I would need a coupon PAGE all in itself. say before the shipping page.. Then I need to get the total amount before the next page is displayed. For some reason im not getting it passed.. It looks like the way it works right now is that you are Posting from the payment page to the confirm page with the coupon code. Edited October 4, 2006 by rayge Quote Link to comment Share on other sites More sharing options...
kgt Posted October 4, 2006 Author Share Posted October 4, 2006 then I would need a coupon PAGE all in itself.say before the shipping page.. Then I need to get the total amount before the next page is displayed. For some reason im not getting it passed.. It looks like the way it works right now is that you are Posting from the payment page to the confirm page with the coupon code. On the payment page, you can make it work the way CCGV does. Next to the coupon box, have a 'Redeem Coupon' button that will go ahead and post checkout_payment.php. You'd probably need to use the onclick event for the button to bypass the javascript checks for the payment module. In checkout_confirmation.php, process the coupon and then check the order total. If order_total > 0, redirect back to checkout_payment.php. If order_total = 0, then display the confirmation screen. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
rayge Posted October 4, 2006 Share Posted October 4, 2006 When i simply tested it without the checkform JS it still comes back to the payment page.. Im assuming its checking the CC in some fashon on the COnfirm page. Quote Link to comment Share on other sites More sharing options...
kgt Posted October 4, 2006 Author Share Posted October 4, 2006 When i simply tested it without the checkform JS it still comes back to the payment page.. Im assuming its checking the CC in some fashon on the COnfirm page. It could be getting redirected because there is no selected payment module. If the CC is the selected payment module, then yes, there will be validation performed in checkout_confirmation.php (actually performed in the payment module you're using). So you need to make sure your payment module doesn't perform validation if the order total is zero. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
rayge Posted October 4, 2006 Share Posted October 4, 2006 (edited) It could be getting redirected because there is no selected payment module. If the CC is the selected payment module, then yes, there will be validation performed in checkout_confirmation.php (actually performed in the payment module you're using). So you need to make sure your payment module doesn't perform validation if the order total is zero. Actually its getting redirected because it is defaulting to the detected payment method.. even if i set an item to $0 and have it skip shipping AND payment pages Then comment out the code on the confirm page that redirects them to the payment page related to payment validation, it still shows the authorize.net as the payment method.. therefore it still trys to process through authorize.net Any other ideas? Edited October 4, 2006 by rayge Quote Link to comment Share on other sites More sharing options...
ken.yong Posted October 4, 2006 Share Posted October 4, 2006 The first version on the contributions site wasn't the first version of this code. PM me or email with with your email address and I will send it to you. Thanks a lot! Kristen. I got the 2 files and followed your instructions in the email by taking out the codes in checkout_confirmation.php and added relevant codes in checkout_shipping.php. Now checkout_shipping.php recognizes bad codes and gives relevant errors. The only thing that is still not going through is the discount itself cannot be passed to the ultimate total on the checkout_confirmation.php page, i.e. even thought I punched in the correct code, there was no discount applied to the final total. Is there anything else I need to check? Many thanks again! Quote Link to comment Share on other sites More sharing options...
kgt Posted October 4, 2006 Author Share Posted October 4, 2006 Actually its getting redirected because it is defaulting to the detected payment method.. even if i set an item to $0 and have it skip shipping AND payment pages Then comment out the code on the confirm page that redirects them to the payment page related to payment validation, it still shows the authorize.net as the payment method.. therefore it still trys to process through authorize.net That's why I think you need to modify the payment module to NOT process when the order total is zero. Another option may be to create a sort of "dummy" payment module (similar to the COD payment module). The COD payment module doesn't really do anything - it's a placeholder for a transaction that will occur after the order is submitted. In checkout_confirmation.php, if the order total is zero, make the dummy payment module the payment method. Looking at the code in checkout_confirmation, I think it's doable. The payment object must be assigned before the order object, but you wouldn't know that you need to reassign the payment object to the dummy module until the order object (that contains the order total) is assigned. Also, the coupon code must be performed using the order object before you'll know the order total is zero. You may be able to do something like this: // load the selected payment module require(DIR_WS_CLASSES . 'payment.php'); $payment_modules = new payment($payment); require(DIR_WS_CLASSES . 'order.php'); $order = new order; //kgt order total check if( $order->info['total'] == 0 ) { //we need to reassign the payment module and recreate the objects $payment_modules = new payment('cod'); //recreate the payment module $order->info['payment_method'] = 'cod'; //reset the order payment method } //end kgt order total check $payment_modules->update_status(); if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL')); } if (is_array($payment_modules->modules)) { $payment_modules->pre_confirmation_check(); } As long as you're not using the COD module, you should be fine just editing it: 1. Change includes/languages/english/modules/payment/cod.php to match the verbiage you want. 2. Change the selection() function in includes/modules/payment/cod.php to return false (so it doesn't display as a payment option on checkout_payment.php but it's still recognized as an installed payment module): function selection() { return false } 3. Install the COD module and give it a shot. Footnote: I have no idea if any of this will actually work. ;) Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
lotusgirl Posted October 5, 2006 Share Posted October 5, 2006 Does this have the capability to offer free shipping with a purchase of a certain $ amount? I am needing to accept vouchers from some customers and offer free shipping to others without overloading the site with too many contributions. Thanks! Quote Link to comment Share on other sites More sharing options...
animatco Posted October 5, 2006 Share Posted October 5, 2006 KQT, did you have a chance to look at the email I sent the other night. Any suggestions. Thank you, Steve Quote Link to comment Share on other sites More sharing options...
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.