variant & price load in shopify - ajax

Product price for default variant is working.When i change variant "Inc VAT" is not changing automatically.
I want to change product price automatically, when i will change variant of a product. See the store-
https://woodies-timber.myshopify.com/products/bendi-ply-long-grain
<div class="price dvt-vat">
{%- include 'limited-offer' -%}
<div id="price">
{%- if product.available -%}
<span class="price-new money">{{current_variant.price | money}}</span>
{%- if current_variant.compare_at_price > current_variant.price -%}
<span class="price-old money">{{current_variant.compare_at_price | money}}</span>
{%- endif -%}
{%- else -%}
<span class="price-old">{{'products.product.sold_out' | t}}</span>
{%- endif -%}
</div>
<span class="exl-vat">Exl VAT</span>
{% assign dvt_price = current_variant.price %}
{% assign dvt_price_prat = current_variant.price | times :20 | divided_by :100 | plus: current_variant.price | money %}
<br>
<span class="price-new money dvt_price_totlal">{{ dvt_price_prat }}</span>
<span class="exl-vat">Inc VAT</span>
</div>

Related

Shopify Drop-Down Menu : Show collection product count

i am working on a Shopify Store here and need to display the product count for each collection in the drop-down sub-menu and somehow I can not figure it out. The documentation is a little bit light on this issue.
I need the product count to be shown only in the sub-menus.
I tried adding the code below but it snot working:
{% if childlink.type == 'collection_link' %}
({{ childlink.object.products_count }})
{%endif%}
Can anyone help me out with this? Below is my code:
<div class="dropdown-menu">
<div class="row tt-col-list">
<div class="col">
<ul class="tt-megamenu-submenu tt-megamenu-preview">
{%- for child_level_2 in level_2.links -%}
<li><span>{{ child_level_2.title }} </span>
{%- capture return -%}{%- include "get_linklist_dropdown", link: child_level_2 -%}{%- endcapture -%}{%- assign return = return | split: "%%" -%}{%- assign has_drop_down = return | first | strip -%}{%- assign child_list_handle = return | last | strip -%}
{%- assign level_3 = linklists[child_list_handle] -%}
{%- if level_3.empty? -%}
{%- assign child_list_handle = child_level_2.title | handle -%}
{%- assign level_3 = linklists[child_list_handle] -%}
{%- endif -%}
{%- if level_3.links != blank -%}
<ul>
{%- for child_level_3 in level_3.links -%}
<li>
<span>{{ child_level_3.title }}</span>
{%- capture return -%}{%- include "get_linklist_dropdown", link: child_level_3 -%}{%- endcapture -%}{%- assign return = return | split: "%%" -%}{%- assign has_drop_down = return | first | strip -%}{%- assign child_list_handle = return | last | strip -%}
{%- assign level_4 = linklists[child_list_handle] -%}
{%- if level_4.empty? -%}
{%- assign child_list_handle = child_level_3.title | handle -%}
{%- assign level_4 = linklists[child_list_handle] -%}
{%- endif -%}
{%- if level_4.links != blank -%}
<ul>
{%- for child_level_4 in level_4.links -%}
<li>
<span>{{ child_level_4.title }}</span>
{%- capture return -%}{%- include "get_linklist_dropdown", link: child_level_4 -%}{%- endcapture -%}{%- assign return = return | split: "%%" -%}{%- assign has_drop_down = return | first | strip -%}{%- assign child_list_handle = return | last | strip -%}
{%- if has_drop_down == "true" -%}
{%- assign level_5 = linklists[child_list_handle] -%}
{%- unless level_5.empty? -%}
<ul>
{%- for child_level_5 in level_5.links -%}
<li>{{ child_level_5.title }}</li>
{%- endfor -%}
</ul>
{%- endunless -%}
{%- endif -%}
</li>
{%- endfor -%}
</ul>
{%- endif -%}
</li>
{%- endfor -%}
</ul>
{%- endif -%}
</li>
{%- endfor -%}
</ul>
</div>
</div>
</div>
</pre>

Transform Jekyll "reading time" into "page rating calculation"

I want to transform following Jekyll "reading time" calculator
<span class="reading-time">
{% capture words %}
{{ content | number_of_words | minus: 180 }}
{% endcapture %}
{% unless words contains “-” %}
{{ words | plus: 180 | divided_by: 180 |
append: “minutes to read” }}
{% endunless %}
</span>
into "page rating" with the following meta taken from page Front matter using following formula
{{ page.facebook }}
plus
{{ page.instagram }}
multiply
{{ page.age }}
divide
1000 000
multiply {{ content | number_of_words }}
divide
100 =
More details here
This can do the trick :
{% assign number_of_words = content | strip_html | number_of_words %}
{% assign social = page.facebook | plus: page.instagram %}
{% comment %}Two lines for readability, but can be chained on one line{% endcomment %}
{% assign Indexmod = social | times: page.age | divided_by: 1000000.0 %}
{% assign Indexmod = Indexmod | times: number_of_words | divided_by: 100 %}
Note :
the use of strip_html, this avoid counting html as words.
the use of 'divided_by: 1000000.0' to cast result to a Float

