Jump to content

Get Product combinations stock quantity :/ Doesn't work :(


Recommended Posts

On my product-pages now, the stock quantity is shown like a number, 82, If I have 2 combinations with 7 in one combination and 75 in another combination it will show that, when toggling between the combinations.

That's great.

 

But I want it to show 100+ if the stock quantity is over 100 and when only a few is left I want the show "get it while we have the item in stock" or something.

 

BTW this is the line that shows the stock level now:

<span id="quantityAvailable">{$product->quantity|intval}</span>

I tryed: 

<span id="quantityAvailable">
{if $product->quantity|intval < 100 || $product->quantity|intval > 7}
{$product->quantity|intval}

{elseif $product->quantity|intval >= 100}
100+

elseif{$product->quantity|intval <= 6 || $product->quantity|intval > 0}
Only a few left!
 
{/if}
</span>

But this only works for every item, not the specific combination :(

 

How to Get the combination-stock-quantity in ror? Or is this a javascript thing? 

 

The site is: mackabler.dk

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

  • 11 months later...
<span id="quantityAvailable2">

{if $product->quantity|intval < 100 && $product->quantity|intval > 7}

{$product->quantity|intval}

1

{elseif $product->quantity|intval > 100}

100+

2

{elseif $product->quantity|intval <= 6 && $product->quantity|intval > 0}

Only a few left!

 3

{/if}

</span>

Link to comment
Share on other sites

  • 8 months later...

I was able to solve this by editing /themes/default-bootstrap/js/product.js

 

In function updateDisplay(), about 481 line, after the following code

if (!selectedCombination['unavailable'] && quantityAvailable > 0 && productAvailableForOrder == 1)
{

I added:

if (quantityAvailable > 50) {
     quantityAvailable = '50+';
}

And it works ;)

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...