CyberStore Ecommerce 2023 Documentation
ClientJavaScript Property
Example 


Dovetail.Ecommerce.Controls Namespace > CatalogSimplePricingControl Class : ClientJavaScript Property
Gets or sets the client javascript.

Property Value

The client javascript.
Remarks

The ClientJavaScript property contains the client-side JavaScript functions used by the CatalogSimplePricingControl. To override default client-side behavior when the Add to Cart button is clicked, web developers may inject their own JavaScript by setting the value of the ClientJavaScript property. The client-side code is loaded by the control into the client script block during the Pre_Render event of the control page load sequence.

The default JavaScript code follows:

var CatalogSimplePricingControl_AddToCart = function(Item_ID, p) {
    if (p.bID.GetText() != p.callLinkLabel) {
        if (Item_ID == 0 || Item_ID == '' || Item_ID == null) {
            return; 
        }
        var Qty = isNaN(p.qty) ? 0 : p.qty; 
        if (p.minQty == null || isNaN(p.minQty) || p.minQty == 0) {
            if (Qty == '' || Qty == null) { Qty = 1; }
        } else {
            if (Qty == '' || Qty == null || Qty < p.minQty) {
                Qty = p.minQty;
            }
        }
        if (p.tID.GetText() != Qty) { p.tID.SetText(Qty); }
        var UOMType = p.uom;
        if (UOMType == null || UOMType == '') {
            UOMType = 'PREFERRED';
        }
        var Params = { 'Item_ID': Item_ID, 'Qty': Qty, 'UOM':UOMType };

        MakeAJAXCall('Cart.AddItemToCart', Params, CatalogSimplePricingControl_VerifyAddToCart, p);
    }
    else {
        if (p.zeroPriceLink != '') {
            window.location = p.zeroPriceLink;
        }
        else {
            return;
        }
    }
}
var CatalogSimplePricingControl_VerifyAddToCart = function(Data, p) {
    p.bID.SetText('Added to Cart');
    p.bID.SetEnabled(false);
    var e = p.bID.GetMainElement();

    e.classList.add('added');
    setTimeout(function () { p.bID.SetText(p.bText); e.classList.remove('added');p.bID.SetEnabled(true); }, 1500);
}
Example

	
See Also

Reference

CatalogSimplePricingControl Class
CatalogSimplePricingControl Members