示例#1
0
 /**
  * Rounds a price amount with the store's currency format
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @param float $amount The number to be rounded
  * @param array $format (optional) The formatting settings to use,
  * @return float The rounded float
  **/
 public static function roundprice($amount, $format = array())
 {
     $format = Shopp::currency_format($format);
     extract($format);
     return round($amount, $precision);
 }
示例#2
0
function shopp_default_script_settings()
{
    $base = array();
    $settings = Shopp::currency_format();
    if (!empty($settings)) {
        $currency = array('cp' => $settings['cpos'], 'c' => $settings['currency'], 'p' => (int) $settings['precision'], 't' => $settings['thousands'], 'd' => $settings['decimals']);
        if (isset($settings['grouping'])) {
            $currency['g'] = is_array($settings['grouping']) ? join(',', $settings['grouping']) : $settings['grouping'];
        }
    }
    if (!is_admin()) {
        $base = array('nocache' => is_shopp_page('account'));
    }
    // Validation alerts
    shopp_localize_script('catalog', '$cv', array('field' => __('Your %s is required.', 'Shopp'), 'email' => __('The e-mail address you provided does not appear to be a valid address.', 'Shopp'), 'minlen' => __('The %s you entered is too short. It must be at least %d characters long.', 'Shopp'), 'pwdmm' => __('The passwords you entered do not match. They must match in order to confirm you are correctly entering the password you want to use.', 'Shopp'), 'chkbox' => __('%s must be checked before you can proceed.', 'Shopp')));
    // Checkout page settings & localization
    shopp_localize_script('checkout', '$co', array('ajaxurl' => admin_url('admin-ajax.php'), 'loginname' => Shopp::__('You did not enter a login.'), 'loginpwd' => Shopp::__('You did not enter a password to login with.'), 'badpan' => Shopp::__('Not a valid card number.'), 'submitting' => Shopp::__('Submitting…'), 'error' => Shopp::__('An error occurred while submitting your order. Please try submitting your order again.'), 'timeout' => (int) SHOPP_SUBMIT_TIMEOUT));
    // Validation alerts
    shopp_localize_script('cart', '$ct', array('items' => __('Items', 'Shopp'), 'total' => __('Total', 'Shopp')));
    // Calendar localization
    shopp_localize_script('calendar', '$cal', array('jan' => __('January', 'Shopp'), 'feb' => __('February', 'Shopp'), 'mar' => __('March', 'Shopp'), 'apr' => __('April', 'Shopp'), 'may' => __('May', 'Shopp'), 'jun' => __('June', 'Shopp'), 'jul' => __('July', 'Shopp'), 'aug' => __('August', 'Shopp'), 'sep' => __('September', 'Shopp'), 'oct' => __('October', 'Shopp'), 'nov' => __('November', 'Shopp'), 'dec' => __('December', 'Shopp'), 'sun' => __('Sun', 'Shopp'), 'mon' => __('Mon', 'Shopp'), 'tue' => __('Tue', 'Shopp'), 'wed' => __('Wed', 'Shopp'), 'thu' => __('Thu', 'Shopp'), 'fri' => __('Fri', 'Shopp'), 'sat' => __('Sat', 'Shopp')));
    // Product editor: unsaved changes warning
    shopp_localize_script('product-editor', '$msg', array('confirm' => __('The changes you made will be lost if you navigate away from this page.', 'Shopp')));
    $defaults = apply_filters('shopp_js_settings', array_merge($currency, $base));
    shopp_localize_script('shopp', '$s', $defaults);
}
示例#3
0
 /**
  * Builds a regular express to match the current currency format
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @param boolean $symbol (optional) Require currency symbol - required by default
  * @return string The current currency regex pattern
  **/
 public static function _currency_regex($symbol = true)
 {
     $format = Shopp::currency_format();
     extract($format);
     $pre = $cpos ? '' . preg_quote($currency) . ($symbol ? '' : '?') : '';
     $amount = '[\\d' . preg_quote($thousands) . ']+';
     $fractional = '(' . preg_quote($decimals) . '\\d{' . $precision . '}?)?';
     $post = !$cpos ? '' . preg_quote($currency) . ($symbol ? '' : '?') : '';
     return $pre . $amount . $fractional . $post;
 }