how do I concat page variables in jekyll loops

I'm accessing a page variable in a jekyll loop like below:
```ruby
{% assign kind = page.categories | first %}
{% for post in site.categories.[kind] | limit: 5 %}
{% unless post.url == page.url %}
<a href="{{ site.baseurl }}{{ post.url }}" class = 'post-url'>
<img src = '{{ site.baseurl }}/assets/{{ post.image }}.jpg>
<h2 itemprop="name headline">{{ page.title | escape }}</h2>
<time >{{ post.date | date: date_format }}</time>
</a>
{% endunless %}
{% endfor %}
```
Although the page builds successfully it outputs an error saying Expected page id but found open_square in "post in site.categories.[kind] | limit: 5"
How can I avoid this add still be able to use the page.categories | first variable?
Use site.categories[kind] instead of site.categories.[kind]
There shouldn't be any dot after "categories"

Jekyll custom date

I want use bellow code to display custom date in my Jekyll site
{% assign m = page.date | date: "%-m" %}
{% case m %}
{% when '1' %}Januar
{% when '2' %}Februar
{% when '3' %}März
{% when '4' %}April
{% when '5' %}Mai
{% when '6' %}Juni
{% when '7' %}Juli
{% when '8' %}August
{% when '9' %}September
{% when '10' %}Oktober
{% when '11' %}November
{% when '12' %}Dezember
{% endcase %}
But I don't now where to put it (I tried in post.html but does not work)
I've made a template for this.
This template translate a date in a specific language. Here it's french but feel free to change month and day arrays.
This template can be used in an enumeration of post/page (eg: the index page) or in a post/page template.
When used in an enumeration, you need to pass the date to process
{% for post in site.posts %}
<li>
<span class="post-date">{% include custom_date_full_fr.html date = post.date %}</span>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</li>
{% endfor %}
Where used in a page/post template, you just have to include the template, as the page.date will already be available.
{% include custom_date_full_fr.html %}
custom_date_full_fr.html
{% if include.date %}
{% assign processed_date = include.date %}
{% else if page.date %}
{% assign processed_date = page.date %}
{% endif %}
{% comment %}-------- Test if we have a date to process --------{% endcomment %}
{% if processed_date %}
{% assign month = "janvier,février,mars,avril,mai,juin,juillet,août,septembre,octobre,novembre,décembre" | split: "," %}
{% comment %}------ Note : sunday is the first day in this array -------{% endcomment %}
{% assign day = "dimanche,lundi,mardi,mercredi,jeudi,vendredi,samedi" | split: "," %}
{% assign month_index = processed_date | date: "%m" | minus: 1 %}
{%comment%}----------------------------------------------
Here **minus: 0** is a trick to convert day_index from string to integer and then use it as an array index.
----------------------------------------------{%endcomment%}
{% assign day_index = processed_date | date: "%w" | minus: 0 %}
{%comment%}-------- Output the date ----------{%endcomment%}
{{ day[day_index] }} {{ processed_date | date: "%d" }} {{ month[month_index] }} {{ processed_date | date: "%Y" }}
{% endif %}
See here for more info :
Jekyll Date Formatting Examples by Alan W. Smith
Liquid documentation - date filters

jekyll shared template different parameters

I am trying to share a single template in 2 other templates as follows:
_layouts/V2/post.slim
{% include V2/date_wrapper.html date_value=page.date %}
and
_includes/V2/footer/recent_posts.slim
| {% for post in site.posts limit: 5 %}
| <div class="w-bloglist-entry">
| <a class="w-bloglist-entry-link" href="{{ post.url }}">{{ post.title }}</a>
| <span class="w-bloglist-entry-date">
| <i class="fa fa-clock-o"></i>
| {% include V2/date_wrapper.html date_value=post.date %}
| </span>
| </div>
| {% endfor %}
This is the shared template:
_includes/V2/date_wrapper.html
{% assign d = include.date_value | date: "%-d" %}
{{ include.date_value | date: "%B" }}
{% case d %}
{% when '1' or '21' or '31' %}{{ d }}st,
{% when '2' or '22' %}{{ d }}nd,
{% when '3' or '23' %}{{ d }}rd,
{% else %}{{ d }}th,{% endcase %} {{ include.date_value | date: "%Y" }}
If I set this up using the template only in the post it works, however, no matter what I try I can not seem to get this to work in the footer in the for loop. The error is:
Liquid Exception: undefined method `data' for #<Jekyll::SlimPartialTag:0x007ffa549315b0> in _layouts/V2/post.slim
14:47:34 - ERROR - Jekyll build has failed
Thoughts? Is this possible in Jekyll?

Resources