Jump to content

Recommended Posts

4 hours ago, Rosyweb said:

1) Are you, when on your site - able to choose select Products and then choose' exclude Specials' and click save and it actually creates that code successfully and adds it to you list?    

2) Then does that code follow through and work and actually exclude the specials when you try it out in cart view? 

many thanks

I just checked and it works correct on this way.

The problem may appear in a store with thousands of products.

- The max. post size may be reached if thousands of products are selected.

- the product list in the coupon listing will get very, very long (all discount products will be listed)

- in ot_discount, the coding merges the product_id's array against the specials array. This may slow down page load if there are thousands of product id's.

Even it works, it may not be useful for big stores with thousands of products.

So it would be good in a future to try to add the functionality in the way specials could be excluded on the subtotal option. Then in ot_discount, if exclude specials is flagged, loop only through the ordered products and compare against specials and exclude them from discount.

 

Share this post


Link to post
Share on other sites

1)  On the one hand - that's brilliant Tsimi.    Its allowed me to get it to work excluding specials. 

Can I just suggest putting a tiny bit of text on that page to say - please highlight products from the below list that you want included.    It wasn't obvious that these actually needed highlighting and that it wouldn't work with them just listed there.

2)  Yes I've run into the problem that Raiwa has identified above.  The site has 1200 products.  Not huge, but its a working site.   The list only let me select up to J!!   So half my products were left off. 

Is there any way of uping the max. post size.  Where is this defined? 

thanks again!

 

Share this post


Link to post
Share on other sites
41 minutes ago, Rosyweb said:

Is there any way of uping the max. post size.  Where is this defined?

This is a php.ini setting. It can be overwritten in .htaccess, but it depends on your hosting if it will work. You probably need to request your hosting to increase it. If you are on a shared server, it will be difficult.

https://stackoverflow.com/questions/6135427/increasing-the-maximum-post-size

Edited by raiwa

Share this post


Link to post
Share on other sites

I tried on a test store with several thousand products and it seems there are more limitations for posting data.

I couldn't get all products included even with post_max_size set o zero (no limit).

It seems the limit for me is around 900 products. (xampp local develop installation)

Here more info about:

https://stackoverflow.com/questions/2364840/what-is-the-size-limit-of-a-post-request

"The url portion of a request (GET and POST) can be limited by both the browser and the server - generally the safe size is 2KB as there are almost no browsers or servers that use a smaller limit.

The body of a request (POST) is normally* limited by the server on a byte size basis in order to prevent a type of DoS attack (note that this means character escaping can increase the byte size of the body). The most common server setting is 10MB, though all popular servers allow this to be increased or decreased via a setting file or panel."

Edited by raiwa

Share this post


Link to post
Share on other sites

Ok so its never really going to work for most people on selecting all products then.  But then of course I can set it on Manufacturers with excluding specials selected.  That way I still cover all my products and exclude specials.

I've done this.  Although when I highlighted all manufacturers, when it created the code -  it only listed the first (this got me worried) but actually it does work on all manufacturers products, and excludes specials.

Great - some way to get it working.  All the calculations are now correct as well!

thanks for your time in helping me suss this out and working out whats possible and limitations also.      It would still be great to sub-total after the discount etc applied, so I'll watch out in case that gets added later by yourself Raiwa or  Lambros.   The old discount codes I was using pre BS was ot_discount_coupon_codes_3_34_osc2.3_1_2_3.     

 

Share this post


Link to post
Share on other sites

If you intend to select all products couldn't you use the select Categories feature? To select 1000 products or only 10 categories makes a big difference. That won't require such a large list up.

 

Share this post


Link to post
Share on other sites

@Tsimi, @Rosyweb,

I had a look on the coding and it was easier than I thought to add the exclude specials feature on subtotal discount.

Can you give it a try and confirm if all works correct.

Just replace these 2 files:

- admin/discount_codes.php

- includes/modules/order_total/ot_discount.php

 

discount_codes.php

ot_discount.php

Edited by raiwa

Share this post


Link to post
Share on other sites

OK, here is the ot_discount.php which should substract the discount from order subtotal if sort order is before order subtotal.

NOTE: it will also substract shipping discount from subtotal.

 

ot_discount.php

Share this post


Link to post
Share on other sites
On 11/18/2018 at 3:35 PM, Tsimi said:

To simply select all products just click the very first product and then scroll all the way down and hold the SHIFT button and click the last product on the list now all products within the list should be selected. Then click the save button.

I think "Ctrl + A" is better way to select all products in a window.


Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites
23 hours ago, Tsimi said:

If you intend to select all products couldn't you use the select Categories feature? To select 1000 products or only 10 categories makes a big difference. That won't require such a large list up.

 

In my case, I add a drop-down menu for categories excluded from the discount.
This allows you to select fewer categories if just some are excluded and the rest of categories/products is concerned. :)

PS: In this example, discount coupons are displayed from the customer area and show which categories are excluded.

modified_discount_coupon.jpg

