Doesn't work on Litecart 2.3.5

Merchant
From United States
Member since Mar 2022

When selecting a product combo, json output is blank.

The part that is failing seems to be this:

    if (count($product->options_stock) > 0) {

      foreach ($product->options_stock as $stock_option) {
        foreach (explode(',', $stock_option['combination']) as $pair) {
          if (!in_array($pair, $selected_options)) continue 2;
        }```

It seems to never match anything, I put:

```print "if not in array $pair, of ". print_r($selected_options); print "\n";  
if (!in_array($pair, $selected_options)) print "continue";```

to debug it, and here were the results:

```Array
(
    [0] => 1-0
    [1] => 2-0
)
if not in array 1-0:"Black", of 1
continue

Array
(
    [0] => 1-0
    [1] => 2-0
)
if not in array 1-0:"Black", of 1
continue

Array
(
    [0] => 1-0
    [1] => 2-0
)
if not in array 1-0:"Grey", of 1
continue

Array
(
    [0] => 1-0
    [1] => 2-0
)
if not in array 1-0:"Grey", of 1
continue

I am not sure how to fix this, please help if you can.

tim
Founder
From Sweden
Member since May 2013
tim

I had a newer version locally that I published.
If that doesn't solve the problem I will dig into it.
Let me know if it solves your problem.

Merchant
From United States
Member since Mar 2022

Thank you, Tim! Unfortunately it still doesn't work. The behavior is the same.  What should be json output is just 6 lines but blank.

tim
Founder
From Sweden
Member since May 2013
tim

Worked for me. Any errors in logs/errors.log?

Merchant
From United States
Member since Mar 2022

No errors in error.log for this. 

The $_POST contents:

(
    [product_id] => 6
    [options] => Array
        (
            [Color] => Black
            [Size] => X-Small
        )

    [quantity] => 1
)

And the output in the part again that I believe is failing (?)

(
    [0] => 1-0
    [1] => 2-0
)
if not in array 1-0:"Black", of 1
continueArray
(
    [0] => 1-0
    [1] => 2-0
)
if not in array 1-0:"Black", of 1
continueArray
(
    [0] => 1-0
    [1] => 2-0
)
if not in array 1-0:"Grey", of 1
continueArray
(
    [0] => 1-0
    [1] => 2-0
)
if not in array 1-0:"Grey", of 1
continue

If there is anything else I can do to place print_r or var_dumps to help debug why this isn't working, please let me know. Thanks for your help. It seems to just fail to find it and continues through all the products and doesn't stop.

Merchant
From United States
Member since Mar 2022

I've tried going back to the beginning, uninstalling the mod, and redoing everything step by step just to ensure I didn't miss anything, same result.

If this cannot be fixed because it is not a paid modification, is there a mod in the store otherwise that would incorporate this functionality? 

Even if it's paid, I would pay for it to work. Without this mod, the default stock amount is misleading. I might have a total of 9 stocked shirts but which combination? It could be 6 gray shirts, and 3 black shirts. The customer has no idea what combinations are actually stocked, until they try and add them and this will be confusing when some combinations are sold out.

tim
Founder
From Sweden
Member since May 2013
tim

I will rewrite this addon when I get the chance. Right now I have work over my head.
Remind me in a week or two.

Merchant
From United States
Member since Mar 2022

Thank you tim, I appreciate your time. I'm still very interested in getting this addon to work!

You
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.