Jump to content

BUG? available_date not shown on product page


Recommended Posts

I am not seeing the usefulness of the available_date field (other than for internal use)

Is there a way to show this on the product page?

 

For instance, if you have a product that is out of stock, but want to give customers the option to go ahead and pre-order it, it would be useful to show the expected delivery date.

 

Any thoughts on how to achieve this? 

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

I almost have it. I added this code:

 <p {if ($product->quantity <= 0 && !$product->available_later && $allow_oosp) OR ($product->quantity > 0 && !$product->available_now) OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if} class="availability statut in-stock" >{l s='Estimated Arrival:'}<span>{$product->available_date}</span></p>

However, it displays a date of 0000-00-00

Here is the item I am testing if it helps:

http://www.whispardesign.com/chandeliers/646-aubree-6-light-chandelier#/-

 

The only place the date does show correctly is on products that are IN STOCK. I only want the estimated arrival string to show if back-orders are allowed - NOT when items are currently in stock.

 

and yes, my setting allow ordering items out of stock.

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

Thanks for the reply fishordog

Yes, I know that but the resulting date is not showing on the product page. Also for combinations, the date is in the combinations tab.

I have always these filled out but not displaying. My workaround had been to change the text field for "if out of stock" but that takes too much time. 

 

Basically I just need the code for this date to display if a product is out of stock but is able to be ordered.

Link to comment
Share on other sites

I took a look at a copy of PS 1.5.6.2 and I could not get the date to show at all with my TM template. I then looked at PS 1.6.0.6 and it worked fine with and without combinations.

 

I also looked at the code in product.tpl from PS 1.6 and copied the code from that template to my TM PS 1.5 product.tpl

<span id="availability_date_label">{l s='Availability date:'}</span>
<span id="availability_date_value">{dateFormat date=$product->available_date full=false}</span>

After that it produced the behavior you describe. It works only without combinations. That's as far as I have got with it.

Link to comment
Share on other sites

Thanks Bill - Good to see you around! I tried this code latest but still not showing for combinations. Just not sure what is missing as to why it won't pull data from combinations.

<!-- availability -->
                        <p {if ($product->quantity <= 0 && !$product->available_later && $allow_oosp) OR ($product->quantity > 0 && !$product->available_now) OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if} class="availability statut in-stock" >{l s='Availability:'} 
                           <span id="availability_value"{if $product->quantity <= 0} class="warning_inline"{/if}>
                            {if $product->quantity <= 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->available_now}{/if}
                        </span></p>
	 <p id="availability_date"{if !$product->available_for_order OR $PS_CATALOG_MODE OR !isset($product->available_date) OR $product->available_date < $smarty.now|date_format:'%Y-%m-%d'} style="display: none;"{/if}>
	<span id="availability_date_label">{l s='Availability date:'}</span>
	<span id="availability_date_value">{dateFormat date=$product->available_date full=false}</span>
   </p>
Link to comment
Share on other sites

Going forward, as I understand it, Prestashop was not going to make anymore changes to PS 1.5X, however they have decided to add some new stuff from that vote for 1.5 fixes. Unfortunately this particular problem is not going to be fixed in PS1.5x, as far as I know. So that means we need to figure this out on our own. You and I are not programmers, but I think you know your way around code better than I do. In fact I know you do. :)

 

Hopefully someone may help us, and I'd like to see this fixed. It does seem to work well in PS 1.6x so hopefully that may help guide us.

Link to comment
Share on other sites

You are too kind. I know enough about code to be dangerous - that is about it :)

 

I am beginning to think, as much as we need combinations, they are a curse because I also have an issue updating inventory automatically because of the way products with combinations and without are treated differently in the database. I have yet to find a way to efficiently upload a csv that will update quantities on all products. This is a deathblow to any ecommerce store.

 

Hopefully you are right that someone more talented with code see what the problem is and offer a decent solution. I'll keep trying until then and post if I get anywhere.

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

Okay - getting closer. This code results in these results for products with attributes and products without attributes: Now I get the "availability date" label but a date code or 0000-00-00

<span id="availability_date_label">{l s='Availability date:'}</span>
<span id="availability_date_value">{$product->available_date}</span>

In the BO, what is the link between the availability date entered in "quantities" for items without combinations and availability date entered in "combinations" for items with attributes? This is the issue and I have no clue what the difference is. Must be in a controller or something that is beyond my pay grade.

 

post-463404-0-23243900-1399851917_thumb.jpg

post-463404-0-06315600-1399851918_thumb.jpg

Link to comment
Share on other sites

