Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Tip: Automatically Select An 'in-Stock' Combination On Product Page Load Rate Topic   * * * * * 1 votes

 
  • DialdBikes
  • Newbie
  • Members
  • Join Date: 19-Jan 12
  • 6 posts

Posted 15 March 2016 - 08:42 PM #1

Hi guys.

 

I would like to share this hint/tip with you all since it's been quite important to us and I'm sure it will be useful to somebody else.

 

We've recently upgraded to version 4.3.5 and we've noticed a piece of functionality missing that was present in 2.2.5 but not in the 4.3.x versions.

 

When a customer browsed to a product on our old store, the product loaded and automatically selected a product combination that was 'in-stock'.

 

We run 99% of our products to 'track with options', so each of our products carry many combinations with inventory/stock quantities attached to each.

 

In version 4.3.x, the first variant in each option is selected by default and this can often result in the product appearing 'out of stock' to a customer at first glance if the first combination has sold out. I didn't like the fact that customers now had to dig through the options to find a combination that was in stock.

 

Here's how I changed our cart to automatically load the first in-stock product combination it can.

 

In /app/functions/fn.catalog.php, look for this block of code (at around line 3700):

unset($product_options);
    if (!fn_allowed_for('ULTIMATE:FREE')) {
        if (empty($exceptions)) {
            return $default;
        }
    }

Change it to the following:

unset($product_options);
    if (!fn_allowed_for('ULTIMATE:FREE')) {
        if (empty($exceptions) && ($track_with_options != ProductTracking::TRACK_WITH_OPTIONS)) {
            return $default;
        }
    }

Save the file, upload, clear your store cache and test it. That's it  :grin:

 

I've tested this with all types of products (types of tracking and 'combination exceptions' too) with no issues. 

 

Please note that this is a core edit so any future upgrades are bound to remove this.

 

We haven't upgraded to 4.3.6 yet, but I've checked the source and this doesn't seem to be present in the new version either.

 

Cheers!

Andrew.



 
  • veganermat
  • Advanced Member
  • Members
  • Join Date: 04-Nov 14
  • 54 posts

Posted 08 April 2016 - 12:41 PM #2

thank you, this was very useful!!  :grin:  :grin:



 
  • dotell
  • Junior Member
  • Trial users
  • Join Date: 21-Oct 09
  • 218 posts

Posted 01 October 2016 - 08:00 PM #3

This work in 4.3.9?



 
  • dotell
  • Junior Member
  • Trial users
  • Join Date: 21-Oct 09
  • 218 posts

Posted 01 October 2016 - 11:10 PM #4

To answer my own question:  Yes, it does work!



 
  • Antars
  • Member
  • Members
  • Join Date: 18-Sep 11
  • 45 posts

Posted 31 October 2016 - 08:34 PM #5

been looking for the solution, but in my CS-Cart 4.2.2 the offered solution does not work.



 
  • Antars
  • Member
  • Members
  • Join Date: 18-Sep 11
  • 45 posts

Posted 31 October 2016 - 08:35 PM #6

the error i get

is currently unable to handle this request.

HTTP ERROR 500