Shopify Ajax Update Cart - shopify

I want to be able to update my cart when I click on the increase button without having to click update button
Here is my script
<script>
let classlist = []
let val = document.querySelector('.qty-select')
let classes = document.getElementsByClassName('val')
for (var i=0; i<classes.length; i++) {
classlist.push(classes[i].innerText)
}
let lineclasses = classlist.join(", ")
val.onclick = function() {
jQuery.post('/cart/update.js', {updates: [lineclasses]});
console.log('dfdfdfd')
}
</script>
Here is my Liquid
{% for item in cart.items %}
<div class="product row">
<div class="col-lg-2 col-md-3 col-sm-4">
<img src="{{ item | img_url: 'medium' }}" />
</div>
<div class="col-lg-8 col-md-8 col-sm-7 product-info">
<div class="product-title">
{{ item.product.title }}
<span class="price right"><b>{{ item.price | money }}</b></span>
</div>
<div class="qty-select">
<input type="number" hidden="hidden" name="updates[]" id="updates_{{ item.key }}" class="qty"
value="{{ item.quantity }}" min="0" />
<span class="val">{{ item.quantity }}</span>
</div>
</div>
<div class="col-lg-2 col-md-1 col-sm-1 text-right remove">
<a aria-label="Remove {{ item.variant.title }}"
href="/cart/change?line={{ forloop.index }}&quantity=0"><i class="fas fa-times"></i></a>
</div>
</div>
{% endfor %}
I have tried this, but its not working

Related

HubSpot custom module to display data from hubdb and search filter