By George I think we got it, add those two lines right below,

<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if} >{l s='Warning: Last items in stock!'}</p>

So it ends up like this,

<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if} >{l s='Warning: Last items in stock!'}</p>

<P><span id="availability_date_label">{l s='Availability date:'}</span>
<span id="availability_date_value">{dateFormat date=$product->available_date full=false}</span></P>

And it works for me. You can of course move it around to your liking with HTML.

Link to comment
Share on other sites

Using the <p class="warning_inline" is much better visually.

<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if} >{l s='Warning: Last items in stock!'}</p>

<p class="warning_inline" <span id="availability_date_label">{l s='Availability date:'}</span>
<span id="availability_date_value">{dateFormat date=$product->available_date full=false}</span></p>
Link to comment
Share on other sites

Uggg... still nothing... here is my code from availability to number of items in stock (where you suggested adding the lines) Still getting the same result... http://www.whispardesign.com/chandeliers/646-aubree-6-light-chandelier

<!-- availability -->
            <p {if ($product->quantity <= 0 && !$product->available_later && $allow_oosp) OR ($product->quantity > 0 && !$product->available_now) OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if} class="availability statut in-stock" >{l s='Availability:'} 
                 <span id="availability_value"{if $product->quantity <= 0} class="warning_inline"{/if}>
                 {if $product->quantity <= 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->available_now}{/if}
                  </span></p>
			<!-- number of item in stock -->
			{if ($display_qties == 1 && !$PS_CATALOG_MODE && $product->available_for_order)}
			<p id="pQuantityAvailable"{if $product->quantity <= 0} style="display: none;"{/if}>
				<span id="quantityAvailable">{$product->quantity|intval}</span>
				<span {if $product->quantity > 1} style="display: none;"{/if} id="quantityAvailableTxt">{l s='item in stock'}</span>
				<span {if $product->quantity == 1} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'}</span>
			</p>
			{/if}
			<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if} >{l s='Warning: Last items in stock!'}</p>
            <!--Code added for availability date -->
             <P><span id="availability_date_label">{l s='Availability date:'}</span>
				<span id="availability_date_value">{dateFormat date=$product->available_date full=false}</span></P>
Edited by Whispar1 (see edit history)
Link to comment
Share on other sites

I also have some code like this early just after the Variable declarations at the top. Notice the {$combination.available_date}.

 

See also attached product.tpl for caparison.

{if isset($groups)}
	// Combinations
	{foreach from=$combinations key=idCombination item=combination}
		var specific_price_combination = new Array();
		var available_date = new Array();
		specific_price_combination['reduction_percent'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type == 'percentage'}{$combination.specific_price.reduction*100}{else}0{/if};
		specific_price_combination['reduction_price'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type == 'amount'}{$combination.specific_price.reduction}{else}0{/if};
		specific_price_combination['price'] = {if $combination.specific_price AND $combination.specific_price.price}{$combination.specific_price.price}{else}0{/if};
		specific_price_combination['reduction_type'] = '{if $combination.specific_price}{$combination.specific_price.reduction_type}{/if}';
		specific_price_combination['id_product_attribute'] = {if $combination.specific_price}{$combination.specific_price.id_product_attribute|intval}{else}0{/if};
		available_date['date'] = '{$combination.available_date}';
		available_date['date_formatted'] = '{dateFormat date=$combination.available_date full=false}';
		addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity}, available_date, specific_price_combination);
	{/foreach}
{/if}

product.zip

Link to comment
Share on other sites

Thanks Bill - That portion of code is definitely missing from mine. Simply adding it throws an invalid date exception.... I have some digging to do.

{if isset($groups)}
            // Combinations
            {foreach from=$combinations key=idCombination item=combination}
                var specific_price_combination = new Array();
				<!--added var available_date 05/12/2014 -->
				var available_date = new Array();
                specific_price_combination['reduction_percent'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type == 'percentage'}{$combination.specific_price.reduction*100}{else}0{/if};
                specific_price_combination['reduction_price'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type == 'amount'}{$combination.specific_price.reduction}{else}0{/if};
                specific_price_combination['price'] = {if $combination.specific_price AND $combination.specific_price.price}{$combination.specific_price.price}{else}0{/if};
                specific_price_combination['reduction_type'] = '{if $combination.specific_price}{$combination.specific_price.reduction_type}{/if}';
                addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity}, '{$combination.available_date}', specific_price_combination);
            {/foreach}
        {/if}

BTW, here is your tpl back - I added google rich snippets (courtesty of Nemo) All you need to do is make a few changes in product.js  Add:

