WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Bakery Shop => Topic started by: sky writer on September 24, 2015, 04:29:32 AM

Title: Final Checkout TXT_BUY showing Country Code
Post by: sky writer on September 24, 2015, 04:29:32 AM
When you reach the final checkout page, the button for TXT_BUY does not show what is in the EN.PHP language file "Buy", it shows - "Buy CAD 544.50"
I've searched around the files and I believe this is being populated by/jquery/calc_price.js

My question is, how can I remove the "CAD" country code from this button.  I would like it to just show "Buy 544.50", or even "Buy Now".

Code: [Select]
(function($) {
    $.fn.calcPrice = function() {

        // Get basic price and keep it stored in global var
        if (typeof basic_price === 'undefined') {
            basic_price = container.text().replace(/\D/g, '');
            basic_price = parseFloat(basic_price / 100);
        }
        var price = basic_price;

        // Loop through selected options
        $.each(this, function(key, value) {
            var sel_option = $(value);
            // Split the selected option into attribute / currency / sign / price
            arr = sel_option.text().match(/(.*)([A-Z]{3}) ([+,-]?)(.*)/);

            if (arr) {
                var sign      = arr[3];
                var opt_price = parseFloat(arr[4]);
                // Calculate new price
                if (sign == '+') {
                    price = price + opt_price;
                } else if (sign == '-') {
                    price = price - opt_price;
                } else {
                    price = opt_price;
                }
            }
        });

        // Money number format
        // Adapted from: http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript
        var n = price,
        c = 2,
        d = decimal_sep,
        t = thousands_sep,
        sign = (n < 0) ? '-' : '',
        i = parseInt(n = Math.abs(n).toFixed(c)) + '',
        j = ((j = i.length) > 3) ? j % 3 : 0;

        new_price = sign + (j ? i.substr(0, j) + t : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : '');

        // Refresh item price on page
        container.html(currency + ' ' + new_price);

    };
})(jQuery);
Title: Re: Final Checkout TXT_BUY showing Country Code
Post by: sky writer on September 24, 2015, 04:57:30 AM
I found it in "/view_summary.php"

Line 850
Code: [Select]
'TXT_BUY'                    =>    $MOD_BAKERY['TXT_BUY'].' '.$setting_shop_currency.' '.$f_order_total
Maybe this will help others.