View availability message on summary page Cart - prestashop-1.7

I want to display the availability message on the basket summary page.
In a normal product page the code {$product.availability_message} works just fine, and the message changes depending on availability.
But if i use {$product.availability_message} in cart-detailed-product-line.tpl it displays the same message no matter if the product is in stock or not.
Anyone know how to achieve this in Prestashop 1.7x ? I have searched online for hours without any results.

{$availability_message} show the message when the product in stock if not you have to use {$product.available_later} so to work fine with that if product in stock show {$product.availability_message} if not show {$product.available_later} like that :
{if $product.availability == 'available'}
{$product.availability_message}
{else}
{$product.available_later}
{/if}
OR :
{if $product.stock_quantity > 0 } {$product.availability_message} {else} {$product.available_later} {/if}

Related

Magento 2: Get Simple Product's Price?

I've been building a Magento 2 template however I've hit a roadblock with the way I'm pulling the prices. The prices are being pulled correctly for simple products by using the following (simplified as I'm exploding the variable to split the string):
$price = $product->getPrice();
<p><?php echo $price; ?></p>
Due to Magento 2 changing the way it processes the prices of configurable products, the price is being outputted as 0.00 for configurables and not pulling the price of the simple products that are attached to it. This was to be expected because I'm not telling it to pull the price of the simple products.
What's the best way for me to get the prices of the simple products? There's a size dropdown on the configurable so ideally, the price would change depending on which product you click on in the dropdown.
Due to me having to explode the price string, I can't just call the block in the XML file either unless I write an overkill jQuery script to split the string on the browser...
Thanks!
Try this code it will help you.
if($product->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE){
$product->getFinalPrice();
}
else
{
echo $product->getPrice();
}
in your block phtml file you can just use
<?php
$_product = $this->getProduct();
echo $_product->getFinalPrice();
?>
it should show you final price,it work with simple and bundle products

Speciale price Magento

I have set a speciale price for a product in the backend but when I go to the product page the price appears and then off again. Also in the cart it's not display.
See link what I mean : Link
After seeing your code, find this on line 177:
<?php echo $priceProperties; ?>
And replace with this :
echo Mage::getModel('catalogrule/rule')->calcProductPriceRule($_product,$_product->getPrice());
I believe your theme doesn't take into account the discount. This would be a bug with the theme development.
This is untested (as I don't have full access to your theme) code so let me know if you have any trouble.

Magento "Please specify the product's option(s)" message remains after completing add to cart after initially clicking "Add to Cart" on category page

Sequence is that customer clicks "Add to Cart" button for a configurable product on the category page. As expected, customer is taken to product page with a notification message to "Please specify the product's option(s)." All good. Problem is that once the options have been selected and the customer clicks "Add to Cart" on the product page, the "Please specify the product's option(s)" message re-appears along with a message indicating the product was successfully added to the cart. Confusing for customer, who has to go into cart to be sure they added it successfully.
I've only found the problem described in one other forum post (http://www.magentocommerce.com/boards/viewthread/298926/), but it's unanswered.
A few thoughts:
I have the "After Adding a Product Redirect to Shopping Cart" config setting for the site set to No. Really don't want customers going back and forth to the cart like that--too interruptive to shopping.
It seems to have to do with the URL, which is appended with a "?options=cart" variable both when customer first goes into product page (correct behavior) and after reloading page when successfully adding product to cart (seemingly incorrect behavior).
I've considered tweaking the code to strip the "?options=cart" part of the URL after Add to Cart is hit on the product page, but I figured I'd check with the Internet and see if I can avoid that work. Seems like I'm missing something simple (or I've stumbled upon a bug).
Not a huge problem, but definitely confusing for the end user. Any ideas?
If anyone else encounters this problem in the future, here's the fix. I know that there is a better way to overwrite core Magento php files, but the quick and dirty way is to alter the _goBack() function within app/code/core/Mage/Checkout/controllers/CartController.php. This begins at line 74, approximately.
Change the following from...
elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
&& !$this->getRequest()->getParam('in_cart')
&& $backUrl = $this->_getRefererUrl()
) {
$this->getResponse()->setRedirect($backUrl);
}
...to...
elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
&& !$this->getRequest()->getParam('in_cart')
&& $backUrl = $this->_getRefererUrl()
) {
if (strstr($backUrl,'?options=cart')) $backUrl = str_replace('?options=cart', '', $backUrl);
$this->getResponse()->setRedirect($backUrl);
}
Why on Earth this is not default functionality is beyond me.
Had the same problem today. I couldn't edit an order because of the "Please specify the product's option(s)." message.
I checked logs and found one product which stop the operation. Problem was in configurable product at tab Custom Options. I've deleted all of the options there and now everything is OK.

Static Block for specific products in magento

Is there any way to do this :
I have two kinds of products, Handmade and ready women accessories. for handmade products I want a block under the price that tell the customer "This Product is 100% Handmade" and for the ready product nothing. So it will be only for the Handmade.
I already have a block but it is visible to all products, so I want it to be visible only for Handmade products.
Any Ideas ?
Can you not create an attribute specifically for the Handmade products? e.g the attribute could be called 'IsHandmade'.
Then on your product page (view.phtml) under the price have something like this?:
<?php if ($product->getIsHandMade == 'Yes'):
echo 'This Product is 100% Handmade';
endif; ?>

Magento : Availability of configurable products on Cart page

I want to show Stock Availability on cart page in magento for a configurable products.
The stock status is fine on Product Detail page, however on cart page it always shows "out of stock" for configurable product. I can understand what the reason is, the inventory of the configurable product itself is set to 0. However on a product detail page it does show "In Stock" because the child products are "In Stock". But if I want to check the availability on Cart page, it always shows "Out of Stock".
Below is the code how I want to achieve the Stock Availability on a Cart page.
<?php
$thisProduct = Mage::getModel('catalog/product')->load($_item->getId());
if($thisProduct->isAvailable()):
echo $this->__('In stock');
else:
echo $this->__('Out of stock');
endif;
?>
You can try with: isSaleable() method instead.
Let me know if that works for you.
Thanks
In the path template\checkout\cart\item\default.phtml use the below code to check product availability
$_item->getProduct()->isSaleable() or else when you got $_item = $this->getItem(); object
Hope it may helps

Resources