I'm trying to create a custom module in HubSpot to display data from hubdb and i also to make a search filter so that users can search for some specific info on the pay but i'm having some issue with the filter. Could anyone assist me? Below is my code so far.
Here is my hubDB Table column (i'm using dynamic pages):
| hs_name | hs_path | title | decription | country | date | location | language | image | url |
search filter screenshot and Display of the data screenshot
<div class="container mt-5 filter">
<div class="row">
<div class="col-md-6 mt-0 filter-search" style="text-align: left;">
<input type="text" id="myInput" placeholder="Search..." />
</div>
<div class="col-sm-2 filter-section">
<select class="country">
<option value="all">All Country</option>
<option value="UK"> UK </option>
<option value="BE"> Belgium </option>
</select>
</div>
<div class="col-sm-2 filter-section">
<select class="language">
<option value="all">Language</option>
<option value="English"> English </option>
<option value="French"> French</option>
</select>
</div>
<div class="col-sm-2 filter-section">
<select class="tags">
<option value="all">Tags</option>
<option value="Virtual">Virtual</option>
<option value="Physical">Physical</option>
</select>
</div>
</div>
</div>
<div class="container FilterContainer mt-5">
{% set current_dt = unixtimestamp( local_dt ) %}
  {% set query = "date__lt="~current_dt~"&orderBy=-date" %}
  {% set table = hubdb_table_rows(<hubdbTableId>, query) %}
{% for row in table %}
<div class="card column" data-country="{{ row.country == "BE" }}" data-language="{{ row.language == "English" }}" data-tag="{{ row.country == "Virtual" }}">
<div class="row no-gutters">
<div class="col-md-4">
<img src="{{ row.image.url }}" alt="Banner" class="img-fluid h-100" />
</div>
<div class="col-md-6">
<div class="card-body">
<p class="card-text">
<span class="badge badge-pill">{{ row.country }}</span>
<span class="badge badge-pill"> <i class="fa fa-calendar"></i> {{ row.date|datetimeformat(('%B %e, %Y')) }}</span>
<span class="badge">{{ row.location }}</span>
<span class="badge badge-pill">{{ row.language }}</span>
</p>
<h5 class="card-title"><strong>
{{ row.title }}</strong></h5>
<p><strong>Decription: </strong>{{ row.decription }}</p>
</div>
</div>
<div class="event-detail-border"></div>
<div class="col-md-2 btn-body">
Read More
</div>
</div>
</div>
{% endfor %}
</div>
<script>
$("select.country, select.language, select.tags").change(updateEvents);
$("#myInput").on("keyup", updateEvents);
function updateEvents() {
var country = $('select.country').val();
var language = $('select.language').val();
var tags = $('select.tags').val();
var search = $("#myInput").val();
$('.FilterContainer')
.find('.column')
.hide()
.filter(function() {
var okCountry = true;
var okLanguage = true;
var okTags = true;
var okSearch = true;
if (country !== "all") {
okCountry = $(this).attr('data-country') === country;
}
if (language !== "all") {
okLanguage = $(this).attr('data-language') === language;
}
if (tags !== "all") {
okTags = $(this).attr('data-teacher') === tags;
}
if (search !== '') {
okSearch = $(this).text().toLowerCase().indexOf(search) > -1;
}
//only fade a room if it satisfies all four conditions
return okCountry && okLanguage && okTags && okSearch;
}).fadeIn('fast');
}
</script>

How to make boxes fields the same size

I'm using HTML and TWIG.
I have different boxes with different fields filled with data retrieved from a php call. The problem is I don't know how to make those fields (and consequently boxes) the same size.
The size of each field should be the tallest one of the group. So far I got this
As you can see, Contratto, JSer and Azienda are fine (usually always on a single line, so it shouldn't be a problem).
The problem is Note: as you can see, it goes well for single box, but having more ones just break the visualization. I'd like all fields to be the same size in their own group:
every Contratto the size of the biggest one;
every JSer the size of the biggest one;
every Azienda the size of the biggest one
and of course, the important one, every Note the size of the biggest one
Here's the code I'm using, with Bootstrap 3.3.7
{% if alerts|length > 0 %}
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> I TUOI AVVISI ({{ alerts|length }})</h3>
</div>
<div class="box-body">
{% for alert in alerts %}
<div class="col-lg-3 col-md-4 col-sm-6">
<div class="shadow-box">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f">Avviso</h3>
</div>
<div class="box-body">
<p><b>Contratto</b>: {{ alert.getJob().getContratto().getRiferimento() }}</p>
<p><b>JSer</b>: {{ alert.getJob().getJobStationer().getNome() }} {{ alert.getJob().getJobStationer().getCognome() }}</p>
<p><b>Azienda</b>: {{ alert.getJob().getAzienda().getNome() }}</p>
<p><b>Note</b>: {{ alert.getJob().getNote() }}</p>
</div>
{% if alert.getUtente() is not null %}
<div class="box-footer" style="text-align: left">
<p><b>Modificato da</b> {{ alert.getUtente().getNome() }} {{ alert.getUtente().getCognome() }} <b>il</b> {{ alert.getDataModifica()|date('d/m/Y') }}</p>
</div>
{% endif %}
<div class="box-footer">
<a href="{{ path('job_dettaglio', { 'id_job': alert.getJob().getId(), 'dettaglio': 1 }) }}"class="link-avviso">
Vai al dettaglio <i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
EDIT: this is the code version with columns and rows
{% if alerts|length > 0 %}
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> I TUOI AVVISI ({{ alerts|length }})</h3>
</div>
<div class="box-body">
{% for alert in alerts %}
<div class="col-lg-3 col-md-4 col-sm-6">
<div class="shadow-box">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f">Avviso</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-sm-12">
<b>Contratto</b>: {{ alert.getJob().getContratto().getRiferimento() }}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<b>JSer</b>: {{ alert.getJob().getJobStationer().getNome() }} {{ alert.getJob().getJobStationer().getCognome() }}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<b>Azienda</b>: {{ alert.getJob().getAzienda().getNome() }}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<b>Note</b>: {{ alert.getJob().getNote() }}</p>
</div>
</div>
</div>
{% if alert.getUtente() is not null %}
<div class="box-footer" style="text-align: left">
<p><b>Modificato da</b> {{ alert.getUtente().getNome() }} {{ alert.getUtente().getCognome() }} <b>il</b> {{ alert.getDataModifica()|date('d/m/Y') }}</p>
</div>
{% endif %}
<div class="box-footer">
<a href="{{ path('job_dettaglio', { 'id_job': alert.getJob().getId(), 'dettaglio': 1 }) }}"class="link-avviso">
Vai al dettaglio <i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
Any suggestion?
EDIT ANSWER:
After few tries, I normalized the single row instead of single fields...single fields would not be the same height, but the row will, so this is actually fine for my final result. Here's the answer:
//CSS in head
.alertProperties {
padding-left:0px !important;
}
//Code
{% if alerts|length > 0 %}
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> I TUOI AVVISI ({{ alerts|length }})</h3>
</div>
<div class="box-body">
{% for alert in alerts %}
{% if loop.index % 5 == 0 or loop.first %}
<div class="row">
{% endif %}
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="box-header with-border"><h3 class="box-title" style="color: #ff000f">Avviso</h3></div>
<div class="box-body" style="border-left: 1px solid #00ACDF !important">
<div class="col-sm-12 alertProperties">
<b>Contratto</b>: {{ alert.getJob().getContratto().getRiferimento() }}
</div>
<div class="col-sm-12 alertProperties">
<b>JSer</b>: {{ alert.getJob().getJobStationer().getNome() }} {{ alert.getJob().getJobStationer().getCognome() }}
</div>
<div class="col-sm-12 alertProperties">
<b>Azienda</b>: {{ alert.getJob().getAzienda().getNome() }}
</div>
<div class="col-sm-12 alertProperties">
<b>Note</b>: {{ alert.getJob().getNote() }}</p>
</div>
{% if alert.getUtente() is not null %}
<div class="box-footer" style="text-align:left;">
<div class="col-sm-12 alertProperties">
<b>Modificato da</b> {{ alert.getUtente().getNome() }} {{ alert.getUtente().getCognome() }} <b>il</b> {{ alert.getDataModifica()|date('d/m/Y') }}
</div>
</div>
{% endif %}
<div class="box-footer">
<div class="col-sm-12">
<a href="{{ path('job_dettaglio', { 'id_job': alert.getJob().getId(), 'dettaglio': 1 }) }}" class="link-avviso">
Vai al dettaglio <i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
</div>
{% if (loop.index % 4 == 0 or loop.last) %}
</div>
{% endif %}
{% endfor %}
</div>
{# </div> #}
</div>
{% endif %}
You can truncate text of the note section by forcing text on the same line with the white-space:none
p{
width:400px;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
However if you wanna truncate it to more than one line you can read it more on chris coyier's article here

Add/Replace EAN13 field on product combinations page

i am trying to replace the "Impact on price (tax excl.)" field with EAN13 field at the product combinations tab because it is easier to scan barcodes and add quantities for all combinations at one page. I chose to replace this field and not add a new one because i will probably never use it.
So far i managed to show the field I want at the place of Impact on Price by modifying form_combination.html.twig file. It reads the EAN13 for products that already have it, but if I try to add or modify EAN13 of a product when I save it i get an error (just save error not a lot of info).
At first i just replaced "Impact on price" with "EAN13" field and when I got this error I thought it was because the impact on price field was missing so I put it where EAN13 was, but still got the save error message. If i delete the EAN13 of a product and try to save it, it works. It just doesn't when I try to add new or replace the existing one. What is wrong with the code?
Here is a pic of where i put the EAN13 field
Below is the original code
<tr class="combination loaded" id="attribute_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}">
<td width="1%"><input class="js-combination" type="checkbox" data-id="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}"></td>
<td class="img"><div class="fake-img"></div></td>
<td>{{ form.vars.value.name }}</td>
<td class="attribute-price">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">{{ default_currency }}</span>
</div>
<input type="text" class="attribute_priceTE form-control text-sm-right" value="{{ form.vars.value.attribute_price }}">
</div>
</td>
which i replaced with
<tr class="combination loaded" id="attribute_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}">
<td width="1%"><input class="js-combination" type="checkbox" data-id="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}"></td>
<td class="img"><div class="fake-img"></div></td>
<td>{{ form.vars.value.name }}</td>
<td class="attribute-price">
<div class="input-group">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_ean13.vars.label }}
</label>
{{ form_errors(form.attribute_ean13) }}
{{ form_widget(form.attribute_ean13) }}
</fieldset>
</div>
</td>
Final code looks like this
{#**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* #author PrestaShop SA and Contributors <contact#prestashop.com>
* #copyright Since 2007 PrestaShop SA and Contributors
* #license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*#}
<tr class="combination loaded" id="attribute_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}">
<td width="1%"><input class="js-combination" type="checkbox" data-id="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}"></td>
<td class="img"><div class="fake-img"></div></td>
<td>{{ form.vars.value.name }}</td>
<td class="attribute-price">
<div class="input-group">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_ean13.vars.label }}
</label>
{{ form_errors(form.attribute_ean13) }}
{{ form_widget(form.attribute_ean13) }}
</fieldset>
</div>
</td>
<td class="attribute-finalprice text-sm-right">
<span data-price="{{ form.vars.value.final_price }}" data-uniqid="{{ form.vars.value.id_product_attribute }}">{{ form.vars.value.final_price }}</span> {{ default_currency }}
</td>
{% if 'PS_STOCK_MANAGEMENT'|configuration %}
<td class="attribute-quantity">
<div>
<input type="text" value="{{ form.vars.value.attribute_quantity }}" class="form-control text-sm-right">
</div>
</td>
{% endif %}
<td class="attribute-actions">
<div class="btn-group btn-group-sm" role="group">
<i class="material-icons">mode_edit</i>
</div>
<div id="combination_form_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" class="combination-form hide row">
<div class="col-sm-12 nav">
{# "Prev." is short for "Previous" #}
<a class="btn-sensitive prev"><i class="material-icons">keyboard_arrow_left</i> {{ 'Prev. combination'|trans({}, 'Admin.Catalog.Feature') }}</a>
<a class="next btn-sensitive">{{ 'Next combination'|trans({}, 'Admin.Catalog.Feature') }} <i class="material-icons">keyboard_arrow_right</i></a>
</div>
<div class="panel col-md-12 p-2">
<div class="float-left">
<button type="button" class="back-to-product btn btn-outline-secondary btn-back"><i class="material-icons">arrow_back</i> {{ 'Back to product'|trans({}, 'Admin.Catalog.Feature') }}</button>
</div>
<h2 class="title pt-2">
{{ "Combination details"|trans({}, 'Admin.Catalog.Feature') }} -
{{ form.vars.value.name }}
</h2>
{{ form_widget(form.attribute_default) }}
<div class="row">
{% if 'PS_STOCK_MANAGEMENT'|configuration %}
<div class="col-md-2">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_quantity.vars.label }}
</label>
{{ form_errors(form.attribute_quantity) }}
{{ form_widget(form.attribute_quantity) }}
</fieldset>
</div>
{% endif %}
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.available_date_attribute.vars.label }}</label>
{{ form_errors(form.available_date_attribute) }}
{{ form_widget(form.available_date_attribute) }}
</fieldset>
</div>
<div class="col-md-2">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_minimal_quantity.vars.label }}
<span class="help-box" data-toggle="popover"
data-content="{{ "The minimum quantity required to buy this product (set to 1 to disable this feature). E.g.: if set to 3, customers will be able to purchase the product only if they take at least 3 in quantity."|trans({}, 'Admin.Catalog.Help') }}" ></span>
</label>
{{ form_errors(form.attribute_minimal_quantity) }}
{{ form_widget(form.attribute_minimal_quantity) }}
</fieldset>
</div>
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_reference.vars.label }}</label>
{{ form_errors(form.attribute_reference) }}
{{ form_widget(form.attribute_reference) }}
</fieldset>
</div>
</div>
<h2 class="title">
{{ 'Stock'|trans({}, 'Admin.Catalog.Feature') }}
</h2>
<div class="row">
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_location.vars.label }}</label>
{{ form_errors(form.attribute_location) }}
{{ form_widget(form.attribute_location) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_low_stock_threshold.vars.label }}</label>
{{ form_errors(form.attribute_low_stock_threshold) }}
{{ form_widget(form.attribute_low_stock_threshold) }}
</fieldset>
</div>
<div class="col-md-9">
<fieldset class="form-group widget-checkbox-inline">
<label class="form-control-label"> </label>
<div class="widget-checkbox-inline">
{{ form_errors(form.attribute_low_stock_alert) }}
{{ form_widget(form.attribute_low_stock_alert) }}
<span class="help-box" data-toggle="popover" data-html="true" data-content="{{ "The email will be sent to all the users who have the right to run the stock page. To modify the permissions, go to [1]Advanced Parameters > Team[/1]"|trans({'[1]':'<a href="'~getAdminLink("AdminEmployees")~'">','[/1]':'</a>'}, 'Admin.Catalog.Help')|raw }}" ></span>
</div>
</fieldset>
</div>
</div>
<h2 class="title">
{{ "Price and impact"|trans({}, 'Admin.Catalog.Feature') }}
</h2>
<div class="row">
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_wholesale_price.vars.label }}</label>
{{ form_errors(form.attribute_wholesale_price) }}
{{ form_widget(form.attribute_wholesale_price) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_price.vars.label }}
<span class="help-box" data-toggle="popover"
data-content="{{ "Does this combination have a different price? Is it cheaper or more expensive than the default retail price?"|trans({}, 'Admin.Catalog.Help') }}" ></span>
</label>
{{ form_errors(form.attribute_price) }}
{{ form_widget(form.attribute_price) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_priceTI.vars.label }}</label>
{{ form_errors(form.attribute_priceTI) }}
{{ form_widget(form.attribute_priceTI) }}
</fieldset>
</div>
<div class="col-md-3">
<small class="form-control-label vcenter">{{ "Final retail price (tax excl.) will be"|trans({}, 'Admin.Catalog.Feature') }} <span class="final-price" data-price="{{ form.vars.value.final_price }}" data-uniqid="{{ form.vars.value.id_product_attribute }}">{{ form.vars.value.final_price }}</span> {{ default_currency }}</small>
</div>
</div>
<div class="row">
<div class="col-md-3 {% if 'PS_USE_ECOTAX'|configuration != 1 %}hide{% endif %}">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_ecotax.vars.label }}</label>
{{ form_errors(form.attribute_ecotax) }}
{{ form_widget(form.attribute_ecotax) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_unity.vars.label }}
<span class="help-box" data-toggle="popover"
data-content="{{ "Does this combination have a different price per unit?"|trans({}, 'Admin.Catalog.Feature') }}" ></span>
</label>
{{ form_errors(form.attribute_unity) }}
{{ form_widget(form.attribute_unity) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_weight.vars.label }}</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">{{ 'PS_WEIGHT_UNIT'|configuration }}</span>
</div>
{{ form_errors(form.attribute_weight) }}
{{ form_widget(form.attribute_weight) }}
</div>
</fieldset>
</div>
</div>
<h2 class="title">
{{ "Specific references"|trans({}, 'Admin.Catalog.Feature') }}
</h2>
<div class="row">
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_isbn.vars.label }}</label>
{{ form_errors(form.attribute_isbn) }}
{{ form_widget(form.attribute_isbn) }}
</fieldset>
</div>
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_ean13.vars.label }}
<span class="help-box" data-toggle="popover"
data-content="{{ "This type of product code is specific to Europe and Japan, but is widely used internationally. It is a superset of the UPC code: all products marked with an EAN will be accepted in North America."|trans({}, 'Admin.Catalog.Help') }}" ></span>
</label>
{{ form_errors(form.attribute_ean13) }}
{{ form_widget(form.attribute_ean13) }}
</fieldset>
</div>
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_upc.vars.label }}</label>
{{ form_errors(form.attribute_upc) }}
{{ form_widget(form.attribute_upc) }}
</fieldset>
</div>
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_mpn.vars.label }}</label>
{{ form_errors(form.attribute_mpn) }}
{{ form_widget(form.attribute_mpn) }}
</fieldset>
</div>
</div>
<h2 class="title">
{{ "Images"|trans({}, 'Admin.Catalog.Feature') }}
</h2>
<div class="row">
<div class="col-md-12">
<fieldset class="form-group js-combination-images">
<label>
<small class="form-control-label">{{ form.id_image_attr.vars.label }}</small>
<small class="form-control-label number-of-images"></small>
</label>
{{ form_errors(form.id_image_attr) }}
{{ form_widget(form.id_image_attr) }}
</fieldset>
</div>
</div>
<div class="row">
<div class="col-md-12">
{{ renderhook('displayAdminProductsCombinationBottom', { 'id_product': form.vars.value.id_product, 'id_product_attribute': form.vars.value.id_product_attribute }) }}
</div>
</div>
{{ form_widget(form.id_product_attribute) }}
</div>
</div>
</td>
<td width="5%">
<i class="material-icons">delete</i>
</td>
<td>
{% set checked = form.vars.value.attribute_default == 1 ? 'checked' : '' %}
<input class="attribute-default" type="radio" {{ checked }} data-id="{{ form.vars.value.id_product_attribute }}">
</td>
</tr>
I finally managed to get it working, so I am posting the solution. I know it is not 100% correct and not upgrade friendly, but it does the job really good if you want to add barcode to combinations fast. For anyone wondering this is the working code i ended up with :
<tr class="combination loaded" id="attribute_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}">
<td width="1%"><input class="js-combination" type="checkbox" data-id="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}"></td>
<td class="img"><div class="fake-img"></div></td>
<td>{{ form.vars.value.name }}</td>
<td>
<fieldset class="form-group">
{{ form_errors(form.attribute_ean13) }}
{{ form_widget(form.attribute_ean13) }}
</fieldset>
</td>
Code starts in line 25 of form_combination.html.twig
I also change the table header name at form_combinations.html.twig so that it says Barcode

