Back to PhocacartRenderJs class

Method getPriceFormatJavascript

public static
getPriceFormatJavascript
(mixed $price_decimals, mixed $price_dec_symbol, mixed $price_thousands_sep, mixed $price_currency_symbol, mixed $price_prefix, mixed $price_suffix, mixed $price_format)

Method getPriceFormatJavascript - Source code

/*
 * Change Price, Stock, ID (EAN, SKU, ...)
 * select box (standard, image, color)
 * check box
 */
/* public static function renderAjaxChangeProductDataByOptions($id = 0, $typeView = '', $class = '') {

        $paramsC = PhocacartUtils::getComponentParameters();
        $dynamic_change_price   = $paramsC->get('dynamic_change_price', 0);
        $dynamic_change_stock   = $paramsC->get('dynamic_change_stock', 0);
        $dynamic_change_id   = $paramsC->get('dynamic_change_id', 0);
        $theme                  = $paramsC->get('theme', 'bs3');

        if ($dynamic_change_price == 0 && $dynamic_change_stock == 0 && $dynamic_change_id == 0) {
            return false;
        }


        $urlAjax = Uri::base(true) . '/index.php?option=com_phocacart&task=checkout.changedatabox&format=json&' . Session::getFormToken() . '=1';

        $s = array();
        $s[] = 'function phAjaxChangeData' . $typeView . '(phProductId, phDataA1, phDataA2){';
        $s[] = '	var phUrl 	= "' . $urlAjax . '";';
        $s[] = '	var phOptions = [];';
        $s[] = '	phOptions["id"] = phProductId;';
         $s[] = '	phOptions["id_item_price"] = "#phItemPriceBox' . $typeView . '" + phProductId;';
         $s[] = '	phOptions["id_item_stock"] = "#phItemStockBox' . $typeView . '" + phProductId;';
         $s[] = '	phOptions["id_item_id"] = "#phItemIdBox' . $typeView . '" + phProductId;';
         $s[] = '	phOptions["product_add_to_cart_item"] 		= ".phProductAddToCart' . $typeView . '" + phProductId;';// display or hide add to cart button
         $s[] = '	phOptions["product_add_to_cart_item_icon"] 	= ".phProductAddToCartIcon' . $typeView . '" + phProductId;';// display or hide add to cart icon
        $s[] = '	phOptions["view"] = ' . (int)$typeView . ';';
         $s[] = '	phOptions["method_price"]  = ' . (int)$dynamic_change_price . ';';
         $s[] = '	phOptions["method_stock"]  = ' . (int)$dynamic_change_stock . ';';
         $s[] = '	phOptions["method_id"]  = ' . (int)$dynamic_change_id . ';';
        $s[] = '	phOptions["task"]  = "change";';
         $s[] = '	phOptions["type"]  = "changedata";';
        $s[] = '	phOptions["class"]  = "' . $class . '";';
        $s[] = '	var phData 	= \'id=\'+ phOptions["id"] +\'&\'+ phDataA1 +\'&\'+ phDataA2 +\'&\'+\'class=\'+ phOptions["class"] +\'&\'+\'typeview=\'+ phOptions["view"];';
        $s[] = '	phDoRequestMethods(phUrl, phData, phOptions);';
        $s[] = '}';
        $s[] = ' ';



        $s[] = 'jQuery(document).ready(function(){  ';
      /*  $s[] = '    var phSelectboxA             =  "select.phj' . $typeView . '.phjProductAttribute";';
        $s[] = '    var phSelectboxASelected    =  phSelectboxA + ":selected";';
        $s[] = '	jQuery(document).on(\'change\', phSelectboxA, function(e){ ';// Select Box
        //$s[] = '		jQuery(this).off("change");';

        $s[] = '		var phTypeView = jQuery(this).data(\'type-view\');';
        $s[] = '		var phProductId = jQuery(this).data(\'product-id\');';
        $s[] = '		var phProductGroup = \'.phjAddToCartV' . $typeView . 'P\' + phProductId;';
        $s[] = '		var phDataA1 = jQuery(phProductGroup).find(\'select\').serialize();';// All Selects
        $s[] = '		var phDataA2 = jQuery(phProductGroup).find(\':checkbox\').serialize();';// All Checkboxes
        $s[] = '		phAjaxChangeData' . $typeView . '(phProductId, phDataA1, phDataA2);';// If REQUIRED, don't allow to untick image or color "select box" - see jquery.phocaattribute.js
        $s[] = '	})';*/
