Example #1
0
 /**
  * Get the legend for the main chart sidebar
  *
  * @return array
  */
 public function getChartLegend()
 {
     $legend = array();
     switch ($this->chartGroupBy) {
         case 'hour':
             /** @noinspection PhpUndefinedFieldInspection */
             $average_sales_title = sprintf(__('%s average sales per hour', 'jigoshop'), '<strong>' . Product::formatPrice($this->reportData->averageSales) . '</strong>');
             break;
         case 'day':
             /** @noinspection PhpUndefinedFieldInspection */
             $average_sales_title = sprintf(__('%s average daily sales', 'jigoshop'), '<strong>' . Product::formatPrice($this->reportData->averageSales) . '</strong>');
             break;
         case 'month':
         default:
             /** @noinspection PhpUndefinedFieldInspection */
             $average_sales_title = sprintf(__('%s average monthly sales', 'jigoshop'), '<strong>' . Product::formatPrice($this->reportData->averageSales) . '</strong>');
             break;
     }
     /** @noinspection PhpUndefinedFieldInspection */
     $legend[] = array('title' => sprintf(__('%s gross sales in this period', 'jigoshop'), '<strong>' . Product::formatPrice($this->reportData->totalSales) . '</strong>'), 'tip' => __('This is the sum of the order totals including shipping and taxes.', 'jigoshop'), 'color' => $this->chartColours['sales_amount'], 'highlight_series' => 5);
     /** @noinspection PhpUndefinedFieldInspection */
     $legend[] = array('title' => sprintf(__('%s net sales in this period', 'jigoshop'), '<strong>' . Product::formatPrice($this->reportData->netSales) . '</strong>'), 'tip' => __('This is the sum of the order totals excluding shipping and taxes.', 'jigoshop'), 'color' => $this->chartColours['net_sales_amount'], 'highlight_series' => 6);
     $legend[] = array('title' => $average_sales_title, 'color' => $this->chartColours['average'], 'highlight_series' => 2);
     /** @noinspection PhpUndefinedFieldInspection */
     $legend[] = array('title' => sprintf(__('%s orders placed', 'jigoshop'), '<strong>' . $this->reportData->totalOrders . '</strong>'), 'color' => $this->chartColours['order_count'], 'highlight_series' => 1);
     /** @noinspection PhpUndefinedFieldInspection */
     $legend[] = array('title' => sprintf(__('%s items purchased', 'jigoshop'), '<strong>' . $this->reportData->totalItems . '</strong>'), 'color' => $this->chartColours['item_count'], 'highlight_series' => 0);
     /** @noinspection PhpUndefinedFieldInspection */
     $legend[] = array('title' => sprintf(__('%s charged for shipping', 'jigoshop'), '<strong>' . Product::formatPrice($this->reportData->totalShipping) . '</strong>'), 'color' => $this->chartColours['shipping_amount'], 'highlight_series' => 4);
     /** @noinspection PhpUndefinedFieldInspection */
     $legend[] = array('title' => sprintf(__('%s worth of coupons used', 'jigoshop'), '<strong>' . Product::formatPrice($this->reportData->totalCoupons) . '</strong>'), 'color' => $this->chartColours['coupon_amount'], 'highlight_series' => 3);
     return $legend;
 }
Example #2
0
 public function getArgs()
 {
     $args = array();
     foreach ($this->topEarners as $product) {
         $args[] = array('total' => Product::formatPrice($product->price), 'id' => $product->id, 'url' => esc_url(add_query_arg('product_ids', $product->id, add_query_arg('last_used', self::SLUG))), 'title' => $product->title);
     }
     return $args;
 }
Example #3
0
 public function getArgs()
 {
     $args = array();
     foreach ($this->mostDiscount as $coupon) {
         $args[] = array('total' => Product::formatPrice($coupon['amount']), 'url' => esc_url(add_query_arg('coupon_codes', $coupon['code'], add_query_arg('last_used', self::SLUG))), 'title' => $coupon['code']);
     }
     return $args;
 }
Example #4
0
 /**
  * @return array
  */
 public function getChartLegend()
 {
     $legend = array();
     $this->getReportData();
     $totalDiscount = 0;
     $totalCoupons = 0;
     foreach ($this->reportData->orderCoupons as $order) {
         $totalDiscount += array_sum(array_map(function ($coupon) {
             return $coupon['amount'];
         }, $order->coupons));
         $totalCoupons += array_sum(array_map(function ($coupon) {
             return $coupon['usage'];
         }, $order->coupons));
     }
     $legend[] = array('title' => sprintf(__('%s discounts in total', 'jigoshop'), '<strong>' . Product::formatPrice($totalDiscount) . '</strong>'), 'color' => $this->chartColours['discount_amount'], 'highlight_series' => 1);
     $legend[] = array('title' => sprintf(__('%s coupons used in total', 'jigoshop'), '<strong>' . $totalCoupons . '</strong>'), 'color' => $this->chartColours['coupon_count'], 'highlight_series' => 0);
     return $legend;
 }
Example #5
0
 /**
  * Get the legend for the main chart sidebar
  *
  * @return array
  */
 public function getChartLegend()
 {
     if (!$this->productIds) {
         return array();
     }
     $legend = array();
     $totalSales = array_sum(array_map(function ($item) {
         return $item->order_item_amount;
     }, $this->reportData->orderItems));
     $totalItems = array_sum(array_map(function ($item) {
         return $item->order_item_count;
     }, $this->reportData->orderItems));
     $totalQuantity = array_sum(array_map(function ($item) {
         return $item->order_item_quantity;
     }, $this->reportData->orderItems));
     $legend[] = array('title' => sprintf(__('%s sales for the selected items', 'jigoshop'), '<strong>' . Product::formatPrice($totalSales) . '</strong>'), 'color' => $this->chartColours['sales_amount'], 'highlight_series' => 2);
     $legend[] = array('title' => sprintf(__('%s purchases for the selected items', 'jigoshop'), '<strong>' . $totalItems . '</strong>'), 'color' => $this->chartColours['item_count'], 'highlight_series' => 1);
     $legend[] = array('title' => sprintf(__('%s purchased quantity', 'jigoshop'), '<strong>' . $totalQuantity . '</strong>'), 'color' => $this->chartColours['item_quantity'], 'highlight_series' => 0);
     return $legend;
 }
Example #6
0
 /**
  * Get the legend for the main chart sidebar
  *
  * @return array
  */
 public function getChartLegend()
 {
     if (!$this->showCategories) {
         return array();
     }
     $legend = array();
     $index = 0;
     foreach ($this->showCategories as $category) {
         $category = get_term($category, 'product_category');
         $total = 0;
         $product_ids = $this->getProductsInCategory($category->term_id);
         foreach ($product_ids as $id) {
             if (isset($this->reportData->itemSales[$id])) {
                 $total += $this->reportData->itemSales[$id];
             }
         }
         $legend[] = array('title' => sprintf(__('%s sales in %s', 'jigoshop'), '<strong>' . Product::formatPrice($total) . '</strong>', $category->name), 'color' => $this->chartColours[$index % sizeof($this->chartColours)], 'highlight_series' => $index);
         $index++;
     }
     return $legend;
 }
Example #7
0
?>
</a></td>
	<td class="product-name">
		<a href="<?php 
echo $url;
?>
"><?php 
echo apply_filters('jigoshop\\template\\shop\\checkout\\product_title', $product->getName(), $product, $item);
?>
</a>
		<?php 
echo Product::getVariation($variation, $item);
?>
		<?php 
do_action('jigoshop\\template\\shop\\checkout\\after_product_title', $product, $item);
?>
	</td>
	<td class="product-price"><?php 
echo Product::formatPrice($price);
?>
</td>
	<td class="product-quantity"><?php 
echo $item->getQuantity();
?>
</td>
	<td class="product-subtotal"><?php 
echo Product::formatPrice($item->getQuantity() * $price);
?>
</td>
</tr>
Example #8
0
		<a href="<?php 
echo $url;
?>
"><?php 
echo apply_filters('jigoshop\\template\\shop\\cart\\product_title', $product->getName(), $product, $item);
?>
</a>
		<?php 
echo Product::getVariation($variation, $item);
?>
		<?php 
do_action('jigoshop\\template\\shop\\cart\\after_product_title', $product, $item);
?>
	</td>
	<td class="product-price"><?php 
echo apply_filters('jigoshop\\template\\shop\\cart\\product_price', Product::formatPrice($price), $price, $product, $item);
?>
</td>
	<td class="product-quantity"><input type="number" name="cart[<?php 