Adding code for Comment Boxes on Shopify Blog post in article.liquid

Im trying to add code back into shopify to allow for a comments box at the bottom of blog posts.
from my investigating, the code should exist in article.liquid, however it looks like the original developer deleted it.
I have tried entering code from Shopifys example https://shopify.github.io/liquid-code-examples/example/comment-list which produced no changes (Also I can't see there being an option to 'moderate' the comments, ideally we want to check them before they're posted on site.
Also tried a code from Github https://github.com/Shopify/Timber/blob/master/templates/article.liquid, which resulted in the below image. This code mentions 'moderate', but it didn't work.
github code error
Has anyone experience similar issue?
this is the current article.liquid code:
<div class="small-12 columns">
<article class="single-article">
<div class="article__title">
<h1 class="impact alpha">{{ blog.title }}</h1>
<h3 class="impact gamma">
<time pubdate datetime="{{ article.published_at | date: '%Y-%m-%d' }}">{{ article.published_at | date: '%b %d, %Y' }}</time> | {{ blog.title }}
</h3>
</div>
<div class="article__feature-image">
<img src="{{ article.image.src | img_url: '1024x1024' }}" alt="{{ article.image.alt }}">
</div>
<div class="article__content">
<div class="row">
<div class="small-12 medium-8 medium-offset-2 columns rte">
{{ article.content }}
</div>
</div>
</div>
<div class="article__paginate">
{% if blog.next_article or blog.previous_article %}
<div class="row">
<div class="small-12 medium-8 medium-offset-2 columns rte">
<p class="clearfix">
{% if blog.next_article %}
<span class="left impact epsilon">{{ '← Next Post' | link_to: blog.next_article }}</span>
{% endif %}
{% if blog.previous_article %}
<span class="right impact epsilon">{{ 'Previous Post →' | link_to: blog.previous_article }}</span>
{% endif %}
</p>
</div>
</div>
{% endif %}
</div>
<div class="article__author">
<div class="row">
<div class="small-12 medium-8 medium-offset-2 columns">
<div class="row">
<div class="author-image small-12 medium-3 columns">
<img src="http://www.gravatar.com/avatar/{{ article.user.email | md5 }}?s=100" />
</div>
<div class="author-details small-12 medium-9 columns">
<h4 class="impact epsilon">Written by {{ article.author }}</h4>
<p>{{ article.user.bio }}</p>
</div>
</div>
</div>
</div>
</div>
<div class="article__social clearfix">
<div class="row">
<div class="small-12 medium-8 small-centered columns">
<h4 class="epsilon impact">Share This</h4>
<br>
{% include 'snippets_share' %}
</div>
</div>
</div>
</article>
</div>

