[Paid] jQuery script for Shopify
Page 1 of 1
Interinactive
VIP Member



Posts: 29462

PostPosted: Fri, 16th May 2014 09:40    Post subject: [Paid] jQuery script for Shopify
I have so much other stuff to do and I don't have time to figure this out. Issue:

http://ecommerce.shopify.com/c/ecommerce-design/t/hide-unavailable-options-set-title-of-variant-dropdown-195492

I can use JSON (or even jQuery by grabbing content from the page) to put an extra option in the dropdown but it screws up as it's not a valid product. I need it so that the default option is the title (eg: "Pick a size...") and so that it can't be picked again. I need it to work in conjunction with that existing script.

This script works:

http://docs.shopify.com/support/your-website/themes/how-to-add-a-pick-an-option-to-drop-downs

But then the other one doesn't. They just need to be combined somehow.

TL;DR: Make it so that this script and this script work together.



If you're a regular/trustworthy person I can give you access to the store since there's nothing on there anyway.

Name your game or price, I'll leave it here for a day before I put it on a freelancer site.

Thanks!
Back to top
Werelds
Special Little Man



Posts: 15098
Location: 0100111001001100
PostPosted: Fri, 16th May 2014 10:25    Post subject:
Should be easy money for someone who has the time for it.

Pretty easy to do if you use Select2/Chosen/Selectize, as each has a placeholder option.

Here's some (almost pseudo) code for you though (maybe this is enough for you to figure it out on your own). Modify HTML to do this first:
Code:

<select data-placeholder="Select {{ category name or whatever }}"></select>


Then in JS:
Code:

$('select').each(function() {
  var $select = $(this),
        $option = '<option value="">' + $select.data('placeholder') . '</option>';

  $select.prepend($option);
  $select.one('change', function() {
    $option.remove();
  });
});


That's the general mechanic. Just use a data attribute to store the placeholder and remove the option you added once the dropdown is changed to a different value. You may need to couple this with the linked-list bits by using custom events (didn't check the other script), but this is how you need to do this.
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group