当前位置: 首页>>代码示例>>PHP>>正文


PHP Shopp::taxrate方法代码示例

本文整理汇总了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);
}
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:7,代码来源:Core.php

示例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;
//.........这里部分代码省略.........
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:101,代码来源:product.php

示例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;
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:39,代码来源:product.php


注:本文中的Shopp::taxrate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。