Skip to content

Instantly share code, notes, and snippets.

View JumboLove's full-sized avatar

David Witt JumboLove

View GitHub Profile
@JumboLove
JumboLove / dw-form-radio-button.html
Created June 7, 2013 13:45
DW Form Radio Button
<isloop items="${pdict.CurrentForms.newsletter.subscribe.gender.options}" var="option">
<isif condition="${option.htmlValue > 0}" >
<label for="gender-${option.htmlValue}"><isprint value="${Resource.msg(option.label,'forms',null)}" /></label>
<input type="radio" name="${pdict.CurrentForms.newsletter.subscribe.gender.htmlName}" value="${option.htmlValue}" id="gender-${option.htmlValue}" />
</isif>
</isloop>
@JumboLove
JumboLove / select-enum-of-integer
Created June 7, 2013 13:47
Select from Enum of Integer
<isset name="GiftCertLineItemDef" value="${dw.object.SystemObjectMgr.describe('GiftCertificateLineItem').getCustomAttributeDefinition( "denominations" ).getValues()}" scope="page" />
<select>
<isloop iterator="${GiftCertLineItemDef}" var="denom" status="status">
<option value="${denom.getValue()}">${denom.getDisplayValue()}</option>
</isloop>
</select>
@JumboLove
JumboLove / set-checkbox-state
Created June 7, 2013 13:50
Set checkbox state
jQuery('#dwfrm_profile_newsletter').attr('checked', function(){
var status = ${pdict.ETSubStatus};
if(status === true){return 'checked'};
});
@JumboLove
JumboLove / set-cookie
Created June 7, 2013 13:52
Set Cookie
@JumboLove
JumboLove / dw-popup-ajax
Created June 7, 2013 14:02
DW Form Popup Ajax Form
<isinclude template="util/modules">
<div class="checkBalanceContainer">
<form action="${URLUtils.continueURL()}" id="${pdict.CurrentForms.giftcert.htmlName}">
<isinputfield formfield="${pdict.CurrentForms.giftcert.balance.giftCertID}" type="input">
<isinputfield formfield="${pdict.CurrentForms.giftcert.balance.pin}" type="input" >
<button type="submit" name="${pdict.CurrentForms.giftcert.checkbalance.htmlName}" class="checkBalance">Check Balance</button>
<iscomment>Hidden input required for ajax serialization of the form</iscomment>
<input name='${pdict.CurrentForms.giftcert.checkbalance.htmlName}' type='hidden' value="true"/>
</form>
@JumboLove
JumboLove / pipeline-hooks
Created June 7, 2013 14:03
Creating Pipeline Hooks
GetPipelineHooks.ds
/**
* Name: GetHookPipeline.ds
*
* Description:
* Gets the configiured hook pipeline, if not found it returns EmptyHook-Start
*
* @input hookName : String The property key of the Hook
* @input fallbackHookPipeline : String The pipeline, which should be used as a fallback, if the hook is not defined in the current site
* @output hookPipeline : String The hook pipeline to call
@JumboLove
JumboLove / product-feed
Created June 7, 2013 14:04
Boilerplate Product Feed
/**
* Demandware Script File
* Export only the Product IDs to Netrada FTP to match the ProductFeed Export sent to Bazaarvoice
* Exports Product IDs to a text file with pipe delimiters.
* Created by David Witt 05 June 2013
*
*/
importPackage( dw.system );
importPackage( dw.util );
@JumboLove
JumboLove / format-money
Created June 7, 2013 14:14
Format Money
/*
decimal_sep: character used as deciaml separtor, it defaults to '.' when omitted
thousands_sep: char used as thousands separator, it defaults to ',' when omitted
*/
Number.prototype.toMoney = function(decimals, decimal_sep, thousands_sep) {
var n = this,
c = isNaN(decimals) ? 2 : Math.abs(decimals), //if decimal is zero we must take it, it means user does not want to show any decimal
d = decimal_sep || '.', //if no decimal separator is passed we use the dot as default decimal separator (we MUST use a decimal separator)
/*
@JumboLove
JumboLove / category-content-slot
Created June 10, 2013 18:13
Category Content Slot
<iscomment>Be sure to include this line commented out in the category rendering template if you want this to show up outside the rendering template</iscomment>
<isslot id="cat-banner" context="category" description="Category Banner" context-object="${pdict.ProductSearchResult.category}"/>
@JumboLove
JumboLove / strip-html
Created June 17, 2013 14:04
Remove HTML from a string
function getShortDescription(product : Product) {
var description : String = product.getLongDescription().toString();
var htmlTest : RegExp = new RegExp("(<([^>]+)>)", "ig");
description = description.replace(htmlTest, "");
return description;
}