Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Last active December 11, 2015 06:38
Show Gist options
  • Select an option

  • Save msmithstubbs/4560461 to your computer and use it in GitHub Desktop.

Select an option

Save msmithstubbs/4560461 to your computer and use it in GitHub Desktop.
Custom integration
/*
* Example code only
* This code has not been tested on a live site
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
$("input#add").removeClass("disabled").removeAttr("disabled");
$("h2#price span").html(Shopify.formatMoney(variant.price, "${{amount}}"));
if (variant.compare_at_price) {
$("h2#price del").html(Shopify.formatMoney(variant.compare_at_price, "${{amount}}"));
} else {
$("h2#price del").empty();
}
} else {
$("input#add").addClass("disabled").attr("disabled", "disabled");
var message = variant ? "<a href='notifyme'>Email when available</a>" : "Unavailable";
$("h2#price span").html(message);
$("h2#price del").empty();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment