Disable shipping method based on zip, how to get zip in tpl - prestashop

I have a shipping method with a certain name. If the zip code of the delivery address is NOT 1234, the selection of that shipping method should be disabled.
I think this could be done within themes\classic\templates\checkout_partials\steps\shipping.tpl with adding a smarty tag:
<div class="col-xs-12 carriere-name-container{if $carrier.logo} col-md-8{/if}">
<span class="h6 carrier-name {if $address.zip == 1234}not-allowed{/if}">{$carrier.name} </span>
</div>
However, I'm unsure how to get the ZIP code exactly in the tag.
Thanks

Put {debug} on tpl's top and you will watch available tpl_vars.

Related

Trouble Displaying a Product's Price in Stencil Conditional Statement

I'm using the Cornerstone theme in BigCommerce. On my product page, I need to hide pricing unless the end user is logged in. BigCommerce has this feature, but it's all or nothing and I only want to restrict certain items from displaying their price. I am using a custom field at the product level named HidePrice. This custom field has either a True or False defined for each product on my site. There are three conditions I need to account for...
The end user is logged in: Display the price regardless of what the HidePrice value is
The product's HidePrice value = false: Display the product's price
The product's HidePrice value = true and the end user is NOT logged in: Suppress the product's price and display an alternate "Too low to show" message.
Here's my code that isn't quite working...
<div class="productView-price">
{{#if customer}}
{{#if product.can_purchase}}
<p class="productView-price">
<span>Price: {{product.price.without_tax.value}}</span>
</p>
{{/if}}
{{else}}
{{#filter product.custom_fields 'HidePrice' property='name' }}
{{#if (toLowerCase value) '==' 'true'}}
<div class="too-low-to-show">This product is priced too low to show!</div>
{{else}}
<p class="productView-price">
<span>Price: {{product.price.without_tax.value}}</span>
</p>
{{/if}}
{{/filter}}
{{/if}}
</div>
The piece I can't seem to get working is condition #1 above (The product's HidePrice value = false: Display the product's price). Conditions #2 & #3 work just fine but the price simply never displays when the requirements of condition #1 are met. Oddly, the "Price:" label I've pre-pended just before the price handlebar will display but the price handlebar itself seems to be ignored by BigCommerce. I have found that if I use the same price handlebar outside of my conditional statement, it will render on the page. I'm baffled by this one. Any help would be greatly appreciated. Thanks!
I believe the issue here is simply scope. Once you enter the filter condition, you have left the global scope and entered the product.custom_fields scope. You no longer have access to the product object. A simple fix for this should be to go back up a level by appending "../" in front of product.price.
<div class="productView-price">
{{#if customer}}
{{#if product.can_purchase}}
<p class="productView-price">
<span>Price: {{product.price.without_tax.value}}</span>
</p>
{{/if}}
{{else}}
{{#filter product.custom_fields 'HidePrice' property='name' }}
{{#if (toLowerCase value) '==' 'true'}}
<div class="too-low-to-show">This product is priced too low to show!</div>
{{else}}
<p class="productView-price">
<span>Price: {{../product.price.without_tax.value}}</span>
</p>
{{/if}}
{{/filter}}
{{/if}}
</div>

(Prestashop 1.7) Show shipping costs only after country address is added

Do you know how to add and show shipping costs in checkout summary, ONLY after an address (with county) is added/selected, on Prestashop 1.7.6?
Is it possible?
You make your country have county as requirement.
You edit the corresponding .tpl (which serves the shipping cost)
{if !isset($address)}
<span class="alert alert-warning">
{l s='Choose address to see the shipping cost'}
</span>
{else}
{* Here the actual content *}
{/if}
Regards,
Konstantinos A. Kogkalidis

Shopify Where to Setup Returns Texts

Where in the admin panel can I setup some kind of product returns text and then call it in the product.liquid template?
I've setup a new tab for the product description now I need to find a way to setup and pull the returns text information.
<div class="tabs">
{% if product.description.size > 0 %}
<div class="tab" id="product-description-tab">
<div class="tab-title">Description</div>
<div class="tab-content">
{{ product.description }}
</div>
</div>
{% endif %}
</div>
So to answer question, if content is always the same for all products:
First solution, you may use a page content :
Create a page with needed content
Add theme option allowing theme user to choose the page content to display
Retrieve settings to display page content wherever you need in your product template - To do it clean, add a condition to display nothing if settings value is empty.
Second solution:
Create theme setting with textarea type
Retrieve setting to display content wherever you want in your product template
Add a condition to display nothing if setting value is blank.
Documentation about settings_schema.json is available here: https://help.shopify.com/themes/development/theme-editor/settings-schema
HTH

Test the rendering of HTML and CSS

I need to test if the following HTML code and the CSS of that page results into a red and line-through price like:
<div class="listOldPrice">
<span>
<span class="wasPriceEuroDestination">€ </span>
719.
<b>-</b>
</span>
</div>
Can I do that with Selenium? How?
This is the Ruby solution:
price = #driver.find_element(:class, 'wasPriceEuroDestination')
assert_equal(true, price.displayed?)
assert_equal("rgba(255, 0, 0, 1)", price.css_value('color'))
assert_equal("line-through", price.css_value('text-decoration'))
That is usually handled by a class. Since classes aren't the prettiest to match on since they aren't very unique, it's difficult to give you a complete selector, but i'll put some placeholders in:
In Java, you could do something like:
assertTrue(driver.findElement(By.cssSelector("div#someParentOfThatPrice div.listOldPrice")).isDisplayed());
If this test fails, that means that it can't find the element, ergo, it's not crossed out.

Retrieve 5th item's price value using selenium webdriver

Say I have multiple price quotes from multiple retailers, how will I retrieve the 5th value from a particular retailer - say Target or Walmart ? I can get to the 5th entry using the matching image logo bit how do I retrieve the value ?
Adding Html Code to make things more clear .I need to retrieve the ratePrice value (198)
<div id="rate-297" class="rateResult standardResult" vendor="15">
<div class="rateDetails">
<h4>Standard Goods
<br>
<img src="http://walmart.com/walmart/ZEUSSTAR999.jpg">
</h4>
<p>
<span class="vendorPart-380">
<img alt="Walmart" src="/cb2048547924/icons/15.gif">
<br>
<strong>
<br>
MNC
</span>
</p>
</div>
<div class="ratePrice">
<h3>
$198
<sup>49</sup>
</h3>
<p>
<strong>$754.49</strong>
<br>
</p>
<a class="button-select" href="https://www.walmart.com/us/order/95134/2013-05-14-10-00/95134/2013-05-17-10-00/297"> </a>
</div>
</div>
If you could provide some HTML it would help. Speaking generally from what you're asking you'd get a locator to the price div or whatever HTML element and then get its text using something like:
_driver.FindElement(locator_of_element).Text
The trick is understanding the HTML in order to target the 5th element. So if you can find the row that has the 5th entry then it's simply a matter or then finding the price div in that row and getting the text of it.
EDIT based on more info provided by OP in comments
Using the HTML you provided (which isn't well formed by the way, missing closing strong tag, a tag, etc.). I'd say do the following:
_driver.FindElement(By.XPath("//div[#class='ratePrice'][5]/h3")).Text