Skip to content

Instantly share code, notes, and snippets.

@philcon93
Last active January 29, 2018 00:38
Show Gist options
  • Save philcon93/19bbb0dcec244bcb7908af288a40c972 to your computer and use it in GitHub Desktop.
Save philcon93/19bbb0dcec244bcb7908af288a40c972 to your computer and use it in GitHub Desktop.
Updated Product variation dropdown template

Updated Product variation dropdown template

B@SE JS

When a user picks a variation on a product page, sections of the page will reload to update the content to fit the variation product. Also the list_item_variation selects will reload, and the template for these items are stored in Neto.js, specificly product_variationInit. When the user picks a variation, the product_variationInit function will run, which we use to say which templates need to reload, e.g:

$.product_variationInit({
  'loadtmplates': ['_buying_options', '_images','_header']

To change a variation select template, we just need to include the new template, e.g:

'select_template': {
            'header': '<select class="##sel_class##" ref="##specific_id##">',
            'body': '<option value="##value_id##" ##IF:select## selected ##END IF:select##>##value_name##</option>',
            'footer': '</select>'
        },

These templates use 'hashing' which is similar to base tag/functions but is very limited in it's values.

<script type="text/javascript" language="javascript">
$(document).ready(function() {
$.product_variationInit({
// loadtmplate code ...
'select_template': {
'header': '<select class="##sel_class##" ref="##specific_id##">',
'body': '<option value="##value_id##" ##IF:select## selected ##END IF:select##>##value_name##</option>',
'footer': '</select>'
},
// additional fns and kit variationInit code ...
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment