public static function get_tax_for_display($tax_class)
 {
     $return = false;
     if (fflcommerce_cart::get_tax_amount($tax_class, false) > 0 && fflcommerce_cart::get_tax_rate($tax_class) > 0 || fflcommerce_cart::get_tax_rate($tax_class) !== false) {
         $return = self::$tax->get_tax_class_for_display($tax_class) . ' (' . (double) fflcommerce_cart::get_tax_rate($tax_class) . '%) ';
         // only show estimated tag when customer is on the cart page and no shipping calculator is enabled to be able to change country
         if (!fflcommerce_shipping::show_shipping_calculator() && is_cart()) {
             $return .= '<small>' . sprintf(__('estimated for: %s', 'fflcommerece'), fflcommerce_countries::get_country(fflcommerce_tax::get_customer_country())) . '</small>';
         }
     }
     return $return;
 }
예제 #2
0
        ?>
					<?php 
        if ($options->get('fflcommerce_calc_taxes') == 'yes') {
            foreach (fflcommerce_cart::get_applied_tax_classes() as $tax_class) {
                if (fflcommerce_cart::get_tax_for_display($tax_class)) {
                    ?>
								<tr data-tax="<?php 
                    echo $tax_class;
                    ?>
">
									<th class="cart-row-tax-title"><?php 
                    echo fflcommerce_cart::get_tax_for_display($tax_class);
                    ?>
</th>
									<td class="cart-row-tax"><?php 
                    echo fflcommerce_cart::get_tax_amount($tax_class);
                    ?>
</td>
								</tr>
							<?php 
                }
            }
        }
        ?>
					<?php 
        if (!fflcommerce_cart::tax_after_coupon() && fflcommerce_cart::get_total_discount()) {
            ?>
						<tr class="discount">
							<th class="cart-row-discount-title"><?php 
            _e('Discount', 'fflcommerce');
            ?>
예제 #3
0
function fflcommerce_ajax_update_item_quantity()
{
    /** @var fflcommerce_cart $cart */
    $cart = fflcommerce_cart::instance();
    $cart->set_quantity($_POST['item'], (int) $_POST['qty']);
    $items = $cart->get_cart();
    $price = -1;
    if (isset($items[$_POST['item']])) {
        $item = $items[$_POST['item']];
        /** @var fflcommerce_product $product */
        $product = $item['data'];
        $price = apply_filters('fflcommerce_product_subtotal_display_in_cart', fflcommerce_price($product->get_defined_price() * $item['quantity']), $item['product_id'], $item);
    }
    if (fflcommerce_cart::show_retail_price()) {
        $subtotal = fflcommerce_cart::get_cart_subtotal(true, false, true);
    } else {
        if (fflcommerce_cart::show_retail_price() && FFLCommerce_Base::get_options()->get('fflcommerce_prices_include_tax') == 'no') {
            $subtotal = fflcommerce_cart::get_cart_subtotal(true, true);
        } else {
            $subtotal = fflcommerce_cart::$cart_contents_total_ex_tax + fflcommerce_cart::$shipping_total;
            $subtotal = fflcommerce_price($subtotal, array('ex_tax_label' => 1));
        }
    }
    $tax = array();
    foreach (fflcommerce_cart::get_applied_tax_classes() as $tax_class) {
        if (fflcommerce_cart::get_tax_for_display($tax_class)) {
            $tax[$tax_class] = fflcommerce_cart::get_tax_amount($tax_class);
        }
    }
    $shipping = fflcommerce_cart::get_cart_shipping_total(true, true) . '<small>' . fflcommerce_cart::get_cart_shipping_title() . '</small>';
    $discount = '-' . fflcommerce_cart::get_total_discount();
    $total = fflcommerce_cart::get_total();
    echo json_encode(array('success' => true, 'item_price' => $price, 'subtotal' => $subtotal, 'shipping' => $shipping, 'discount' => $discount, 'tax' => $tax, 'total' => $total));
    exit;
}