// Checkbox
// Unfortunately, we cannot run event:
// 1. CHANGE - because of Bootstrap toogle button, this will run 3x ajax (checkbox is hidden and changes when clicking on button)
// 2. CLICK directly on checkbox as if Bootstrap toogle button is use, clicked will be icon not the checkbox
// So we run click on div box over the checkbox which works and don't run ajax 3x
//$s[] = '	jQuery(document).on(\'change\', \'.ph-checkbox-attribute.phj'.$typeView.'.phjProductAttribute :checkbox\', function(){';
//$s[] = '	jQuery(document).on(\'click\', \'#phItemPriceBoxForm .ph-checkbox-attribute.ph-item-input-set-attributes\', function(){';
/*  $s[] = '    var phCheckboxA             =  ".ph-checkbox-attribute.phj' . $typeView . '.phjProductAttribute"';
       // $s[] = '    var phCheckboxAInputChecked =  phCheckboxA + " input:checked"';
        $s[] = '	jQuery(document).on(\'click\', phCheckboxA, function(e){';
        $s[] = '        if (e.target.tagName.toUpperCase() === "LABEL") { return;}';// Prevent from twice running
        if ($theme == 'bs4') {
            $s[] = '        if (e.target.tagName.toUpperCase() === "SPAN" || e.target.tagName.toUpperCase() === "IMG") { return;}';// Prevent from twice running
        }
        $s[] = '		var phProductId = jQuery(this).data(\'product-id\');';
        $s[] = '		var phTypeView = jQuery(this).data(\'type-view\');';
        $s[] = '		var phProductGroup = \'.phjAddToCartV' . $typeView . 'P\' + phProductId;';
        $s[] = '		var phDataA1 = jQuery(phProductGroup).find(\'select\').serialize();';// All Selects
        $s[] = '		var phDataA2 = jQuery(phProductGroup).find(\':checkbox\').serialize();';// All Checkboxes

        // If REQUIRED, don't allow to untick all checkboxes
        $s[] = '		var phRequired = jQuery(this).data("required");';
        $s[] = '        var phCheckboxAInputChecked =  "#" + jQuery(this).attr("id") + " input:checked"';
        $s[] = '        var phACheckedLength = jQuery(phCheckboxAInputChecked).length;';

        $s[] = '        if (phACheckedLength == 0) {';
        $s[] = '            var phThisLabel = jQuery(e.target).parent();';// Bootstrap checkboxes - colors, images
        $s[] = '            phThisLabel.addClass("active");';// Bootstrap checkboxes - colors, images
        $s[] = '            e.preventDefault();';
        $s[] = '            return false;';
        $s[] = '        }';

        $s[] = '		phAjaxChangeData' . $typeView . '(phProductId, phDataA1, phDataA2);';
        $s[] = '	})';*/
// Change the price on time view when site is initialized
// Because some parameters can be selected as default
// Automatically start only in item view, not in category or another view
/*if ($option == 'com_phocacart' && $view == 'item') {
      //$s[] = '		var phProductId = jQuery(\'.phjItemAttribute\').data(\'product-id\')';
      $s[] = '		var phDataA1 = jQuery("select.phjItemAttribute").serialize();';
      $s[] = '		var phDataA2 = jQuery(".ph-checkbox-attribute.phjItemAttribute :checkbox").serialize();';
      $s[] = '		var phpDataA = phDataA1 +\'&\'+ phDataA2;';
      $s[] = '		phAjaxChangePrice'.$typeView.'('.(int)$id.');';
  }*/