echo $key;
?>
]" value="<?php 
echo $item->getQuantity();
?>
" /></td>
	<td class="product-subtotal"><?php 
echo apply_filters('jigoshop\\template\\shop\\cart\\product_subtotal', Product::formatPrice($item->getQuantity() * $price), $item->getQuantity() * $price, $product, $item);
?>
</td>
</tr>
Example #9
0
<?php

use Jigoshop\Helper\Forms;
use Jigoshop\Helper\Product;
/**
 * @var $method \Jigoshop\Shipping\Method Method to display.
 * @var $order \Jigoshop\Entity\Order Order to display.
 */
?>
<li class="list-group-item shipping-<?php 
echo $method->getId();
?>
 clearfix">
	<label>
		<input type="radio" name="order[shipping]" value="<?php 
echo $method->getId();
?>
" <?php 
echo Forms::checked($order->hasShippingMethod($method), true);
?>
 />
		<?php 
echo $method->getName();
?>
	</label>
	<span class="pull-right"><?php 
echo Product::formatPrice($method->calculate($order));
?>
</span>
</li>
Example #10
0
    ?>
			<span class="order-time"><?php 
    echo get_the_time(_x('M d, Y', 'dashboard', 'jigoshop'), $order->getId());
    ?>
</span>
			<small>
				<?php 
    echo count($order->getItems());
    ?>
 <?php 
    echo _n('Item', 'Items', count($order->getItems()), 'jigoshop');
    ?>
,
				<span	class="total-quantity"><?php 
    echo __('Total Quantity', 'jigoshop');
    ?>
 <?php 
    echo $totalItems;
    ?>
</span>
				<span	class="order-cost"><?php 
    echo Helper\Product::formatPrice($order->getTotal());
    ?>
</span>
			</small>
		</li>
	<?php 
}
?>
</ul>
Example #11
0
		<span class="js_widget_product_price"><?php 
        echo $item->getQuantity() . ' &times; ' . Product::formatPrice($item->getPrice());
        ?>
</span>
	</li>
	<?php 
    }
    ?>
</ul>
<p class="total">
	<strong><?php 
    _e('Subtotal', 'jigoshop');
    ?>
:</strong>
	<?php 
    echo Product::formatPrice($cart->getTotal());
    ?>
	<?php 
    do_action('jigoshop_widget_cart_before_buttons');
    ?>
	<p class="buttons">
		<a href="<?php 
    echo $cart_url;
    ?>
" class="btn btn-default"><?php 
    _e($view_cart_label, 'jigoshop');
    ?>
</a>
		<a href="<?php 
    echo $checkout_url;
    ?>
Example #12
0
 /**
  * @param Wordpress $wp
  */
 public function addFrontendAssets(Wordpress $wp)
 {
     $post = $wp->getGlobalPost();
     $product = $this->productService->findForPost($post);
     if ($product instanceof Product\Variable) {
         $variations = array();
         foreach ($product->getVariations() as $variation) {
             /** @var $variation Product\Variable\Variation */
             $variations[$variation->getId()] = array('price' => $variation->getProduct()->getPrice(), 'html' => array('price' => \Jigoshop\Helper\Product::formatPrice($variation->getProduct()->getPrice())), 'attributes' => array());
             foreach ($variation->getAttributes() as $attribute) {
                 /** @var $attribute Product\Variable\Attribute */
                 $variations[$variation->getId()]['attributes'][$attribute->getAttribute()->getId()] = $attribute->getValue();
             }
         }
         Styles::add('jigoshop.product.variable', \JigoshopInit::getUrl() . '/assets/css/shop/product/variable.css');
         Scripts::add('jigoshop.product.variable', \JigoshopInit::getUrl() . '/assets/js/shop/product/variable.js', array('jquery'));
         Scripts::localize('jigoshop.product.variable', 'jigoshop_product_variable', array('variations' => $variations));
     }
 }
