Comments (10)
Hi @maherelaridi,
Should do! I'm pretty sure I have used them with it before. You may need to edit the code a little to get it going though.
Thanks! Let me know how you go.
from shopify-theme-framework.
Hi @Cam-
Sorry, forgot to reply. Anyhow, I had to change few things on the product.liquid template to allow the following:
1- show separate multiple variants per products
2- update product price when variant is selected.
{% if product.variants.size > 1 %}
<form action="/cart/add" method="post">
<div class="current-price">
<div class="variant-price price">
<h5 class="price-field"></h5>
</div>
</div>
<div id="product-variants">
<select id="product-select" name='id'>
{% for variant in product.variants %}
<option value="{{ variant.id }}">{{ variant.title }}</option>
{% endfor %}
</select>
</div><!-- product variants -->
<input type="submit" class="btn addtocart button secondary radius expand" name="add" value="Add to Shopping Cart" id="purchase" />
</form>
{% else %}
<form action="/cart/add" method="post">
<div id="product-variants">
</div><!-- product variants -->
<input type="hidden" id="{{ variant.id }}" name="id" value="{{ product.variants[0].id }}" />
<div class="current-price">{{ product.price | money_with_currency }}</div>
<input type="submit" class="large button main" name="add" value="Add to Shopping Cart" id="purchase" />
</form>
{% endif %}
{% else %}
<p><strong>This product is temporarily unavailable</strong></p>
{% endif %}
And this jQuery on the theme.liquid
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
// selected a valid variant
jQuery('#purchase').removeClass('disabled').removeAttr('disabled'); // remove unavailable class from add-to-cart button, and re-enable button
jQuery('.price-field').html(Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}")); // update price field
} else {
// variant doesn't exist
jQuery('#purchase').addClass('disabled').attr('disabled', 'disabled'); // set add-to-cart button to unavailable class and disable button
var message = variant ? "Sold Out" : "Unavailable";
jQuery('.price-field').text(message); // update price-field message
}
};
// initialize multi selector for product
jQuery(document).ready(function() {
new Shopify.OptionSelectors("product-select", { product: {{ product | json }}, onVariantSelected: selectCallback });
{% assign found_one_in_stock = false %}
{% for variant in product.variants %}
{% if variant.available and found_one_in_stock == false %}
{% assign found_one_in_stock = true %}
{% for option in product.options %}
jQuery('.single-option-selector:eq(' + {{ forloop.index0 }} + ')').val({{ variant.options[forloop.index0] | json }}).trigger('change');
{% endfor %}
{% endif %}
{% endfor %}
$('#product-variants div').addClass("selector-wrapper");
$('#product-variants div label').css("float","left");
$('#product-variants div select').css("float","right");
$('#product-variants div ').addClass("clearfix").css("clear","both");
{% if product.options.size == 1 %}
$(".selector-wrapper").prepend("<label>{{ product.options.first}}</label>")
{% endif %}
});
Here is how it looks like now
http://paintapart.com/products/2003-2007-honda-accord-coupe-fender
from shopify-theme-framework.
Awesome stuff @maherelaridi! I'm have to roll this into the main build. I've got a lot of updates to commit, so the upcoming build should be a lot more useful :) Thank you for including your code!
from shopify-theme-framework.
Btw I am about to build another Shopify site. I noticed that they support SASS now. Not sure how I go about this using your theme. Any ideas?
I found this read here:
https://ecommerce.shopify.com/c/ecommerce-design/t/you-can-now-use-scss-in-shopify-s-template-editor-133389
http://shopify.github.io/Timber/
from shopify-theme-framework.
I think you should just be able to replace the CSS files with your SASS files, as Shopify compiles it at their end (from what I can remember).
from shopify-theme-framework.
Sweet! I'll try that. Thanks Cam
from shopify-theme-framework.
No probs! Let me know how you go :)
from shopify-theme-framework.
Hey Cam,
I see this issue was solved by maherelaridi but I am having trouble figuring it out myself.
Basically I have a few product variants but selecting between them in the drop down does not actually change the price displayed. I am guessing it is just an issue with the jquery somewhere but I can't quite find it.
The price displayed used to just default to the lowest price, i changed the code to select the first available variant from the list so now it show the proper price when the page loads, but selecting between variants does nothing. Any help with this issue would be much appreciated, it is one of the last road blocks I am running into with my product.liquid.
You can see the example here: http://asterisk-2.myshopify.com/collections/protection/products/sample-product-2
pw: whaick
Thanks again.
from shopify-theme-framework.
Hi @ineptian. Most of this theme is a Foundation-ized version of the Minimal theme by Shopify (albeit a much older version). I would recommend grabbing the new scripting from that and merging it in to your product pages https://themes.shopify.com/themes/minimal/styles/fashion
from shopify-theme-framework.
Hello,
For a product we have created two set of option option-1 and option-2. Is it possible to show option-1 as a select box and option-2 as a checkbox
from shopify-theme-framework.
Related Issues (20)
- Overflow / Scroll Modal HOT 3
- Error on login page
- Too little products float right. HOT 4
- Add Off Canvas Menu with Cart Included
- Secondary Product Image Display Error HOT 3
- View larger image modal not closing HOT 1
- Product Swatches HOT 7
- Strange behavior with multiple reveal modals on home page HOT 7
- Equalizer Plugin Missing HOT 1
- Add to Cart button adding wrong product. HOT 9
- jQuery Zoom only works on first thumbnail HOT 5
- Reveal Modal not working when trigger button is separate from the modal? HOT 1
- Position of tooltips HOT 1
- Size of product image hover HOT 3
- Accordion HOT 1
- Collection Page Rows HOT 2
- Dynamic price update not working with product variations
- Does this shopify support products with custom core price options? not using for variants option only custom core select option.
- hellow.. i add on product quick view a thumbnail
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shopify-theme-framework.