/*
        $s[] = '})';
        $s[] = ' ';
        Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
    }*/
/*
 * Change Price
 * select box (standard, image, color)
 * check box
 */
/*
    public static function renderAjaxChangeProductPriceByOptions($id = 0, $typeView = '', $class = '') {

        $paramsC = PhocacartUtils::getComponentParameters();
        $dynamic_change_price   = $paramsC->get('dynamic_change_price', 0);
        $theme                  = $paramsC->get('theme', 'bs3');

        if ($dynamic_change_price == 0) {
            return false;
        }


        $urlAjax = Uri::base(true) . '/index.php?option=com_phocacart&task=checkout.changepricebox&format=json&' . Session::getFormToken() . '=1';

        $s = array();
        $s[] = 'function phAjaxChangePrice' . $typeView . '(phProductId, phDataA1, phDataA2){';
        $s[] = '	var phUrl 	= "' . $urlAjax . '";';
        $s[] = '	var phOptions = [];';
        $s[] = '	phOptions["id"] = phProductId;';
        $s[] = '	phOptions["id_item"] = "#phItemPriceBox' . $typeView . '" + phProductId;';
        $s[] = '	phOptions["view"] = ' . (int)$typeView . ';';
        $s[] = '	phOptions["method"]  = ' . (int)$dynamic_change_price . ';';
        $s[] = '	phOptions["task"]  = "change";';
        $s[] = '	phOptions["type"]  = "changeprice";';
        $s[] = '	phOptions["class"]  = "' . $class . '";';
        $s[] = '	var phData 	= \'id=\'+ phOptions["id"] +\'&\'+ phDataA1 +\'&\'+ phDataA2 +\'&\'+\'class=\'+ phOptions["class"] +\'&\'+\'typeview=\'+ phOptions["view"];';
        $s[] = '	phDoRequestMethods(phUrl, phData, phOptions);';
        $s[] = '}';
        $s[] = ' ';


       /* $s[] = '	jQuery.ajax({';
        $s[] = '		type: "POST",';
        $s[] = '		url: phUrl,';
        $s[] = '		async: "false",';
        $s[] = '		cache: "false",';
        $s[] = '		data: phData,';
        $s[] = '		dataType:"JSON",';
        $s[] = '		success: function(data){';
        $s[] = '			if (data.status == 1){';
        $s[] = '				jQuery(phIdItem).html(data.item);';
        $s[] = '		   } else {';// Don't change the price box, don't render any error message
        $s[] = '			  }';
        $s[] = '		}';
        $s[] = '	})';
        $s[] = '}';
        $s[] = ' ';*/