Example #13
0
 /**
  * Processes change of item quantity and returns updated item value and cart details.
  */
 public function ajaxUpdateItem()
 {
     $cart = $this->cartService->getCurrent();
     try {
         $cart->updateQuantity($_POST['item'], (int) $_POST['quantity']);
         $this->cartService->save($cart);
         $item = $cart->getItem($_POST['item']);
         if ($item === null) {
             throw new Exception(__('Item not found.', 'jigoshop'));
         }
         // TODO: Support for "Prices includes tax"
         $price = $this->options->get('tax.price_tax') == 'with_tax' ? $item->getPrice() + $item->getTax() / $item->getQuantity() : $item->getPrice();
         $response = $this->getAjaxCartResponse($cart);
         // Add some additional fields
         $response['item_price'] = $price;
         $response['item_subtotal'] = $price * $item->getQuantity();
         $response['html']['item_price'] = Product::formatPrice($price);
         $response['html']['item_subtotal'] = Product::formatPrice($price * $item->getQuantity());
     } catch (NotEnoughStockException $e) {
         $response = array('success' => false, 'error' => sprintf(__('Sorry, we do not have enough units in stock. We have got only %s in stock', 'jigoshop'), $e->getStock()));
     } catch (Exception $e) {
         if ($cart->isEmpty()) {
             $response = array('success' => true, 'empty_cart' => true, 'html' => Render::get('shop/cart/empty', array('shopUrl' => $this->wp->getPermalink($this->options->getPageId(Pages::SHOP)))));
         } else {
             $response = $this->getAjaxCartResponse($cart);
             $response['remove_item'] = true;
         }
     }
     echo json_encode($response);
     exit;
 }
Example #14
0
    ?>
					<?php 
}
?>
				</ul>
			</div>
		</div>
		<?php 
Forms::constant(array('name' => 'order[subtotal]', 'id' => 'subtotal', 'label' => __('Subtotal', 'jigoshop'), 'placeholder' => 0.0, 'size' => 12, 'value' => Product::formatPrice($order->getSubtotal())));
?>
		<?php 
Forms::text(array('name' => 'order[discount]', 'label' => sprintf(__('Discount (%s)', 'jigoshop'), Currency::symbol()), 'placeholder' => 0.0, 'value' => $order->getDiscount()));
?>
		<?php 
foreach ($tax as $class => $option) {
    ?>
			<?php 
    Forms::constant(array('name' => 'order[tax][' . $class . ']', 'label' => $option['label'], 'placeholder' => 0.0, 'value' => $option['value'], 'size' => 12, 'classes' => array($orderTax[$class] > 0 ? '' : 'not-active')));
    ?>
		<?php 
}
?>
		<?php 
Forms::constant(array('name' => 'order[total]', 'id' => 'total', 'label' => __('Total', 'jigoshop'), 'placeholder' => 0.0, 'size' => 12, 'value' => Product::formatPrice($order->getTotal())));
?>
		<?php 
do_action('jigoshop\\admin\\order\\totalsBox\\after_total', $order);
?>
	</div>
</div>
Example #15
0
 private function getRow($user, $columnKey)
 {
     switch ($columnKey) {
         case 'customer_name':
             return $user->last_name && $user->first_name ? $user->last_name . ', ' . $user->first_name : '-';
         case 'username':
             return $user->user_login;
         case 'location':
             $stateCode = $this->wp->getUserMeta($user->ID, 'billing_state', true);
             $countryCode = $this->wp->getUserMeta($user->ID, 'billing_country', true);
             $state = Country::hasState($countryCode, $stateCode) ? Country::getStateName($countryCode, $stateCode) : $stateCode;
             $country = Country::exists($countryCode) ? Country::getName($countryCode) : $countryCode;
             $value = '';
             if ($state) {
                 $value .= $state . ', ';
             }
             $value .= $country;
             if ($value) {
                 return $value;
             } else {
                 return '-';
             }
         case 'email':
             return '<a href="mailto:' . $user->user_email . '">' . $user->user_email . '</a>';
         case 'spent':
             return Product::formatPrice($this->getCustomerTotalSpent($user->ID));
         case 'orders':
             return $this->getCustomerOrderCount($user->ID);
         case 'last_order':
             $lastOrder = $this->getCustomerLastOrder($user->ID);
             if ($lastOrder) {
                 /** @var \Jigoshop\Entity\Order $order */
                 $order = $this->orderService->find($lastOrder->order_id);
                 return '<a href="' . admin_url('post.php?post=' . $lastOrder->order_id . '&action=edit') . '">#' . $order->getNumber() . '</a> &ndash; ' . date_i18n(get_option('date_format'), strtotime($lastOrder->order_date));
             }
             return '-';
         case 'user_actions':
             $actions = array();
             $actions['edit'] = array('url' => admin_url('user-edit.php?user_id=' . $user->ID), 'name' => __('Edit', 'jigoshop'), 'action' => 'edit');
             $actions = $this->wp->applyFilters('jigoshop\\admin\\reports\\table\\customer_list\\user_actions', $actions, $user);
             return $actions;
         default:
             return $this->wp->applyFilters('jigoshop\\admin\\reports\\table\\customer_list\\row', '', $user, $columnKey);
     }
 }
