Post by mondokat » Sun Feb 26, 2012 9:38 am

So, I noticed that coupons don't really go by category, like is sort of implied by the interface. What it actually does is when you click the category control on the coupon code page, it adds all the products from that category that exist at the time into the product list and stores that in a "coupon_product" table in the database. There is no internal processing of categories at all.

The problem with this is that any new products added after the code won't be part of that coupon code, even if they are in the correct category. You'd have to add you product, then go back and re-add the category to the coupon code to "refresh" it. This is a non-starter for me, and must be fixed before I can use opencart, so I'm going to give a shot at writing a vqmod to fix it tonite. Wish me luck. I'll record progress here.

New member

Posts

Joined
Mon Feb 20, 2012 3:55 pm

Post by mondokat » Sun Feb 26, 2012 11:35 am

So, here's a list of things that likely should be changed:
  • 1. Clicking on categories should not populate the products list on the coupon page
    2. loading the page should remember what was clicked before
    3. referencing the coupon code should refer to the product list AND any products associated with the selected category.
The first step is easy. Looks like there is a line of javascript that references the scrollbox that houses the category list. Looks like this:

Code: Select all

$('input[name=\'category[]\']').bind('change', function() {
If I change the input name to something that doesn't exist, it will sufficiently break the function. I'm just going to have it look for an array called "junk". This step was easy.

Next step is to make it remember what was selected. For that, I'm going to have to make a schema change in the db, add a new table (coupon_category) and add the contents of the control to it. I'll look at how the product scrollbox gets populated and just copy that code.

New member

Posts

Joined
Mon Feb 20, 2012 3:55 pm

Post by mondokat » Sun Feb 26, 2012 12:41 pm

Man, the indention in this code is all over, yuck. Code style makes for good readability, guys. C'mon.

New member

Posts

Joined
Mon Feb 20, 2012 3:55 pm

Post by mondokat » Sun Feb 26, 2012 1:37 pm

I just learned that order of operation matters in vqmod. If you do a insert of some code on one pass that matches a replace on a second pass, it will modify the inserted code. Good to know.

New member

Posts

Joined
Mon Feb 20, 2012 3:55 pm

Post by mondokat » Sun Feb 26, 2012 2:25 pm

Done with making the ui elements work as expected. The category selector is actually more closely related to the product page's category selector than the coupon page's product selector on the front end, but more like the product selector on the backend. Pretty easy to mod, just took me a while to find all the pieces. Ok, so now that the admin pages will let me configure it, I need to figure out how to make it get applied when checking out. I have an idea for this already, or I wouldn't have even started, I am pretty confident.

New member

Posts

Joined
Mon Feb 20, 2012 3:55 pm

Post by mondokat » Sun Feb 26, 2012 4:12 pm

So I wrote a mod for "catalog/model/checkout/coupon.php", and it is working. Yay! I can't find another place where this code would be used, but if anybody knows any different, I'd love to hear it. It is definitely calculating correctly on the checkout page though. I have checked a category in my coupon code admin ui, and an item in that category reflects the code. awesome. This was easier than I thought.

New member

Posts

Joined
Mon Feb 20, 2012 3:55 pm

Post by mondokat » Mon Feb 27, 2012 2:59 am

And, since I don't think this thing is worth ten bucks (the minimum you can charge on the extensions web site on opencart.com, wish I could charge a dollar, beer money), here it is for free:

http://www.opencart.com/index.php?route ... on_id=5166

New member

Posts

Joined
Mon Feb 20, 2012 3:55 pm

Post by Lisaweb » Mon Feb 27, 2012 7:30 am

This is great work, really appreciate the effort, thanks much! I'm gonna go download and try it now...

Using OC v1.5.4.1 with Evisu Theme


User avatar
Active Member

Posts

Joined
Wed Dec 07, 2011 12:01 am

Post by tarang1906 » Sat May 05, 2012 8:52 pm

Hi mondokat,

Awesome work!!

I am facing an issue with coupons, i know it might not be the right place to post this, but i have already started a thread on this with no response! http://forum.opencart.com/viewtopic.php?f=24&t=54253

When I select a category, ALL the products from ALL the categories are getting inserted in the products section...whereas only products from that particular category should be added.

I check my files with OC original ones but no difference...! ???

I tried with your module to see if this issue could get solved..but nothing! Its working the same way with the above issue.

Could you please suggest something?

Really appreciate any help. Please reply


Thanks

Newbie

Posts

Joined
Wed Mar 07, 2012 9:41 pm

Post by burley » Tue May 08, 2012 8:30 pm

WoW! mondokat!!! really awesome work, thanks for your efforts!
This is a great addition to the shop and very much needed!

Going to download and install it right now.

Voting for "mod of the month" if there were such a thing!!


Edit: did anyone get it to work in v1.5.1? I installed it but can't seem to get it to work.
At least I can't see anything different in my coupon section.

User avatar
Active Member

Posts

Joined
Sun Oct 09, 2011 3:30 pm
Who is online

Users browsing this forum: No registered users and 23 guests