/*


        $s[] = 'jQuery(document).ready(function(){  ';
        $s[] = '    var phSelectboxA             =  "select.phj' . $typeView . '.phjProductAttribute";';
        $s[] = '    var phSelectboxASelected    =  phSelectboxA + ":selected";';

        $s[] = '	jQuery(document).on(\'change\', phSelectboxA, function(e){ ';// Select Box

        //$s[] = '		jQuery(this).off("change");';
        $s[] = '		var phProductId = jQuery(this).data(\'product-id\');';
        $s[] = '		var phProductGroup = \'.phjAddToCartV' . $typeView . 'P\' + phProductId;';
        $s[] = '		var phDataA1 = jQuery(phProductGroup).find(\'select\').serialize();';// All Selects
        $s[] = '		var phDataA2 = jQuery(phProductGroup).find(\':checkbox\').serialize();';// All Checkboxes
        $s[] = '		phAjaxChangePrice' . $typeView . '(phProductId, phDataA1, phDataA2);';// If REQUIRED, don't allow to untick image or color "select box" - see jquery.phocaattribute.js
        $s[] = '	})';

        // Checkbox
        // Unfortunately, we cannot run event:
        // 1. CHANGE - because of Bootstrap toogle button, this will run 3x ajax (checkbox is hidden and changes when clicking on button)
        // 2. CLICK directly on checkbox as if Bootstrap toogle button is use, clicked will be icon not the checkbox
        // So we run click on div box over the checkbox which works and don't run ajax 3x
        //$s[] = '	jQuery(document).on(\'change\', \'.ph-checkbox-attribute.phj'.$typeView.'.phjProductAttribute :checkbox\', function(){';
        //$s[] = '	jQuery(document).on(\'click\', \'#phItemPriceBoxForm .ph-checkbox-attribute.ph-item-input-set-attributes\', function(){';

        $s[] = '    var phCheckboxA             =  ".ph-checkbox-attribute.phj' . $typeView . '.phjProductAttribute"';
       // $s[] = '    var phCheckboxAInputChecked =  phCheckboxA + " input:checked"';
        $s[] = '	jQuery(document).on(\'click\', phCheckboxA, function(e){';
        $s[] = '        if (e.target.tagName.toUpperCase() === "LABEL") { return;}';// Prevent from twice running
        if ($theme == 'bs4') {
            $s[] = '        if (e.target.tagName.toUpperCase() === "SPAN" || e.target.tagName.toUpperCase() === "IMG") { return;}';// Prevent from twice running
        }
        $s[] = '		var phProductId = jQuery(this).data(\'product-id\');';
        $s[] = '		var phProductGroup = \'.phjAddToCartV' . $typeView . 'P\' + phProductId;';
        $s[] = '		var phDataA1 = jQuery(phProductGroup).find(\'select\').serialize();';// All Selects
        $s[] = '		var phDataA2 = jQuery(phProductGroup).find(\':checkbox\').serialize();';// All Checkboxes

        // If REQUIRED, don't allow to untick all checkboxes
        $s[] = '		var phRequired = jQuery(this).data("required");';
        $s[] = '        var phCheckboxAInputChecked =  "#" + jQuery(this).attr("id") + " input:checked"';
        $s[] = '        var phACheckedLength = jQuery(phCheckboxAInputChecked).length;';

        $s[] = '        if (phACheckedLength == 0) {';
        $s[] = '            var phThisLabel = jQuery(e.target).parent();';// Bootstrap checkboxes - colors, images
        $s[] = '            phThisLabel.addClass("active");';// Bootstrap checkboxes - colors, images
        $s[] = '            e.preventDefault();';
        $s[] = '            return false;';
        $s[] = '        }';

        $s[] = '		phAjaxChangePrice' . $typeView . '(phProductId, phDataA1, phDataA2);';
        $s[] = '	})';

        // Change the price on time view when site is initialized
        // Because some parameters can be selected as default
        // Automatically start only in item view, not in category or another view
        /*if ($option == 'com_phocacart' && $view == 'item') {
            //$s[] = '		var phProductId = jQuery(\'.phjItemAttribute\').data(\'product-id\')';
            $s[] = '		var phDataA1 = jQuery("select.phjItemAttribute").serialize();';
            $s[] = '		var phDataA2 = jQuery(".ph-checkbox-attribute.phjItemAttribute :checkbox").serialize();';
            $s[] = '		var phpDataA = phDataA1 +\'&\'+ phDataA2;';
            $s[] = '		phAjaxChangePrice'.$typeView.'('.(int)$id.');';
        }*/
/*

        $s[] = '})';
        $s[] = ' ';
        Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
    }*/
/*
 * Change ID (SKU, EAN, ...)
 * select box (standard, image, color)
 * check box
 */