Example #16
0
 public function ajaxUpdateProduct()
 {
     try {
         if (!is_numeric($_POST['quantity']) || $_POST['quantity'] < 0) {
             throw new Exception(__('Invalid quantity value.', 'jigoshop'));
         }
         if (!is_numeric($_POST['price']) || $_POST['price'] < 0) {
             throw new Exception(__('Invalid product price.', 'jigoshop'));
         }
         /** @var \Jigoshop\Entity\Order $order */
         $order = $this->orderService->find((int) $_POST['order']);
         if ($order->getId() === null) {
             throw new Exception(__('Order not found.', 'jigoshop'));
         }
         $item = $order->removeItem($_POST['product']);
         if ($item === null) {
             throw new Exception(__('Item not found.', 'jigoshop'));
         }
         $item->setQuantity((int) $_POST['quantity']);
         $item->setPrice((double) $_POST['price']);
         if ($item->getQuantity() > 0) {
             $item = $this->wp->applyFilters('jigoshop\\admin\\order\\update_product', $item, $order);
             $order->addItem($item);
         }
         $this->orderService->save($order);
         $result = $this->getAjaxResponse($order);
         $result['item_cost'] = $item->getCost();
         $result['html']['item_cost'] = ProductHelper::formatPrice($item->getCost());
     } catch (Exception $e) {
         $result = array('success' => false, 'error' => $e->getMessage());
     }
     echo json_encode($result);
     exit;
 }
Example #17
0
 /**
  * @param $order Order The order.
  *
  * @return string Items formatted for email.
  */
 private function formatItems($order)
 {
     //		$inc_tax = $this->options->get('tax.included');
     $result = '';
     // validate if any item has cost less than 0. If that's the case, we can't use price including tax
     // TODO: Support for "price includes tax"
     //		$use_inc_tax = $inc_tax;
     //		if ($inc_tax) {
     //			foreach ($this->items as $item) {
     //				$use_inc_tax = ($item['cost_inc_tax'] >= 0);
     //				if (!$use_inc_tax) {
     //					break;
     //				}
     //			}
     //		}
     foreach ($order->getItems() as $item) {
         /** @var $item Order\Item */
         $itemResult = '';
         $product = $item->getProduct();
         $itemResult .= $item->getQuantity() . ' x ' . html_entity_decode($this->wp->applyFilters('jigoshop\\emails\\product_title', $item->getName(), $product, $item), ENT_QUOTES, 'UTF-8');
         if ($product->getSku()) {
             $itemResult .= ' (#' . $product->getSku() . ')';
         }
         // TODO: Support for "price includes tax"
         //			if ($use_inc_tax && $item['cost_inc_tax'] >= 0) {
         //				$return .= ' - '.html_entity_decode(strip_tags(jigoshop_price($item['cost_inc_tax'] * $item['qty'], array('ex_tax_label' => 0))), ENT_COMPAT, 'UTF-8');
         //			} else {
         $itemResult .= ' - ' . ProductHelper::formatPrice($item->getCost());
         //			}
         if ($product instanceof Product\Variable) {
             $variation = $product->getVariation($item->getMeta('variation_id')->getValue());
             $itemResult .= PHP_EOL;
             foreach ($variation->getAttributes() as $attribute) {
                 /** @var $attribute \Jigoshop\Entity\Product\Variable\Attribute */
                 $itemResult .= $attribute->getAttribute()->getLabel() . ': ' . $attribute->getItemValue($item) . ', ';
             }
             $itemResult = rtrim($itemResult, ',');
         }
         $itemResult = $this->wp->applyFilters('jigoshop\\emails\\order_item', $itemResult, $item, $order);
         $result .= $itemResult . PHP_EOL;
     }
     return $result;
 }
