Jack_mcs Posted June 16, 2020 Author Share Posted June 16, 2020 (edited) A new version has been uploaded with these changes: Changed the database installer to remove commands not available in all mysql versions. Changed code for the welcome discount code to take multiple coupons due to languages in the account. Fixed a coding mistake in the redeem code. Fixed a problem where Free Shipping coupons would be convereted to non-Free Shipping. Created a Phoenix version and tested with 1.0.7.3. Pro Version: Ability to automatically send coupon code to customers that place an order to increase re-orders. Edited June 16, 2020 by Jack_mcs domiosc, Omar_one and valquiria23 2 1 Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
Jack_mcs Posted July 3, 2020 Author Share Posted July 3, 2020 A new version has been uploaded with these changes: Added an option to control the number of coupons that show on the coupon page in admin. Added code to delete multiple coupons at once. Changed the heading sections of the coupon admin for a better appearance for the Phoenix version. Changed the code to return the correctly formatted page entry for the coupon box on the shop side for the CE version. Corrected the link to the support thread. Corrected coding mistake for the Thank You success module for the CE version. Corrected coding mistake in the order total modules. Removed the need to alter the pages module by adding the account module for the CE version. Removed definitions in the CE version. Pro Version: Changed code for the automatic coupon code to store the customers name and email address. valquiria23 1 Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
aaymont Posted October 7, 2020 Share Posted October 7, 2020 (edited) I am on OSC 2.3.4 and installing using the instructions provided. In checkout_payment.php one of the instructions towards the end says: Quote var selected; ADD BENEATH: <?php /* Begin Gift Vouchers Secure */ ?> var submitter = null; function submitFunction() { submitter = 1; } <?php /* End Gift Vouchers Secure */ ?> There is no "var selected" in the file. The following instructions also are not present in the file. Quote FIND: //--></script> ADD ABOVE: //Begin Gift Vouchers Secure function popupWindow(url) { window.open(url,'popupWindow','toolbar=no,location=no,directories=no status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=450,screenX=150,screenY=150,top=150,left=150') } //End Gift Vouchers Secure FIND: <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="main"><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td> </tr> ADD ABOVE: <?php //Begin Gift Vouchers Secure echo $order_total_modules->credit_selection(); //End Gift Vouchers Secure ?> Can you advise how I should continue with this, as it's just these last 3 steps that can't be completed. See my file with previous modifications applied. checkout_payment.php Edited October 7, 2020 by aaymont Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted October 7, 2020 Author Share Posted October 7, 2020 11 hours ago, aaymont said: Can you advise how I should continue with this, Use a compare program, like Winmerge, to compare your file with the included changed one to see where the changes for this addon are made. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cinolas Posted October 27, 2020 Share Posted October 27, 2020 Hi @Jack_mcs! Thanks for bringing this contrib up to date. I'm trying to install it on osC 2.3.4 BS GOLD. I believe I already have modular checkout installed, from installing the "Pay Without Account" contrib? (Otherwise how do I check if I have modular checkout?) I understand that there are no instructions and that I should compare the files. It's a bit difficult because my files are extensively modified already, but I'm certainly willing to try. I wouldn't mind compiling instructions for 2.3.4 BS GOLD if we can figure this out. I decided to give the provided Version_2.3.4 instructions a try. From the package: - Use the new files from the CE install - Use the CE install instructions until the checkout_xx pages, then switch to the RC2 instructions for those. (I haven't tried the new files in the Version_2.3.4 folder since it says to use the new files from the Version_CE folder... should I try the Version_2.3.4/NewFiles/ ?) The CE/RC2 instructions seem to line up pretty well. I did up to checkout_process.php in the CE installation instructions, then switched to the RC2 instructions for checkout_process.php, then came back to the CE instructions for create_account.php and logoff.php, then went back to the RC2 instructions for checkout_confirmation.php and checkout_payment.php Like @aaymont above, I get to the part of the RC2 instructions that ask me to find "var selected;" in checkout_payment.php, which is not present in my version of the files. The CE instructions just don't have that bit. My checkout_payment.php looks most like the CE version (it has the require template_top line instead of the actual <head>) but I'm supposed to use the RC2 instructions for checkout_x pages. I see that the point of that step is to add the submitFunction to the <head>: var submitter = null; function submitFunction() { submitter = 1; } Should I add this (and the popupWindow(url) function) to template_top.php instead? My template_top.php doesn't have a "var selected;" either but I can just add the function somewhere. Or is this just not required for my version like for CE (the instructions for CE don't seem to be adding those functions anywhere). In the RC2 instructions there are modifications to account.php that come after the confirmation_x pages. I'm not sure if I'm supposed to do those since there are no modifications to those pages in the CE instructions, and if I understand correctly, I'm only supposed to do the RC2 instructions for checkout_x pages. Should I try the CE instructions all the way through (not using the RC2 instructions)? Any hints at this point would be great help as I would like to avoid, if possible, manually trying all the permutations Comparing files is difficult because my files don't seem to fit any of the 3 sets of ChangedFiles provided, so I'm not sure what version to compare my files against. THANK YOU! Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted October 27, 2020 Author Share Posted October 27, 2020 @cinolasI'm sorry you are having such a problem installing it. I know the instructions are very poor for your version of the shop. Regarding the var selected, the code is using that as a reference to add javascript code. To add it, in the checkout_payment.php and checkout_success.php files find this require(DIR_WS_INCLUDES . 'template_top.php'); ?> and add this after it <script language="javascript"> <?php /* following jscript function ADDED FOR CCGV */ ?> var submitter = null; function submitFunction() { submitter = 1; } <?php /* END OF ADDED FOR CCGV */ ?> </script> The attached are the root files from an old 234 shop I have here. There may be more, or less, than what is in your files but may help you to figure out the changes. gift_vouchers.zip Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cinolas Posted October 29, 2020 Share Posted October 29, 2020 Thanks @Jack_mcs that helps greatly! And I was sitting here trying to figure out how to get that script in the <head> section, but apparently javascript can be anywhere on the page lol I added the javascript and finished following the instructions the best I could, but it gave me the same result: the checkout_payment.php page ends unexpectedly after the billing address. It's the line that summons to the subtotals and totals that causes problem: <?php echo $oscTemplate->getContent('payment'); ?> If I comment it out the page renders normally. Does that shed any light as to where my problem might be? a problem in order_total.php? My order_total.php file validates, and the modifications for that file are the same in the CE and RC2 instructions. Thanks! Quote Link to comment Share on other sites More sharing options...
cinolas Posted October 29, 2020 Share Posted October 29, 2020 My php error log says: Quote PHP Fatal error: Cannot redeclare class order_total in /Applications/MAMP/htdocs/skateshop/includes/classes/order_total.php on line 13 Line 13 is: class order_total { I am not sure why it has already been declared by the time that class file gets summoned. Any idea where else it might be declared? or where else this class file might be invoked ahead of this instance? Cheers! Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted October 30, 2020 Author Share Posted October 30, 2020 3 hours ago, cinolas said: If I comment it out the page renders normally. I can't find that line in the checkout_payment file I posted nor in the instructions or the other files in the 2.3.4 files. Is it in your original file? Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cinolas Posted November 1, 2020 Share Posted November 1, 2020 @Jack_mcs, it's in my /includes/classes/order_total.php Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 1, 2020 Author Share Posted November 1, 2020 13 hours ago, cinolas said: it's in my /includes/classes/order_total.php It's not in mine. Seems like you have the wrong file, or applied the wrong change to it. For that file, you should be able to use the one in the addon, at least for testing. Also, when making changes to the class files, be sure the code is inserted before the last bracket -> } . Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cinolas Posted November 3, 2020 Share Posted November 3, 2020 Come to think of it, @Jack_mcs, I might have added the totals to the checkout_payment.php page myself, just to show the totals to the customer as they choose a payment method. I probably copy-pasted the line from another checkout_x page. Is there a better way to do this that would not cause the order_class to be redeclared? It's not vital, but I would really like to keep showing the totals on that page. On a completely different note (I'm testing other aspects of this contribution): the gift voucher emails are being sent using, as far as I can tell, the send() function: send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, TEXT_REDEEM_COUPON_SUBJECT ); send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, TEXT_REDEEM_COUPON_SUBJECT ); Is there a simple way to change that so it uses the tep_mail() function in /includes/functions/general.php? My tep_mail() function has been customized to use Postmark to send emails, and my server configured to block other attempts, so the gift voucher emails are not being sent. Thanks! Quote Link to comment Share on other sites More sharing options...
cinolas Posted November 3, 2020 Share Posted November 3, 2020 Hmmmm there are apparently other problems with my installation: I created a product to sell $25 vouchers, that worked. I purchased one with my test customer. The voucher showed up in the queue to be released, but it didn't show up in Coupon Admin after being released, and the customer balance still says No Balance even after being released. The voucher is there in the SQL tables, and osC will let me send it, or use the balance to purchase. I tried sending $15 of it, and the portion I sent showed up in Coupon Admin, but not the unsent portion ($10). The sent portion appears to be expired, it only shows up in Coupon Admin for the status "All Coupons" and "Expired Coupons". Here's the info it gives me in Coupon Admin for the sent portion: Quote Coupon Name :: Coupon Amount :: $15.00CADStart Date :: End Date :: Uses per Coupon :: 1Uses per Customer :: 0Total Used :: 0Active :: YProducts :: not setCategories :: not setManufacturers :: not setDate Created :: 11/03/2020Date Modified :: Does it require a date? is that why this one is being considered expired? Any idea how I can get the unsent portion to show up too? Trying to debug why the balance isn't showing on the Account page: I found these lines in /includes/modules/content/account/cm_account_gift_voucher.php $availBalance = CCGV_BALANCE_NONE ; if (tep_session_is_registered($customer_id)) { $gv_query = tep_db_query("select amount from coupon_gv_customer where customer_id = '" . tep_db_input($_SESSION['customer_id']) . "'"); $gv_result = tep_db_fetch_array($gv_query); if ($gv_result['amount'] > 0 ) { $availBalance = CCGV_BALANCE . ' ' . $currencies->format($gv_result['amount']); } I ran the query directly on my SQL tables, manually substituting my test customer ID and it returned the amount I was expected (the unsent portion of $10). So the second IF should've worked. Could it be tep_db_input($_SESSION['customer_id']) that's failing to return my logged-in customer id? There were no clues in my php error log. Thanks again! I think I'm pretty close to it working I would be lost without your insights. Quote Link to comment Share on other sites More sharing options...
cinolas Posted November 3, 2020 Share Posted November 3, 2020 I might be wrong about the emails not going out. I just got the email of my test customer sending a portion of the voucher, so that emails goes out fine. Does the contribution not send an email to the customer when you release the voucher? that one I did not get. Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 3, 2020 Author Share Posted November 3, 2020 The customer that purchased the gift voucher should get an email when it is released. cinolas 1 Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cinolas Posted November 4, 2020 Share Posted November 4, 2020 @Jack_mcs thanks, I'm looking into that now. Since one is going out fine but not the other, I expect they are not being sent the same way. I found the solution to the balance not showing up on the /account.php page. Line 45 of /Version_CE/NewFiles/includes/modules/content/account/cm_account_gift_vouchers.php reads: if (tep_session_is_registered(customer_id)) { For me, it only works if I put the customer_in in single quotes like this: if (tep_session_is_registered('customer_id')) { Are vouchers that have been purchased by customers as product, then released from the Gift Voucher queue, supposed to show up in coupon_admin.php? I'm a bit confused in the difference between coupons and vouchers, if there is one. As always, thanks enormously for the support. Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 5, 2020 Author Share Posted November 5, 2020 Thank you for posting the fix. The change you made is correct. Coupons are code you give to someone. For example, if you wanted to give me 10% off of some product in your shop, you would create a coupon code and give it to me. Gift Vouchers are meant to be sold as products. In this case, I would go to your site and order a gift voucher. Once you released it, I could either use it myself or send it to someone so that they can use it. It will not show in the coupon section in admin. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cinolas Posted November 12, 2020 Share Posted November 12, 2020 Thanks @Jack_mcs ! I think I understand the logic, "Gift Vouchers" are purchased as products, and then the purchaser can send the funds, or portions of, as "Coupons" to other people. Coupon Admin is meant to manage the Coupons, but there's no interface to manage the Gift Vouchers? For my application, I would need to be able to edit the Gift Vouchers for when customers call in their order by phone and pay with their own Gift Vouchers (we expect some customers will use vouchers as a form of lay-away). Is there no way to do this with the current interface? Cheers Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 13, 2020 Author Share Posted November 13, 2020 6 hours ago, cinolas said: For my application, I would need to be able to edit the Gift Vouchers for when customers call in their order by phone and pay with their own Gift Vouchers (we expect some customers will use vouchers as a form of lay-away). Is there no way to do this with the current interface? No, that is not how they are designed to be used. The amount is stored in a table but that is only changed in admin when the GV is redeemed. It is meant to be handled via the customers account. You can install either the Master Password or Phone Orders addon that will allow you to login to the customers account on the shop side. Then complete an order and use the Gift Voucher balance when checking out. By the way, have you looked at the Gift Voucher FAQ in the customers My Account section? That might answer some of your questions about them. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cinolas Posted November 17, 2020 Share Posted November 17, 2020 Thanks @Jack_mcs I have looked at the FAQ, the difference between coupons and vouchers weren't obvious at first. I'm getting acquainted with the concepts One problem I'm still having is that the user MUST enter a payment method for checkout to work, even if they have enough balance in their Gift Voucher account. The FAQ makes it sound like they should only have to enter a payment method if they don't have enough in their Gift Voucher account. If I don't enter a payment method but click the checkbox to use my balance I am sent to the order confirmation page, but then when I click the Confirm button there, it sends me back to the payment page with the message: Please select a payment method for your order. I'm assuming this isn't normal? The amount is correctly attributed to the order on the confirmation page, so I doubt that the problem is about fetching the balance. This is I believe the relevant part of my checkout_confirmation.php page, that part is identical to the Version_2.3.4/ChangedFiles/checkout_confirmation.php: // load the selected payment module require('includes/classes/payment.php'); // Begin Gift Vouchers Secure if ($credit_covers) $payment=''; $payment_modules = new payment($payment); require_once('includes/classes/order_total.php'); // End Gift Vouchers Secure require('includes/classes/order.php'); $order = new order; // Begin Gift Vouchers Secure $order_total_modules = new order_total; $order_total_modules->collect_posts(); $order_total_modules->pre_confirmation_check(); // if ( ($payment_modules->selected_module != $payment) || ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) { if ( (is_array($payment_modules->modules)) && (sizeof($payment_modules->modules) > 1) && (!is_object($$payment)) && (!$credit_covers) ) { // End Gift Vouchers Secure tep_redirect(tep_href_link('checkout_payment.php', 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL')); } if (is_array($payment_modules->modules)) { $payment_modules->pre_confirmation_check(); } // load the selected shipping module require('includes/classes/shipping.php'); $shipping_modules = new shipping($shipping); // Begin Gift Vouchers Secure //require('includes/classes/order_total.php'); //$order_total_modules = new order_total; //$order_total_modules->process(); // End Gift Vouchers Secure // Stock Check $any_out_of_stock = false; if (STOCK_CHECK == 'true') { for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) { $any_out_of_stock = true; } } // Out of Stock if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); } } I've also tried the code from the Version_CE/ChangedFiles/checkout_confirmation.php version but it gives exactly the same result: // load the selected payment module require('includes/classes/payment.php'); // Begin Gift Vouchers Secure if ($credit_covers) $payment=''; $payment_modules = new payment($payment); require_once('includes/classes/order_total.php'); // End Gift Vouchers Secure require('includes/classes/order.php'); $order = new order; // Begin Gift Vouchers Secure $order_total_modules = new order_total; $order_total_modules->collect_posts(); $order_total_modules->pre_confirmation_check(); // End Gift Vouchers Secure // load the selected shipping module require('includes/classes/shipping.php'); $shipping_modules = new shipping($shipping); // Stock Check $any_out_of_stock = false; if (STOCK_CHECK == 'true') { for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) { $any_out_of_stock = true; } } // Out of Stock if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) { tep_redirect(tep_href_link('shopping_cart.php')); } } // Begin Gift Vouchers Secure //require('includes/classes/order_total.php'); //$order_total_modules = new order_total; //$order_total_modules->process(); // End Gift Vouchers Secure Any idea what could be wrong? Thanks! Quote Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 17, 2020 Author Share Posted November 17, 2020 2 hours ago, cinolas said: I'm assuming this isn't normal? It is normal but not to do with this addon. It is because the code in the shop won't allow an order with a total of $0. To test that, enable the COD or Check/Money Order module, create a product with the cost of $0 and try to order it. You could try this addon though it may not work without edits. If the product is marked as a download, then you can complete the order but that is not useful for normal problems. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
♥14steve14 Posted November 18, 2020 Share Posted November 18, 2020 Jack. I was all geared up to add this to my new Phoenix site but I see that you still have core code changes that are required. Is there any way that these minor changes can be added into a hook or something. Otherwise it looks like something I could use, but cant if it required these manual changes. Quote REMEMBER BACKUP, BACKUP AND BACKUP Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 18, 2020 Author Share Posted November 18, 2020 5 hours ago, 14steve14 said: Is there any way that these minor changes can be added into a hook or something. I don't think it can be handled with hooks or modules but it can be done with a template. I planned on looking at that for the next release since the current one won't work with 1.0.7.10 anyway. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cinolas Posted November 18, 2020 Share Posted November 18, 2020 19 hours ago, Jack_mcs said: You could try this addon though it may not work without edits. Good idea. That payment module is a copy of the COD module that only shows up when $order->info['total'] = 0 Obviously, the total isn't 0 when the user gets to the payment page, since they have not applied their Gift Voucher balance to the order yet. But osC still allows the user to move on to checkout_confirmation.php, it's only when they click Confirm that they are sent back to checkout_payment.php... SO, I'm thinking there could be a quick way to change the selected payment module to the Free module when loading checkout_confirmation.php if the total at that point is = 0 I am, however, not quite sure how to do that 😔or even where I should try to add this tweak. Somewhere in checkout_confirmation.php, or perhaps in /includes/classes/payment.php? Any hints is gold, I am out of my depths here, sadly. But willing to learn! Quote Link to comment Share on other sites More sharing options...
cinolas Posted November 18, 2020 Share Posted November 18, 2020 Or could the checkout confirmation process be changed to allow orders that have a total of $0 without invoking the payment method? 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.