/*
    public static function renderAjaxChangeProductIdByOptions($id = 0, $typeView = '', $class = '') {

        $paramsC = PhocacartUtils::getComponentParameters();
        $dynamic_change_id      = $paramsC->get('dynamic_change_id', 0);
        $theme                  = $paramsC->get('theme', 'bs3');

        if ($dynamic_change_id == 0) {
            return false;
        }


        $urlAjax = Uri::base(true) . '/index.php?option=com_phocacart&task=checkout.changeidbox&format=json&' . Session::getFormToken() . '=1';

        $s = array();
        $s[] = 'function phAjaxChangeId' . $typeView . '(phProductId, phDataA1, phDataA2){';
        $s[] = '	var phUrl 	= "' . $urlAjax . '";';
        $s[] = '	var phOptions = [];';
        $s[] = '	phOptions["id"] = phProductId;';
        $s[] = '	phOptions["id_item"] = "#phItemIdBox' . $typeView . '" + phProductId;';
        $s[] = '	phOptions["view"] = ' . (int)$typeView . ';';
        $s[] = '	phOptions["method"]  = ' . (int)$dynamic_change_id . ';';
        $s[] = '	phOptions["task"]  = "change";';
        $s[] = '	phOptions["type"]  = "changeid";';
        $s[] = '	phOptions["class"]  = "' . $class . '";';
        $s[] = '	var phData 	= \'id=\'+ phOptions["id"] +\'&\'+ phDataA1 +\'&\'+ phDataA2 +\'&\'+\'class=\'+ phOptions["class"] +\'&\'+\'typeview=\'+ phOptions["view"];';
        $s[] = '	phDoRequestMethods(phUrl, phData, phOptions);';
        $s[] = '}';
        $s[] = ' ';

        $s[] = 'jQuery(document).ready(function(){  ';
        $s[] = '    var phSelectboxA             =  "select.phj' . $typeView . '.phjProductAttribute";';
        $s[] = '    var phSelectboxASelected    =  phSelectboxA + ":selected";';
        $s[] = '	jQuery(document).on(\'change\', phSelectboxA, function(e){ ';// Select Box
        //$s[] = '		jQuery(this).off("change");';
        $s[] = '		var phProductId = jQuery(this).data(\'product-id\');';
        $s[] = '		var phProductGroup = \'.phjAddToCartV' . $typeView . 'P\' + phProductId;';
        $s[] = '		var phDataA1 = jQuery(phProductGroup).find(\'select\').serialize();';// All Selects
        $s[] = '		var phDataA2 = jQuery(phProductGroup).find(\':checkbox\').serialize();';// All Checkboxes
        $s[] = '		phAjaxChangeId' . $typeView . '(phProductId, phDataA1, phDataA2);';// If REQUIRED, don't allow to untick image or color "select box" - see jquery.phocaattribute.js
        $s[] = '	})';

        // Checkbox
        // Unfortunately, we cannot run event:
        // 1. CHANGE - because of Bootstrap toogle button, this will run 3x ajax (checkbox is hidden and changes when clicking on button)
        // 2. CLICK directly on checkbox as if Bootstrap toogle button is use, clicked will be icon not the checkbox
        // So we run click on div box over the checkbox which works and don't run ajax 3x
        //$s[] = '	jQuery(document).on(\'change\', \'.ph-checkbox-attribute.phj'.$typeView.'.phjProductAttribute :checkbox\', function(){';
        //$s[] = '	jQuery(document).on(\'click\', \'#phItemPriceBoxForm .ph-checkbox-attribute.ph-item-input-set-attributes\', function(){';

        $s[] = '    var phCheckboxA             =  ".ph-checkbox-attribute.phj' . $typeView . '.phjProductAttribute"';
       // $s[] = '    var phCheckboxAInputChecked =  phCheckboxA + " input:checked"';
        $s[] = '	jQuery(document).on(\'click\', phCheckboxA, function(e){';
        $s[] = '        if (e.target.tagName.toUpperCase() === "LABEL") { return;}';// Prevent from twice running
        if ($theme == 'bs4') {
            $s[] = '        if (e.target.tagName.toUpperCase() === "SPAN" || e.target.tagName.toUpperCase() === "IMG") { return;}';// Prevent from twice running
        }
        $s[] = '		var phProductId = jQuery(this).data(\'product-id\');';
        $s[] = '		var phProductGroup = \'.phjAddToCartV' . $typeView . 'P\' + phProductId;';
        $s[] = '		var phDataA1 = jQuery(phProductGroup).find(\'select\').serialize();';// All Selects
        $s[] = '		var phDataA2 = jQuery(phProductGroup).find(\':checkbox\').serialize();';// All Checkboxes

        // If REQUIRED, don't allow to untick all checkboxes
        $s[] = '		var phRequired = jQuery(this).data("required");';
        $s[] = '        var phCheckboxAInputChecked =  "#" + jQuery(this).attr("id") + " input:checked"';
        $s[] = '        var phACheckedLength = jQuery(phCheckboxAInputChecked).length;';

        $s[] = '        if (phACheckedLength == 0) {';
        $s[] = '            var phThisLabel = jQuery(e.target).parent();';// Bootstrap checkboxes - colors, images
        $s[] = '            phThisLabel.addClass("active");';// Bootstrap checkboxes - colors, images
        $s[] = '            e.preventDefault();';
        $s[] = '            return false;';
        $s[] = '        }';

        $s[] = '		phAjaxChangeId' . $typeView . '(phProductId, phDataA1, phDataA2);';
        $s[] = '	})';

        // Change the price on time view when site is initialized
        // Because some parameters can be selected as default
        // Automatically start only in item view, not in category or another view
        /*if ($option == 'com_phocacart' && $view == 'item') {
            //$s[] = '		var phProductId = jQuery(\'.phjItemAttribute\').data(\'product-id\')';
            $s[] = '		var phDataA1 = jQuery("select.phjItemAttribute").serialize();';
            $s[] = '		var phDataA2 = jQuery(".ph-checkbox-attribute.phjItemAttribute :checkbox").serialize();';
            $s[] = '		var phpDataA = phDataA1 +\'&\'+ phDataA2;';
            $s[] = '		phAjaxChangePrice'.$typeView.'('.(int)$id.');';
        }*/