Example #18
0
 /**
  * @param $coupon Coupon
  */
 public function addCoupon($coupon)
 {
     if (!is_object($coupon)) {
         parent::addCoupon($coupon);
         return;
     }
     if (isset($this->couponData[$coupon->getId()])) {
         return;
     }
     if (is_numeric($coupon->getOrderTotalMinimum()) && $this->getTotal() < $coupon->getOrderTotalMinimum()) {
         throw new Exception(sprintf(__('Cannot apply coupon "%s". Order total less than %s.'), $coupon->getCode(), ProductHelper::formatPrice($coupon->getOrderTotalMinimum())));
     }
     if (is_numeric($coupon->getOrderTotalMaximum()) && $this->getTotal() > $coupon->getOrderTotalMaximum()) {
         throw new Exception(sprintf(__('Cannot apply coupon "%s". Order total more than %s.'), $coupon->getCode(), ProductHelper::formatPrice($coupon->getOrderTotalMaximum())));
     }
     if ($coupon->isIndividualUse()) {
         $this->removeAllCouponsExcept(array());
     }
     $discount = $coupon->getDiscount($this);
     $this->couponData[$coupon->getId()] = array('object' => $coupon, 'discount' => $discount);
     parent::addCoupon($coupon->getCode());
     $this->addDiscount($discount);
 }
Example #19
0
echo $method->getId();
?>
-<?php 
echo $rate->getId();
?>
 clearfix">
	<label>
		<input type="radio" name="jigoshop_order[shipping_method]" value="<?php 
echo $method->getId();
?>
" <?php 
echo Forms::checked($cart->hasShippingMethod($method, $rate), true);
?>
 />
		<input type="hidden" class="shipping-method-rate" name="jigoshop_order[shipping_method_rate][<?php 
echo $method->getId();
?>
]" value="<?php 
echo $rate->getId();
?>
" />
		<?php 
echo $rate->getName();
?>
	</label>
	<span class="pull-right"><?php 
echo Product::formatPrice($rate->calculate($cart));
?>
</span>
</li>
Example #20
0
				<th scope="row"><?php 
_e('Discount', 'jigoshop');
?>
</th>
				<td><?php 
echo Product::formatPrice($order->getDiscount());
?>
</td>
			</tr>
			<tr id="cart-total">
				<th scope="row"><?php 
_e('Total', 'jigoshop');
?>
</th>
				<td><?php 
echo Product::formatPrice($order->getTotal());
?>
</td>
			</tr>
			</tbody>
		</table>
	</div>
</div>
<?php 
if ($order->getStatus() == Status::PENDING) {
    ?>
<a href="<?php 
    echo $cancelUrl;
    ?>
" class="btn btn-danger"><?php 
    _e('Cancel this order', 'jigoshop');
Example #21
0
    \Jigoshop\Helper\Render::output('admin/order/item/' . $item->getType(), array('order' => $order, 'item' => $item));
    ?>
			<?php 
}
?>
			</tbody>
			<tfoot>
			<tr>
				<td colspan="3"><?php 
Forms::text(array('name' => 'new_item', 'id' => 'new-item', 'placeholder' => __('Search for products...', 'jigoshop')));
?>
</td>
				<td><button class="btn btn-primary" id="add-item"><?php 
_e('Add item', 'jigoshop');
?>
</button></td>
				<td class="text-right"><strong><?php 
_e('Product subtotal:', 'jigoshop');
?>
</strong></td>
				<td id="product-subtotal"><?php 
Forms::constant(array('name' => 'order[subtotal]', 'value' => Product::formatPrice($order->getProductSubtotal())));
?>
</td>
				<td></td>
			</tr>
			</tfoot>
		</table>
	</div>
