本文整理汇总了PHP中Shopp::currency_format方法的典型用法代码示例。如果您正苦于以下问题:PHP Shopp::currency_format方法的具体用法?PHP Shopp::currency_format怎么用?PHP Shopp::currency_format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shopp
的用法示例。
在下文中一共展示了Shopp::currency_format方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: roundprice
/**
* 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: shopp_default_script_settings
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: _currency_regex
/**
* 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;
}