Jump to content

Help - Availability And Attributes.


bsthomsen

Recommended Posts

Hi

 

I´ve made som changes to my products.tpl so availablity_status fits my needs.

That is also working 100%.

 

BUT - if I´ve a product with attributes, I can´t get it working.

 

I´ve tried to modify my product.js in 1000 different ways, but nothing is working right.

 

I´m jusing prestashop 1.5.3 with default theme. Product.js is back to standard 1.5.3 file.

 

Anyone who knows which modifications I´ve have to do in product.js to make it do the

same as my product.tpl ???

 

This is my modyfied part of product.tpl concerning the availability-status:

<!-- availability -->

{if $allow_oosp}

{if ($product->quantity > 0 && $product->available_now != '') OR ($product->quantity <= 0 && $product->available_later != '')}

<p id="availability_statut"{if $PS_CATALOG_MODE} style="display: none;"{/if}>

<span id="availability_label">{l s='Availability'}</span>

<span id="availability_value"{if $product->quantity <= 0} class="warning_yellow_inline"{/if}>

{if $product->quantity <= 0}{$product->available_later}{else}{$product->available_now}{/if}

</span>

</p>

{else}

<p id="availability_statut">

<span id="availability_label">{l s='Availability'}</span>

<span id="availability_value_call">

{l s='Call us!'}

</span>

</p>

{/if}

{else}

{if $product->quantity > 0}

{if ($product->quantity > 0 && $product->available_now != '') OR ($product->quantity <= 0 && $product->available_later != '')}

<p id="availability_statut"{if $PS_CATALOG_MODE} style="display: none;"{/if}>

<span id="availability_label">{l s='Availability'}</span>

<span id="availability_value"{if $product->quantity <= 0} class="warning_yellow_inline"{/if}>

{if $product->quantity <= 0}{$product->available_later}{else}{$product->available_now}{/if}

</span>

</p>

{else}

<p id="availability_statut">

<span id="availability_label">{l s='Availability'}</span>

<span id="availability_value_call">

{l s='Call us!'}

</span>

</p>

{/if}

{else}

<p id="availability_statut"{if $PS_CATALOG_MODE} style="display: none;"{/if}>

<span id="availability_label">{l s='Availability'}</span>

<span id="availability_value"{if $product->quantity <= 0} class="warning_inline"{/if}>

{l s='This product is no longer in stock'}

</span>

</p>

{/if}

{/if}

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

  • 6 months later...

Hey,

 

Did you find any solution by yourself so far ?

 

Facing the same issue here, seems it comes from the lack of "out of stock" / "in stock" status in product admin part in the BO (quantities) when the product has different versions... It's trcicky because we can't ask to the client to fill these fields for EACH product as they have plenty of referencies...

 

Maybe I'll had default values in product class but I wonder if Ajax will work then when the visitor will chose different itemisation on the product... I think i'm fu**ed !

Link to comment
Share on other sites

Hi again,

 

As usual with Prestashop it's easy to fix but not obvious to find !

 

First of all in your product.tpl you need to assign default values to "avalaibleNowValue" and "availableLaterValue" because there is a test on it in product.js. If you don't want to add a stock message for each and every product on your admin you have to assign thet var:

var availableNowValue = '{if $product->available_now !== ''}{$product->available_now|escape:'quotes':'UTF-8'}{else}{l s="Available, delivered within 24 hours"}{/if}';
var availableLaterValue = '{if $product->available_later !== ''}{$product->available_later|escape:'quotes':'UTF-8'}{else}{l s="Not Available, delivered within one week"}{/if}';

Then you have to change your js to display your message depending on the quantity available for the dedicated itemisation. All informations about quantities are already set up in prestahop and the ajax works well, so in prestashop 1.5.5.0 line 173 (in test to check the availability of the itemisation) put something like this (adapt it to your template):

 

if (availableNowValue != '')
{
//update the availability statut of the product
$('#availability_value').removeClass('warning_inline');
$('#availability_value').text(availableNowValue);
$('#availability_label').removeClass('no-stock');
$('#availability_label').addClass('ok-stock');
if(stock_management == 1)
$('#availability_statut:hidden').show();
}

 And line 270 (the 'else' condition of itemisation availibility):

 

if (availableLaterValue != '')
{
$('#availability_value').text(availableLaterValue);
$('#availability_label').removeClass('ok-stock');
$('#availability_label').addClass('no-stock');
if(stock_management == 1)
$('#availability_statut:hidden').show('slow');
}

So it wont hide your stock status but display the message you want !

 

Hope it will helps people who are looking for the same thing later !

 

Bye

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