本文整理匯總了PHP中Shopp::taxrate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Shopp::taxrate方法的具體用法?PHP Shopp::taxrate怎麽用?PHP Shopp::taxrate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Shopp
的用法示例。
在下文中一共展示了Shopp::taxrate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: shopp_taxrate
/**
* @deprecated Use Shopp::taxrate()
**/
function shopp_taxrate($override = null, $taxprice = true, $Item = false)
{
return Shopp::taxrate($Item);
}
示例2: variants
/**
* Iterate over the product variants or provide markup for a product variants chooser widget
*
* @api `shopp('product.variants')`
* @since 1.1
*
* @param string $result The output
* @param array $options The options
* - **mode**: `loop` (loop, single, multiple) Iterate over the variants with `loop` or provide an variant chooser widget using a `single` drop-down menu for all variants or `multiple` menus
* - **defaults**: Specify a default option that is displayed as the initial selection for the `menu`
* - **before_menu**: Markup to add before the widget
* - **after_menu**: Markup to add after the widget
* - **label**: `on` (on,off) Show or hide the menu name labels from the `menu` widget
* - **format**: `%l (+%p)` The variant option label format
* - **%p**: shows the current variant price including available discounts.
* - **%l**: show the option label.
* - **%s**: show the stock amount of a product in inventory
* - **%d**: show the discount amount of an on sale variant.
* - **%r**: show the original price (the non-sale price) of the product variant.
* - **%u**: show the SKU for the product variant.
* - **required**: `You must select the options for this item before you can add it to your shopping cart.` The error message to show when adding to the cart without selecting an variant when the **required** option is `on`
* - **taxes**: Include or exclude taxes from prices
* - **class**: The class attribute specifies one or more class-names for the menu elements
* @param ShoppProduct $O The working object
* @return bool|string True if the next variant exists, or false otherwise, or the variant chooser markup
**/
public static function variants($result, $options, $O)
{
$string = '';
if (!isset($options['mode'])) {
if (!isset($O->_prices_loop)) {
reset($O->prices);
$O->_prices_loop = true;
} else {
next($O->prices);
}
$price = current($O->prices);
while (false !== $price && ('N/A' == $price->type || 'variation' != $price->context)) {
$price = next($O->prices);
}
if (false !== current($O->prices)) {
return true;
} else {
$O->_prices_loop = false;
return false;
}
}
if (shopp_setting_enabled('inventory') && $O->outofstock) {
return false;
}
// Completely out of stock, hide menus
if (!isset($options['taxes'])) {
$options['taxes'] = null;
}
$defaults = array('defaults' => '', 'disabled' => 'show', 'pricetags' => 'show', 'before_menu' => '', 'after_menu' => '', 'format' => '%l (%p)', 'label' => 'on', 'mode' => 'multiple', 'taxes' => null, 'required' => __('You must select the options for this item before you can add it to your shopping cart.', 'Shopp'));
$options = array_merge($defaults, $options);
extract($options);
$taxes = isset($taxes) ? Shopp::str_true($taxes) : null;
$taxrates = self::_taxes($O, 'price');
$collection_class = ShoppCollection() && isset(ShoppCollection()->slug) ? 'category-' . ShoppCollection()->slug : '';
if ('single' == $mode) {
if (!empty($before_menu)) {
$string .= $before_menu . "\n";
}
if (Shopp::str_true($label)) {
$string .= '<label for="product-options' . (int) $O->id . '">' . Shopp::esc_html__('Options') . ': </label> ' . "\n";
}
$string .= '<select name="products[' . (int) $O->id . '][price]" id="product-options' . (int) $O->id . '" class="' . esc_attr($collection_class) . ' product' . (int) $O->id . ' options">';
if (!empty($defaults)) {
$string .= '<option value="">' . esc_html($options['defaults']) . '</option>' . "\n";
}
foreach ($O->prices as $pricing) {
if ('variation' != $pricing->context) {
continue;
}
$currently = Shopp::str_true($pricing->sale) ? $pricing->promoprice : $pricing->price;
$disable = $pricing->type == 'N/A' || Shopp::str_true($pricing->inventory) && $pricing->stock == 0;
$currently = self::_taxed((double) $currently, $O, $pricing->tax, $taxes);
$discount = 0 == $pricing->price ? 0 : 100 - round($pricing->promoprice * 100 / $pricing->price);
$_ = new StdClass();
$_->p = 'Donation' != $pricing->type && !$disable ? money($currently) : false;
$_->l = $pricing->label;
$_->i = Shopp::str_true($pricing->inventory);
$_->s = $_->i ? (int) $pricing->stock : false;
$_->u = $pricing->sku;
$_->tax = Shopp::str_true($pricing->tax);
$_->t = $pricing->type;
$_->r = $pricing->promoprice != $pricing->price ? money($pricing->price) : false;
$_->d = $discount > 0 ? $discount : false;
if (!$disable || 'show' == $disabled) {
$string .= '<option value="' . $pricing->id . '"' . ($disable ? ' disabled="disabled"' : '') . '>' . esc_html(self::_variant_formatlabel($format, $_)) . '</option>' . "\n";
}
}
$string .= '</select>';
if (!empty($options['after_menu'])) {
$string .= $options['after_menu'] . "\n";
}
} else {
if (!isset($O->options)) {
return;
//.........這裏部分代碼省略.........
示例3: shopp_product_variant_set_price
/**
* shopp_product_variant_set_price - set the price of a variant
*
* @api
* @since 1.2
*
* @param int/Price $variant (required) The priceline id to set the price on, or the Price object to change. If Price object is specified, the object will be returned, but not saved to the database.
* @param float $price the price to be set
* @param string $context (optional default:variant) enforces the priceline is a 'product','variant', or 'addon'
* @return bool/Price false on failure, true if Price saved, else the modified Price object.
**/
function shopp_product_variant_set_price($variant = false, $price = 0.0, $context = 'variant')
{
$context = 'variant' == $context ? 'variation' : $context;
$save = true;
if (is_object($variant) && is_a($variant, 'ShoppPrice')) {
$Price = $variant;
$save = false;
} else {
if (false == $variant) {
shopp_debug(__FUNCTION__ . " failed: Variant id required.");
return false;
}
$Price = new ShoppPrice($variant);
if (empty($Price->id) || $Price->context != $context) {
shopp_debug(__FUNCTION__ . " failed: No such {$context} with id {$variant}.");
}
}
if (shopp_setting_enabled('tax_inclusive') && isset($Price->tax) && Shopp::str_true($Price->tax)) {
$Product = new ShoppProduct($Price->product);
$taxrate = Shopp::taxrate($Product);
$price = Shopp::floatval($price / (1 + $taxrate));
}
$Price->price = $price;
if ($save) {
return $Price->save();
}
return $Price;
}