Jump to content

PS 1.7 Free Orders Not Working


realloyalist

Recommended Posts

Edit: Fix for 1.7.3.3: Comment-3185932
Edit: Fix for 1.7.6.5: Comment-3236846
Edit: Fix for 1.7.8.7: Comment-3404464

The online store that I maintain recently created a Prestashop 1.7 store and have been slowly migrating our products over. One thing that I have discovered is that Prestashop no longer seems to allow free orders. Our online store has a number of free virtual products and in PS 1.6 this wasn't an issue at all. You could add them to your cart and checkout as normal though it would recognize the order as free and bypass the payment step. Now however, in PS 1.7 if I only have a free item in the cart and proceed with checkout it gets to the payment step and won't allow you to proceed. There are no payment methods listed to select which is good however the "Order with an Obligation to Pay" button remains grayed out not allowing you to continue. Underneath the button it has the statement, Please make sure you've chosen a payment method and accepted the terms and conditions.

Can anyone else confirm that this is a bug? If so I'll file a bug report.

You can try this yourself on our store here, 3abnstore.com

2018-08-27_151038.jpg.46cf82f772dfc4c3e46f6508ba6344c1.jpg

Edited by realloyalist (see edit history)
Link to comment
Share on other sites

This functionality has been removed from earlier 1.7 versions. Maybe 1.7.4.x has it but I am not sure. If it is important to you then start with 1.6.

Link to comment
Share on other sites

  • 1 year later...

Free checkout works on my site with 1,7, with only the paypal module enabled (I have the other COD and Bank wire installed, but they are not configured so I assume that they are not enabled).

I did have a problem when I removed the obligation to tick "Terms and Conditions" checkbox...the button greyed out, so I thought I'd mention it here in case anyone else is searching for the same resolution. 

Apparently you can't have a free order without that checkbox.

Link to comment
Share on other sites

Thank you, that does seem to be the case. I tested by turning on the Terms and Conditions requirement and it allowed the free order to go through. Since we do not need or want that requirement though it doesn't do us much good. It would be nice if Prestashop added some functionality for handling free digital downloads though those of us needing that are probably in the minority.

15 hours ago, twistoon said:

Free checkout works on my site with 1,7, with only the paypal module enabled (I have the other COD and Bank wire installed, but they are not configured so I assume that they are not enabled).

I did have a problem when I removed the obligation to tick "Terms and Conditions" checkbox...the button greyed out, so I thought I'd mention it here in case anyone else is searching for the same resolution. 

Apparently you can't have a free order without that checkbox.

Link to comment
Share on other sites

  • 2 months later...

Anyone else needing to allow free orders I finally found how to get PS 1.7 to work. I did this running PS 1.7.3.3. Basically the issue is that the Order button is controlled via Javascript and JQuery with the button being disabled by default. In the code the function that verifies and enables the Order button only runs when changes on the page are detected such as changing the payment option. For a free order none of those watched for triggers happens causing the Order button not to validate and enable. I added a simple if statement that looks for the free order payment type and if found runs the Order button code. Here is the changes that I made. I am not responsible for any issues that may arise from this change. I am simply stating what change I have made.

File to change: core.js
File found in: /themes

Roughly around line 2267 you should find a section that starts with,  
 _createClass(Payment, [{
        key: 'init',
        value: function init() {
          (0, _jquery2['default'])(this.paymentSelector + ' input[type="checkbox"][disabled]').attr('disabled', false);

In this function before the three $body.on statements I placed the following if statement.

// If free order toggle order button
          if ((0, _jquery2['default'])('input[data-module-name="free_order"]').length)
            this.toggleOrderButton();

 

After saving and uploading the modified core.js file free orders now work like any other order.

 

Link to comment
Share on other sites

  • 3 months later...

Hey @realloyalist -- any chance you could post similar fix code for the latest version of PrestaShop?  

I'm running 1.7.5.1 and it looks like the code in core.js is packed/compressed and a slightly different format than your example.. rather difficult to read and change in that format.  Grrr..

Would appreciate any help.

NOTE: Your fix should be standard in Prestashop -- it's a BUG that an order cannot be completed/placed if the Total = 0 !

Link to comment
Share on other sites

Hello @redrob, thank you for posting about 1.7.5.1 I'll be sure not to upgrade for now. I agree Prestashop should get this fixed for what should be a standard option. When I get a chance I'll try and take a look at the latest version. Unfortunately I'm not really much of a developer myself so whenever they change the coding around it takes me a while to make sense of it. Getting used to the big differences between 1.6 and 1.7 has been a struggle.

Link to comment
Share on other sites

  • 1 month later...

I tried to unminify the code from 1.7.5.2 of the core.js file and to add your if statement even if I'm not sure where exactly.

I didn't figure out how to make it work right now on 1.7.5.2

If the somebody could help it would be amazing !

Link to comment
Share on other sites

Hey guys @redrob, @chon59. I believe I figured out how to make the free orders work on new versions. I did this test on PS version 1.7.6.5 so if it is the same as your versions hopefully it will work. Prestashop changed the core.js file all around and made it much more difficult to read and adjust. I did this test with a new installation of Prestashop running in a virtual machine so no guarantees it will work with production environments.

File to change: core.js
File found in: /themes

Roughly line 161

The code is all on one really long line. Easiest way to find the spot is to search for: var e=(0,r.default)("body")
There will be 2 results, the one you want is the second one on line 161 which is a good ways in the line.

In the same line right after, var e=(0,r.default)("body");
insert the following code
if((0,r.default)('input[data-module-name="free_order"]').length){this.toggleOrderButton();}

After making this change you may need to clear Prestashop's cache under the Performance settings.

This should allow free orders to be processed now. Hopefully this works for everyone.

Edited by realloyalist (see edit history)
  • Thanks 2
Link to comment
Share on other sites

Hello @realloyalist, many thanks for your solution.

We also try to activate free orders redirects to order confirmation page.
We tried your solution in Prestashop 1.7.6.1 and it doesn't work.
We have an error in the return page :

undefined order in PaymentModule.php line 364
 at PaymentModuleCore->validateOrder(1498, ‘2’, 0, ‘Commande gratuite’, null, array(), null, false, ‘77db7cf89409d8ba3fb817e2f013e2e4’)
in OrderConfirmationController.php line 159

Do you already seen this problem ?

Thanks

Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...
  • 1 year later...

So it was time to upgrade my store again and had to find how to re-apply the free orders fix. Similar steps as the fix for 1.7.6.5. From the github issue it seems like Prestashop might have fixed the issue for the 1.8 release though I find the github hard to interpret.

Anyway, for PS 1.7.8.7 you will be modifying the core.js file again located in the themes directory of your installation. Start by searching the file for, var e=(0,r.default)("body")
You should get 3 results. You'll want the 3rd result that has an e.on("change",  statement after it.
Right after the var e=(0,r.default)("body") and before the e.on statement past the following if statement.

if((0,r.default)('input[data-module-name="free_order"]').length){this.toggleOrderButton();}

You may then need to clear the store's cache and/or the cache of your browser. This then has allowed my freshly upgraded store to work with free items once again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...