/*

        $s[] = '})';
        $s[] = ' ';
        Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
    }*/
/*
 * Change Stock
 * select box (standard, image, color)
 * check box
 */
/*
    public static function renderAjaxChangeProductStockByOptions($id = 0, $typeView = '', $class = '') {

        $paramsC                = PhocacartUtils::getComponentParameters();
        $dynamic_change_stock   = $paramsC->get('dynamic_change_stock', 0);
        $hide_add_to_cart_stock = $paramsC->get('hide_add_to_cart_stock', 0);
        $theme                  = $paramsC->get('theme', 'bs3');

        if ($dynamic_change_stock == 0) {
            return false;
        }

        $urlAjax = Uri::base(true) . '/index.php?option=com_phocacart&task=checkout.changestockbox&format=json&' . Session::getFormToken() . '=1';

       /* $s[] = ' ';
        $s[] = '/* Function phAjaxChangeStock */
/* ';
        $s[] = 'function phAjaxChangeStock' . $typeView . '(phProductId, phDataA1, phDataA2){';
        $s[] = '	var phUrl 					= "' . $urlAjax . '";';
        $s[] = '	var phId 					= phProductId;' . "\n";
        $s[] = '	var phIdItem 				= "#phItemStockBox' . $typeView . '" + phProductId;';
        $s[] = '	var phProductAddToCart 		= ".phProductAddToCart' . $typeView . '" + phProductId;';// display or hide add to cart button
        $s[] = '	var phProductAddToCartIcon 	= ".phProductAddToCartIcon' . $typeView . '" + phProductId;';// display or hide add to cart icon
        $s[] = '	var phClass 				= "' . $class . '";';
        $s[] = '	var phTypeView 				= "' . $typeView . '";';

        $s[] = '	var phData 	= \'id=\'+phId+\'&\'+phDataA1+\'&\'+phDataA2+\'&\'+\'class=\'+phClass+\'&\'+\'typeview=\'+phTypeView;';
        */