How to apply cycle to this div's

Since there is no modulus (%) in django templates So how to apply
cycle at this
{% for story in data %}
{{forloop.counter}}
when forloop.counter%4==1 then this should be executed
<div class="thumb">
<img src="{{ STATIC_URL }}images/thumb.jpg" width="185" height="185" />
</div>
<div class="thumbFooter">
<span class="view">
{{ story.views }}
</span>
<span class="like">
{{ story.likes }}
</span>
</div>
</li>
when forloop.counter%4==2 or 3 then this should be executed
<li>
<div class="thumb">
<img src="{{ STATIC_URL }}images/thumb.jpg" width="185" height="185" />
</div>
<div class="thumbFooter">
<span class="view">
{{ story.views }}
</span>
<span class="like">
{{ story.likes }}
</span>
</div>
</li>
when forloop.counter%4==0 of for loop this should be executed
<li class="omega">
<div class="thumb">
<img src="{{ STATIC_URL }}images/thumb.jpg" width="185" height="185" />
</div>
<div class="thumbFooter">
<span class="view">
{{ story.views }}
</span>
<span class="like">
{{ story.likes }}
</span>
</div>
</li>
<div class="clear"></div>
{% endfor %}
You can build your own custom filter
In the templatetags directory of your Django, add a file named 'mod.py'. In that file add the following code:
from django import template
register = template.Library()
def mod(value, arg):
if value % arg == 0:
return True
else:
return False
register.filter('mod', mod)
In your template use the mod filter like this:
...
{% load mod %}
...
<tr bgcolor="{% if forloop.counter|mod:2 %}#cccccc{% else %}#ffffff">
...
I think you want class='omega' on each 4th li of forloop. Use django Cycle in template in this way,
{% for story in data %}
<li {% cycle '' '' '' 'class="omega"' %}>
<div class="thumb">
<img src="{{ STATIC_URL }}images/thumb.jpg" width="185" height="185" />
</div>
<div class="thumbFooter">
<span class="view">
{{ story.views }}
</span>
<span class="like">
{{ story.likes }}
</span>
</div>
</li>
{% cycle '' '' '' '<div class="clear"></div>' %}
{% endfor %}
Or you could use the divisibleby filter. You can also use the add filter to adjust for all your conditions:
when forloop.counter%4==1 then this should be executed
{% if forloop.counter|add:"-1"|divisibleby:"4" %}
when forloop.counter%4==2 or 3 then this
{% if forloop.counter|add:"-2"|divisibleby:"4" or forloop.counter|add:"-3"|divisibleby:"4" %}
And without using add for the ones divisible by 4:
when forloop.counter%4==0 of for loop this should be executed
{% if forloop.counter|divisibleby:"4" %}