Ejemplo n.º 1
0
						<tr class="discount">
							<th class="cart-row-discount-title"><?php 
            _e('Discount', 'fflcommerce');
            ?>
</th>
							<td class="cart-row-discount">-<?php 
            echo fflcommerce_cart::get_total_discount();
            ?>
</td>
						</tr>
					<?php 
        }
        ?>
					<?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>
Ejemplo n.º 2
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;
}