/*

        $s = array();
        $s[] = 'function phAjaxChangeStock' . $typeView . '(phProductId, phDataA1, phDataA2){';
        $s[] = '	var phUrl 	= "' . $urlAjax . '";';
        $s[] = '	var phOptions = [];';
        $s[] = '	phOptions["id"] = phProductId;';
        $s[] = '	phOptions["id_item"] = "#phItemStockBox' . $typeView . '" + phProductId;';
        $s[] = '	phOptions["product_add_to_cart_item"] 		= ".phProductAddToCart' . $typeView . '" + phProductId;';// display or hide add to cart button
        $s[] = '	phOptions["product_add_to_cart_item_icon"] 	= ".phProductAddToCartIcon' . $typeView . '" + phProductId;';// display or hide add to cart icon
        $s[] = '	phOptions["view"] = ' . (int)$typeView . ';';
        $s[] = '	phOptions["method"]  = ' . (int)$hide_add_to_cart_stock . ';';
        $s[] = '	phOptions["task"]  = "change";';
        $s[] = '	phOptions["type"]  = "changestock";';
        $s[] = '	phOptions["class"]  = "' . $class . '";';
        $s[] = '	var phData 	= \'id=\'+ phOptions["id"] +\'&\'+ phDataA1 +\'&\'+ phDataA2 +\'&\'+\'class=\'+ phOptions["class"] +\'&\'+\'typeview=\'+ phOptions["view"];';
        $s[] = '	phDoRequestMethods(phUrl, phData, phOptions);';
        $s[] = '}';
        $s[] = ' ';


/*

        $s[] = '	jQuery.ajax({';
        $s[] = '		type: "POST",';
        $s[] = '		url: phUrl,';
        $s[] = '		async: "false",';
        $s[] = '		cache: "false",';
        $s[] = '		data: phData,';
        $s[] = '		dataType:"JSON",';
        $s[] = '		success: function(data){';
        $s[] = '			if (data.status == 1){';

        if ($hide_add_to_cart_stock == 1) {
            $s[] = '				if (data.stock < 1) {';
            //$s[] = '					jQuery(phProductAddToCart).hide();';
            $s[] = '					jQuery(phProductAddToCart).css(\'visibility\', \'hidden\');';
            $s[] = '					jQuery(phProductAddToCartIcon).css(\'display\', \'none\');';

            $s[] = '				} else {';
            //$s[] = '					jQuery(phProductAddToCart).show();';
            $s[] = '					jQuery(phProductAddToCart).css(\'visibility\', \'visible\');';
            $s[] = '					jQuery(phProductAddToCartIcon).css(\'display\', \'block\');';
            $s[] = '				}';
        }

        $s[] = '				jQuery(phIdItem).html(data.item);';
        $s[] = '			  } else {';// Don't change the price box, don't render any error message
        $s[] = '			  }';
        $s[] = '		}';
        $s[] = '	})';
        $s[] = '}';
        $s[] = ' ';
*/
/*
        $s[] = 'jQuery(document).ready(function(){';
        $s[] = '	jQuery(document).on(\'change\', \'select.phj' . $typeView . '.phjProductAttribute\', function(){';// select box
        //$s[] = '		jQuery(this).off("change");';
        $s[] = '		var phProductId = jQuery(this).data(\'product-id\');';
        $s[] = '		var phProductGroup = \'.phjAddToCartV' . $typeView . 'P\' + phProductId;';
        $s[] = '		var phDataA1 = jQuery(phProductGroup).find(\'select\').serialize();';// All Selects
        $s[] = '		var phDataA2 = jQuery(phProductGroup).find(\':checkbox\').serialize();';// All Checkboxes
        $s[] = '		phAjaxChangeStock' . $typeView . '(phProductId, phDataA1, phDataA2);';// If REQUIRED, don't allow to untick image or color "select box" - see jquery.phocaattribute.js
        $s[] = '	})';

        $s[] = '    var phCheckboxA             =  ".ph-checkbox-attribute.phj' . $typeView . '.phjProductAttribute"';
        //$s[] = '    var phCheckboxAInputChecked =  phCheckboxA + " input:checked"';
        $s[] = '	jQuery(document).on(\'click\', phCheckboxA, function(e){';// check box
        $s[] = '        if (e.target.tagName.toUpperCase() === "LABEL") { return;}';// Prevent from twice running
        if ($theme == 'bs4') {
            $s[] = '        if (e.target.tagName.toUpperCase() === "SPAN" || e.target.tagName.toUpperCase() === "IMG") { return;}';// Prevent from twice running
        }
        $s[] = '		var phProductId = jQuery(this).data(\'product-id\');';
        $s[] = '		var phProductGroup = \'.phjAddToCartV' . $typeView . 'P\' + phProductId;';
        $s[] = '		var phDataA1 = jQuery(phProductGroup).find(\'select\').serialize();';// All Selects
        $s[] = '		var phDataA2 = jQuery(phProductGroup).find(\':checkbox\').serialize();';// All Checkboxes

        // If REQUIRED, don't allow to untick all checkboxes
        $s[] = '		var phRequired = jQuery(this).data("required");';
        $s[] = '        var phCheckboxAInputChecked =  "#" + jQuery(this).attr("id") + " input:checked"';
        $s[] = '        var phACheckedLength = jQuery(phCheckboxAInputChecked).length;';

        $s[] = '        if (phACheckedLength == 0) {';
        $s[] = '            var phThisLabel = jQuery(e.target).parent();';// Bootstrap checkboxes - colors, images
        $s[] = '            phThisLabel.addClass("active");';// Bootstrap checkboxes - colors, images
        $s[] = '            e.preventDefault();';
        $s[] = '            return false;';
        $s[] = '        }';

        $s[] = '		phAjaxChangeStock' . $typeView . '(phProductId, phDataA1, phDataA2);';
        $s[] = '	})';

        $s[] = '})';
        $s[] = ' ';
        Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
    }*/