var re = new RegExp("\\"+currencySign, "g");
var signRemoved = our_price.replace(re, "");

above:

$('#our_price_display').text(signRemoved);

to get rid of the double dollar signs.

product.tpl.zip

  • Like 1
Link to comment
Share on other sites

Cool. :)  That's great. This site isn't live yet, and I thank you, one less thing on the list. Shout out to Nemo, http://nemops.com/ one of the best Prestashop web sites EVER.

 

If you actually use my product page will the page load? I realize it would break the theme, but if it loads it would be interesting to know if that function survived as well.

  • Like 1
Link to comment
Share on other sites

Actually, after more testing it is only partially working.

 

It works as expected if a combination is sold out, but when I choose the color that is in stock, the available date from the item out of stock displays. So ... back to the drawing board.

 

post-358011-0-73704700-1399933807_thumb.jpg

post-358011-0-80321300-1399933949_thumb.jpg

Link to comment
Share on other sites

Ok, had another look, and the code is working, the only thing causing the error was using <p class="warning_inline". For some reason that caused the date to appear regardless if the product was in stock. Once removed it works perfectly.

 

I ended up copying 3 lines from PS 1.6

<p id="availability_date"{if ($product->quantity > 0) || !$product->available_for_order || $PS_CATALOG_MODE || !isset($product->available_date) || $product->available_date < $smarty.now|date_format:'%Y-%m-%d'} style="display: none;"{/if}>
<span id="availability_date_label">{l s='Availability date:'}</span>
<span id="availability_date_value">{dateFormat date=$product->available_date full=false}</span>

I placed it just below line 315 in my product.tpl

<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if} >{l s='Warning: Last items in stock!'}</p>
  • Like 1
Link to comment
Share on other sites

Thanks for trying on this Bill.... I am trying to take it step by step.... once I add this code:

available_date['date_formatted'] = '{dateFormat date=$combination.available_date full=false}'; 

I get this:

616.
617.         if ($date == '0000-00-00 00:00:00' || $date == '0000-00-00')
618.             return '';
619.
620.         if (!Validate::isDate($date) || !Validate::isBool($full))
621.             throw new PrestaShopException('Invalid date');
622.
623.         $context = Context::getContext();
624.         $date_format = ($full ? $context->language->date_format_full : $context->language->date_format_lite);
625.         return date($date_format, $time);
626.     }

I've attached my tpl file - only mod so far is adding two lines from your tpl at line 131 and 137.

Adding available_date['date_formatted'] = '{dateFormat date=$combination.available_date full=false}'; stops me in my tracks as seen above.

 

I still have my original code down at 393 because it at least gives me the text "availabiity date" in the FO

<span id="availability_date_label">{l s='Availability date:'}</span>
<span id="availability_date_value">{dateFormat date=$product->available_date full=false}</span>
Link to comment
Share on other sites

Well it was a good try - thanks for the effort Bill For some reason it does not like the date format at all.... so close!

Invalid date
at line 622 in file classes/Tools.php

616. 
617. 		if ($date == '0000-00-00 00:00:00' || $date == '0000-00-00')
618. 			return '';
619. 
620. 		if (!Validate::isDate($date) || !Validate::isBool($full))
621. 			throw new PrestaShopException('Invalid date');
622. 
623. 		$context = Context::getContext();
624. 		$date_format = ($full ? $context->language->date_format_full : $context->language->date_format_lite);
625. 		return date($date_format, $time);
626. 	}
Link to comment
Share on other sites

My theme developer has also been working on this. He switched to default 1.5.3.1 theme and also tried 1.5.4

Nothing worked. 1.5.4 did work on a standalone so he thinks it is a core issue. I will comment out that line and see what happens - if not I guess it's a dead issue because I will never be able to find what core issue is causing this.

Link to comment
Share on other sites

The module that has been a big help to me is "Test Site Creator" by presto-changeo.com.

 

http://www.presto-changeo.com/en/105-test-site-creator.html

 

You can create a new database for your test sites or it will use your existing database and use different table prefixes. I realize if you know what to do you can easily replicate the work this module does in setting up a test site. But you will not do it as quickly or as easily as it becomes with this module. In seconds you have a complete and exact  copy of your web site in a sub folder and its all set to go at that address. You can then upgrade your PS and work out the kinks. Something goes wrong ... no problem, just create a new test site in seconds and try, try again.

 

Presto-changeo, you're welcome. :)

 

I now return you to your regular broadcast.

Link to comment
Share on other sites

×
×
  • Create New...