discount_coupon_in_account.jpg

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

Just replying to the test from Raiwa. 

I did copy those 2 files over and it did let me select Applies to Order sub-total  and then select 'Exclude specials'  

BUT - the result,  it didn't actually exclude the specials product I put in my cart along with others.  

Was I supposed to highlight anything?  Here's my screenshot:

ScreenShot20Nov_b.jpg.08b7e51bd80267865117fcede2272da0.jpg

 

 

Share this post


Link to post
Share on other sites

@Rosyweb,

Can you please doublecheck and make shure you replaced the ot-discount module.

On my test store it works.

Share this post


Link to post
Share on other sites

@raiwa

Works like a charm for me. Well done!
You came up very quickly with a solution for both requested features.
I also tried with OT discount module before and after sub-total and it worked fine.
Also tested prices with and without tax and also all good for me.

@milerwan

CTRL + A would usually work but it doesn't for this case. 😉

Edited by Tsimi

Share this post


Link to post
Share on other sites

@Tsimi
It's a shortcut known on Windows and it works in this case too.
All rows are selected with it... Just test it. :)


Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites
3 minutes ago, milerwan said:

@Tsimi
It's a shortcut known on Windows and it works in this case too.
All rows are selected with it... Just test it. :)

I did test it but it didn't work so I didn't mention it. Great if it works on your store.

Share this post


Link to post
Share on other sites
4 minutes ago, Tsimi said:

I did test it but it didn't work so I didn't mention it. Great if it works on your store.

It's not a question of store, it's just a question of browser (Chrome, IE, firefox, Opera, etc).
All work with this trick normally.


Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites
1 hour ago, Tsimi said:

@raiwa

Works like a charm for me. Well done!
You came up very quickly with a solution for both requested features.
I also tried with OT discount module before and after sub-total and it worked fine.
Also tested prices with and without tax and also all good for me.

Then I'll upload the update. Version number Discount_Codes_4.4.0_BS is ok ?

Share this post


Link to post
Share on other sites

Update uploaded:

Version 4.4.0 BS:

  • Added the possibility to exclude specials on order subtotal discounts.
  • Added support to place ot discount module before ot subtotal module and show subtotal with discount amount substracted.

 

Share this post


Link to post
Share on other sites

Still having trouble getting mine to exclude specials, but if it works on everyone else's I must have missed something. So will try and suss out what I've got that is different. 

Share this post


Link to post
Share on other sites

Hello everyone. I'm having some issues to define some coupons for number of products. For examples:

Coupon: EXAMPLE 1 -> 10% discount -> 1 product

Coupon: EXAMPLE2 -> 20% discount -> 2 products

Coupon: EXAMPLE3 -> 30% discount -> 3 products

It's possible to use with "number of products to apply the discount" for all users and all products just defining like the example I gave? I tried everyting but it doesn't work.. Any help would be awesome.

By the way, is there any change to anyone add a coupon only for a certain attribute?

Share this post


Link to post
Share on other sites

The option " Number of products to apply the discount: " is only available for discounts on specific products or categories or manufacturers, not for subtotal discounts.

You have to use:

Applies to: Products or Categories or Manufacturers

         
 

and select the products/categories/manufacturers you wish to include. Selecting all categories or manufacturers is a trick if you wish to use it for all products. See previous posts about the exclude specials problem.

For me it works all as expected. It applies to the amount of products as entered.

14 minutes ago, sinopia said:

By the way, is there any change to anyone add a coupon only for a certain attribute?

No, I don't think so. It is not planned.

Edited by raiwa

Share this post


Link to post
Share on other sites

Hello @raiwa thank you for your answer. I did selected all products and even categories (I don't use manufacturers). The coupon "EXAMPLE3" works always if I have 1 product or 3 products for example, shouldn't it only be valid if 3 products or more are in the cart?

About the attributes I think that a good idea and also some shops are using that way... Thank you, I'll check about the excluded specials problem, that can be my issue. 

Share this post


Link to post
Share on other sites

Can't fix it, in the version I had I set the javascript at checkout_payment manually and not at header_tags, the discount code works normally but I get this error at console:

Uncaught ReferenceError: $ is not defined

                $.post("discount_code.php", {discount_code: $("#discount_code").val()}, function (data) {


But even with the old one it check correct the discount code but should apply for 3 products as I've set it on admin/discount_codes.php

I've been reading everything but nothing is solving my problem.

 

Share this post


Link to post
Share on other sites

Did you check the radio button "products" or "categories" instead of "subtotal"?

Can you please post a screenshot with an example (both, admin and checkout confirmation).

I checked again and it works for me for 2 products:

image.png.b1e49a2d5edd51c0007d62ffbdce44fd.png

image.thumb.png.fabeddba0e831810ca2c9160a6cbb4c3.png

 

image.thumb.png.c479eb9027bd68348e701bf5cde99ab5.png

 

NOTE: Mouse and graphic card gets discounted.

 

image.png

Share this post


Link to post
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

×