/*
 * JS equivalent to PhocacartPrice::getPriceFormat();
 */
public static function getPriceFormatJavascript($price_decimals, $price_dec_symbol, $price_thousands_sep, $price_currency_symbol, $price_prefix, $price_suffix, $price_format)
{
    //JFactory::getDocument()->addScript(JUri::root(true).'/media/com_phocacart/js/number_format.js');
    $s = array();
    $s[] = 'function phGetPriceFormat($price) {';
    $s[] = '	var $negative = 0;';
    $s[] = ' 	if ($price < 0) {';
    $s[] = ' 		$negative = 1;';
    $s[] = '	}';
    $s[] = '	if ($negative == 1 ) {';
    $s[] = ' 		$price = Math.abs($price);';
    $s[] = ' 	}';
    $s[] = ' 	$price = phNumberFormat($price, "' . $price_decimals . '", "' . $price_dec_symbol . '", "' . $price_thousands_sep . '");';
    switch ($price_format) {
        case 1:
            $s[] = '	$price = $price + "' . $price_currency_symbol . '";';
            break;
        case 2:
            $s[] = '	$price = "' . $price_currency_symbol . '" + $price;';
            break;
        case 3:
            $s[] = '	$price = "' . $price_currency_symbol . '" + " " + $price;';
            break;
        case 0:
        default:
            $s[] = '	$price = $price + " " + "' . $price_currency_symbol . '";';
            break;
    }
    $s[] = '	if ($negative == 1) {';
    $s[] = '		return "- " + "' . addslashes($price_prefix) . '" + $price + "' . addslashes($price_suffix) . '";';
    $s[] = '	} else {';
    $s[] = '		return "' . addslashes($price_prefix) . '" + $price + "' . addslashes($price_suffix) . '";';
    $s[] = '	}';
    $s[] = '}';
    $s[] = ' ';
    Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
}