</div>
Example #22
0
 /**
  * Abstraction for cart update response.
  *
  * Prepares and returns response array for cart update requests.
  *
  * @param CartEntity $cart Current cart.
  *
  * @return array
  */
 private function getAjaxCartResponse(CartEntity $cart)
 {
     $tax = array();
     foreach ($cart->getCombinedTax() as $class => $value) {
         $tax[$class] = array('label' => Tax::getLabel($class, $cart), 'value' => ProductHelper::formatPrice($value));
     }
     $shipping = array();
     $shippingHtml = array();
     foreach ($this->shippingService->getAvailable() as $method) {
         /** @var $method Method */
         if ($method instanceof MultipleMethod) {
             /** @var $method MultipleMethod */
             foreach ($method->getRates($cart) as $rate) {
                 /** @var $rate Rate */
                 $shipping[$method->getId() . '-' . $rate->getId()] = $method->isEnabled() ? $rate->calculate($cart) : -1;
                 if ($method->isEnabled()) {
                     $shippingHtml[$method->getId() . '-' . $rate->getId()] = array('price' => ProductHelper::formatPrice($rate->calculate($cart)), 'html' => Render::get('shop/cart/shipping/rate', array('method' => $method, 'rate' => $rate, 'cart' => $cart)));
                 }
             }
         } else {
             $shipping[$method->getId()] = $method->isEnabled() ? $method->calculate($cart) : -1;
             if ($method->isEnabled()) {
                 $shippingHtml[$method->getId()] = array('price' => ProductHelper::formatPrice($method->calculate($cart)), 'html' => Render::get('shop/cart/shipping/method', array('method' => $method, 'cart' => $cart)));
             }
         }
     }
     $response = array('success' => true, 'shipping' => $shipping, 'subtotal' => $cart->getSubtotal(), 'product_subtotal' => $cart->getProductSubtotal(), 'tax' => $cart->getCombinedTax(), 'total' => $cart->getTotal(), 'html' => array('shipping' => $shippingHtml, 'subtotal' => ProductHelper::formatPrice($cart->getSubtotal()), 'product_subtotal' => ProductHelper::formatPrice($cart->getProductSubtotal()), 'tax' => $tax, 'total' => ProductHelper::formatPrice($cart->getTotal())));
     return $response;
 }
Example #23
0
<?php

use Jigoshop\Helper\Forms;
use Jigoshop\Helper\Product;
/**
 * @var $method \Jigoshop\Shipping\Method Method to display.
 * @var $cart \Jigoshop\Entity\Cart Current cart.
 */
?>
<li class="list-group-item shipping-<?php 
echo $method->getId();
?>
 clearfix">
	<label>
		<input type="radio" name="jigoshop_order[shipping_method]" value="<?php 
echo $method->getId();
?>
" <?php 
echo Forms::checked($cart->hasShippingMethod($method), true);
?>
 />
		<?php 
echo $method->getTitle();
?>
	</label>
	<span class="pull-right"><?php 
echo Product::formatPrice($method->calculate($cart));
?>
</span>
</li>
Example #24
0
	<td class="id"><?php 
Forms::constant(array('name' => 'order[items][' . $id . '][id]', 'value' => $item->getProduct()->getId()));
?>
</td>
	<td class="sku"><?php 
Forms::constant(array('name' => 'order[items][' . $id . '][sku]', 'value' => $item->getProduct()->getSku()));
?>
</td>
	<td class="name"><?php 
Forms::constant(array('name' => 'order[items][' . $id . '][name]', 'value' => apply_filters('jigoshop\\template\\admin\\order\\item_title', $item->getName(), $item->getProduct(), $item)));
?>
</td>
	<td class="price"><?php 
Forms::text(array('name' => 'order[items][' . $id . '][price]', 'value' => Product::formatNumericPrice($item->getPrice())));
?>
</td>
	<td class="quantity"><?php 
Forms::text(array('name' => 'quantity[' . $id . ']', 'value' => $item->getQuantity()));
?>
</td>
	<td class="total"><?php 
Forms::constant(array('name' => 'order[items][' . $id . '][total]', 'value' => Product::formatPrice($item->getCost())));
?>
</td>
	<td class="actions">
		<a href="" class="close remove"><span aria-hidden="true">&times;</span><span class="sr-only"><?php 
_e('Remove', 'jigoshop');
?>
</span></a>
	</td>
</tr>
Example #25
0
echo $method->getId();
?>
-<?php 
echo $rate->getId();
?>
 clearfix">
	<label>
		<input type="radio" name="order[shipping]" value="<?php 
echo $method->getId();
?>
" <?php 
echo Forms::checked($order->hasShippingMethod($method, $rate), true);
?>
 />
		<input type="hidden" class="shipping-method-rate" name="order[shipping_rate][<?php 
echo $method->getId();
?>
]" value="<?php 
echo $rate->getId();
?>
" />
		<?php 
echo $rate->getName();
?>
	</label>
	<span class="pull-right"><?php 
echo Product::formatPrice($rate->calculate($order));
?>
</span>
</li>