Example #1
0
 public static function symbol()
 {
     if (self::$symbol === null) {
         $symbols = Currency::symbols();
         self::$symbol = $symbols[self::$options->get('general.currency')];
     }
     return self::$symbol;
 }
Example #2
0
 /**
  * @return array List of items to display.
  */
 public function getSections()
 {
     return array(array('title' => __('Main', 'jigoshop'), 'id' => 'main', 'fields' => array(array('id' => 'country', 'name' => '[country]', 'title' => __('Shop location (country)', 'jigoshop'), 'type' => 'select', 'value' => $this->options['country'], 'options' => Country::getAll()), array('id' => 'state', 'name' => '[state]', 'title' => __('Shop location (state)', 'jigoshop'), 'type' => 'text', 'value' => $this->options['state']), array('name' => '[email]', 'title' => __('Administrator e-mail', 'jigoshop'), 'type' => 'text', 'tip' => __('The email address used to send all Jigoshop related emails, such as order confirmations and notices.', 'jigoshop'), 'value' => $this->options['email']), array('name' => '[show_message]', 'id' => 'show_message', 'title' => __('Display custom message?', 'jigoshop'), 'type' => 'checkbox', 'checked' => $this->options['show_message'], 'tip' => __('Add custom message on top of each page of your website.', 'jigoshop'), 'classes' => array('switch-medium')), array('name' => '[message]', 'id' => 'custom_message', 'title' => __('Message text', 'jigoshop'), 'type' => 'text', 'value' => $this->options['message'], 'classes' => array($this->options['show_message'] ? '' : 'not-active')), array('name' => '[demo_store]', 'id' => 'demo_store', 'title' => __('Demo store', 'jigoshop'), 'type' => 'checkbox', 'checked' => $this->options['demo_store'], 'tip' => __('Enable this option to show a banner at the top of every page stating this shop is currently in testing mode.', 'jigoshop'), 'classes' => array('switch-medium')))), array('title' => __('Pricing', 'jigoshop'), 'id' => 'pricing', 'fields' => array(array('name' => '[currency]', 'title' => __('Currency', 'jigoshop'), 'type' => 'select', 'value' => $this->options['currency'], 'options' => Currency::countries()), array('name' => '[currency_position]', 'title' => __('Currency position', 'jigoshop'), 'type' => 'select', 'value' => $this->options['currency_position'], 'options' => Currency::positions()), array('name' => '[currency_decimals]', 'title' => __('Number of decimals', 'jigoshop'), 'type' => 'text', 'value' => $this->options['currency_decimals']), array('name' => '[currency_thousand_separator]', 'title' => __('Thousands separator', 'jigoshop'), 'type' => 'text', 'value' => $this->options['currency_thousand_separator']), array('name' => '[currency_decimal_separator]', 'title' => __('Decimal separator', 'jigoshop'), 'type' => 'text', 'value' => $this->options['currency_decimal_separator']))), array('title' => __('Company details', 'jigoshop'), 'description' => __('These details, alongside shop location, will be used for invoicing and emails.', 'jigoshop'), 'id' => 'company', 'fields' => array(array('name' => '[company_name]', 'title' => __('Name', 'jigoshop'), 'type' => 'text', 'value' => $this->options['company_name']), array('name' => '[company_address_1]', 'title' => __('Address (first line)', 'jigoshop'), 'type' => 'text', 'value' => $this->options['company_address_1']), array('name' => '[company_address_2]', 'title' => __('Address (second line)', 'jigoshop'), 'type' => 'text', 'value' => $this->options['company_address_2']), array('name' => '[company_tax_number]', 'title' => __('Tax number', 'jigoshop'), 'description' => __('Add your tax registration label before the registration number and it will be printed as well. eg. <code>VAT Number: 88888888</code>', 'jigoshop'), 'type' => 'text', 'value' => $this->options['company_tax_number']), array('name' => '[company_phone]', 'title' => __('Phone number', 'jigoshop'), 'type' => 'text', 'value' => $this->options['company_phone']), array('name' => '[company_email]', 'title' => __('Email', 'jigoshop'), 'type' => 'text', 'tip' => __('A representative e-mail company - department of orders, customer service, contact.', 'jigoshop'), 'value' => $this->options['company_email']))), array('title' => __('Emails', 'jigoshop'), 'id' => 'emails', 'fields' => array(array('name' => '[emails][from]', 'title' => __('From name', 'jigoshop'), 'description' => __('Name shown in all Jigoshop emails.', 'jigoshop'), 'type' => 'text', 'value' => $this->options['emails']['from']), array('name' => '[emails][footer]', 'title' => __('Footer', 'jigoshop'), 'description' => __('The email footer used in all Jigoshop emails.', 'jigoshop'), 'type' => 'textarea', 'value' => $this->options['emails']['footer']))));
 }
Example #3
0
 /**
  * @param Order $order Order to process payment for.
  *
  * @return bool Is processing successful?
  */
 public function process($order)
 {
     if ($this->settings['test_mode']) {
         $url = self::TEST_URL . '&';
     } else {
         $url = self::LIVE_URL . '?';
     }
     $billingAddress = $order->getCustomer()->getBillingAddress();
     if (in_array($billingAddress->getCountry(), array('US', 'CA'))) {
         $phone = str_replace(array('(', '-', ' ', ')'), '', $billingAddress->getPhone());
         $phone = array('night_phone_a' => substr($phone, 0, 3), 'night_phone_b' => substr($phone, 3, 3), 'night_phone_c' => substr($phone, 6, 4), 'day_phone_a' => substr($phone, 0, 3), 'day_phone_b' => substr($phone, 3, 3), 'day_phone_c' => substr($phone, 6, 4));
     } else {
         $phone = array('night_phone_b' => $billingAddress->getPhone(), 'day_phone_b' => $billingAddress->getPhone());
     }
     $args = array_merge(array('cmd' => '_cart', 'business' => $this->settings['test_mode'] ? $this->settings['test_email'] : $this->settings['email'], 'no_note' => 1, 'currency_code' => Currency::code(), 'charset' => 'UTF-8', 'rm' => 2, 'upload' => 1, 'return' => OrderHelper::getThankYouLink($order), 'cancel_return' => OrderHelper::getCancelLink($order), 'custom' => $order->getId(), 'notify_url' => Api::getUrl(self::ID), 'first_name' => $billingAddress->getFirstName(), 'last_name' => $billingAddress->getLastName(), 'company' => $billingAddress instanceof CompanyAddress ? $billingAddress->getCompany() : '', 'address1' => $billingAddress->getAddress(), 'address2' => '', 'city' => $billingAddress->getCity(), 'state' => $billingAddress->getState(), 'zip' => $billingAddress->getPostcode(), 'country' => $billingAddress->getCountry(), 'email' => $billingAddress->getEmail(), 'invoice' => $order->getNumber(), 'amount' => number_format($order->getTotal(), $this->options->get('general.currency_decimals')), 'bn' => 'Jigoshop_SP'), $phone);
     if ($this->settings['send_shipping']) {
         $shippingAddress = $order->getCustomer()->getShippingAddress();
         $args['no_shipping'] = 1;
         $args['address_override'] = 1;
         $args['first_name'] = $shippingAddress->getFirstName();
         $args['last_name'] = $shippingAddress->getLastName();
         $args['address1'] = $shippingAddress->getAddress();
         $args['address2'] = '';
         $args['city'] = $shippingAddress->getCity();
         $args['state'] = $shippingAddress->getState();
         $args['zip'] = $shippingAddress->getPostcode();
         $args['country'] = $shippingAddress->getCountry();
         // PayPal counts Puerto Rico as a US Territory, won't allow payment without it
         if ($args['country'] == 'PR') {
             $args['country'] = 'US';
             $args['state'] = 'PR';
         }
     } else {
         $args['no_shipping'] = 1;
         $args['address_override'] = 0;
     }
     // If prices include tax, send the whole order as a single item
     // TODO: Price includes tax
     //		$priceIncludesTax = $this->options->get('tax.included');
     //		if($priceIncludesTax){
     //			// Discount
     //			//$args['discount_amount_cart'] = number_format($order->getDiscount(), $this->decimals);
     //
     //			// Don't pass items - PayPal breaks tax due to catalog prices include tax.
     //			// PayPal has no option for tax inclusive pricing.
     //			// Pass 1 item for the order items overall
     //			$item_names = array();
     //
     //			foreach($order->items as $item){
     //				$_product = $order->get_product_from_item($item);
     //				$title = $_product->get_title();
     //
     //				//if variation, insert variation details into product title
     //				if($_product instanceof jigoshop_product_variation){
     //					$title .= ' ('.jigoshop_get_formatted_variation($_product, $item['variation'], true).')';
     //				}
     //
     //				$item_names[] = $title.' x '.$item['qty'];
     //			}
     //
     //			$args['item_name_1'] = sprintf(__('Order %s', 'jigoshop'), $order->get_order_number()).' - '.implode(', ', $item_names);
     //			$args['quantity_1'] = 1;
     //			$args['amount_1'] = number_format($order->order_total - $order->order_shipping - $order->order_shipping_tax + $order->order_discount, $this->decimals, '.', '');
     //
     //			if(($order->order_shipping + $order->order_shipping_tax) > 0){
     //				$args['item_name_2'] = __('Shipping cost', 'jigoshop');
     //				$args['quantity_2'] = '1';
     //				$args['amount_2'] = number_format($order->order_shipping + $order->order_shipping_tax, $this->decimals, '.', '');
     //			}
     //		} else {
     // Cart Contents
     $item_loop = 0;
     foreach ($order->getItems() as $item) {
         /** @var $item Order\Item */
         $item_loop++;
         $product = $item->getProduct();
         $title = $product->getName();
         //if variation, insert variation details into product title
         if ($product instanceof Product\Variable) {
             $title .= '(' . join(', ', array_filter(array_map(function ($attribute) use($item) {
                 /** @var $attribute Product\Variable\Attribute */
                 if ($attribute->getValue() !== '') {
                     $value = $attribute->getValue();
                 } else {
                     $value = $item->getMeta($attribute->getAttribute()->getSlug())->getValue();
                 }
                 return sprintf(_x('%s: %s', 'product_variation', 'jigoshop'), $attribute->getAttribute()->getLabel(), $attribute->getAttribute()->getOption($value)->getLabel());
             }, $product->getVariation($item->getMeta('variation_id')->getValue())->getAttributes()))) . ')';
         }
         $args['item_name_' . $item_loop] = $title;
         $args['quantity_' . $item_loop] = $item->getQuantity();
         // Apparently, PayPal did not like "28.4525" as the amount. Changing that to "28.45" fixed the issue.
         $args['amount_' . $item_loop] = number_format($this->wp->applyFilters('jigoshop\\paypal\\item_price', $item->getPrice(), $item), $this->decimals);
     }
     // Shipping Cost
     if ($this->options->get('shipping.enabled') && $order->getShippingPrice() > 0) {
         $item_loop++;
         $args['item_name_' . $item_loop] = __('Shipping cost', 'jigoshop');
         $args['quantity_' . $item_loop] = '1';
         $args['amount_' . $item_loop] = number_format($order->getShippingPrice(), $this->decimals);
     }
     $args['tax'] = $args['tax_cart'] = number_format($order->getTotalCombinedTax(), $this->decimals);
     $args['discount_amount_cart'] = number_format($order->getDiscount(), $this->decimals);
     if ($this->settings['force_payment'] && $order->getTotal() == 0) {
         $item_loop++;
         $args['item_name_' . $item_loop] = __('Force payment on free orders', 'jigoshop');
         $args['quantity_' . $item_loop] = '1';
         $args['amount_' . $item_loop] = 0.01;
     }
     //		}
     $args = $this->wp->applyFilters('jigoshop\\paypal\\args', $args);
     $order->setStatus(Order\Status::PENDING, __('Waiting for PayPal payment.', 'jigoshop'));
     return $url . http_build_query($args);
 }
Example #4
0
			<thead>
			<tr>
				<th scope="col"><?php 
Forms::constant(array('name' => 'order[items][id]', 'value' => __('ID', 'jigoshop')));
?>
</th>
				<th scope="col"><?php 
Forms::constant(array('name' => 'order[items][sku]', 'value' => __('SKU', 'jigoshop')));
?>
</th>
				<th scope="col"><?php 
Forms::constant(array('size' => 12, 'name' => 'order[items][name]', 'value' => __('Name', 'jigoshop')));
?>
</th>
				<th scope="col"><?php 
Forms::constant(array('size' => 12, 'name' => 'order[items][unit_price]', 'value' => sprintf(__('Unit price (%s)', 'jigoshop'), Currency::symbol())));
?>
</th>
				<th scope="col"><?php 
Forms::constant(array('size' => 12, 'name' => 'order[items][qty]', 'value' => __('Quantity', 'jigoshop')));
?>
</th>
				<th scope="col"><?php 
Forms::constant(array('name' => 'order[items][id][price]', 'value' => __('Price', 'jigoshop')));
?>
</th>
				<th scope="col"></th>
			</tr>
			</thead>
			<tbody>
			<?php 
Example #5
0
        Render::output('admin/order/totals/shipping/method', array('method' => $method, 'order' => $order));
        ?>
						<?php 
    }
    ?>
					<?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);
Example #6
0
 public function getMainChart()
 {
     global $wp_locale;
     // Prepare data for report
     $orderItemCounts = $this->prepareChartData($this->reportData->orderItems, 'post_date', 'order_item_count', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $orderItemAmounts = $this->prepareChartData($this->reportData->orderItems, 'post_date', 'order_item_amount', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $orderItemQuantity = $this->prepareChartData($this->reportData->orderItems, 'post_date', 'order_item_quantity', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $data = array();
     $data['series'] = array();
     $data['series'][] = $this->arrayToObject(array('label' => __('Sold quantity', 'jigoshop'), 'data' => array_values($orderItemQuantity), 'color' => $this->chartColours['item_quantity'], 'bars' => $this->arrayToObject(array('fillColor' => $this->chartColours['item_quantity'], 'fill' => true, 'show' => true, 'lineWidth' => 0, 'align' => 'left', 'barWidth' => $this->barwidth * 0.4)), 'shadowSize' => 0, 'hoverable' => false));
     $data['series'][] = $this->arrayToObject(array('label' => __('Number of items sold', 'jigoshop'), 'data' => array_values($orderItemCounts), 'color' => $this->chartColours['item_count'], 'bars' => $this->arrayToObject(array('fillColor' => $this->chartColours['item_count'], 'fill' => true, 'show' => true, 'lineWidth' => 0, 'align' => 'right', 'barWidth' => $this->barwidth * 0.4)), 'shadowSize' => 0, 'hoverable' => false));
     $data['series'][] = $this->arrayToObject(array('label' => __('Sales amount', 'jigoshop'), 'data' => array_values($orderItemAmounts), 'yaxis' => 2, 'color' => $this->chartColours['sales_amount'], 'points' => $this->arrayToObject(array('show' => true, 'radius' => 5, 'lineWidth' => 3, 'fillColor' => '#fff', 'fill' => true)), 'lines' => $this->arrayToObject(array('show' => true, 'lineWidth' => 4, 'fill' => false)), 'shadowSize' => 0, 'append_tooltip' => Currency::symbol()));
     $data['options'] = $this->arrayToObject(array('legend' => $this->arrayToObject(array('show' => false)), 'grid' => $this->arrayToObject(array('color' => '#aaa', 'borderColor' => 'transparent', 'borderWidth' => 0, 'hoverable' => true)), 'xaxes' => array($this->arrayToObject(array('color' => '#aaa', 'position' => 'bottom', 'tickColor' => 'transparent', 'mode' => 'time', 'timeformat' => $this->chartGroupBy == 'hour' ? '%H' : $this->chartGroupBy == 'day' ? '%d %b' : '%b', 'monthNames' => array_values($wp_locale->month_abbrev), 'tickLength' => 1, 'minTickSize' => array(1, $this->chartGroupBy), 'font' => $this->arrayToObject(array('color' => '#aaa'))))), 'yaxes' => array($this->arrayToObject(array('min' => 0, 'minTickSize' => 1, 'tickDecimals' => 0, 'color' => '#ecf0f1', 'font' => $this->arrayToObject(array('color' => '#aaa')))), $this->arrayToObject(array('position' => 'right', 'min' => 0, 'tickDecimals' => 2, 'alignTicksWithAxis' => 1, 'color' => 'transparent', 'font' => $this->arrayToObject(array('color' => '#aaa')))))));
     if ($this->chartGroupBy == 'hour') {
         $data['options']->xaxes[0]->min = 0;
         $data['options']->xaxes[0]->max = 24 * 60 * 60 * 1000;
     }
     return $data;
 }
Example #7
0
 /**
  * Returns formatted currency position
  *
  * @return string
  */
 private function getCurrencyPosition()
 {
     $pattern = $this->options->get('general.currency_position');
     $positions = Currency::positions();
     return $positions[$pattern];
 }
Example #8
0
 public function getMainChart()
 {
     global $wp_locale;
     $chartData = array();
     $index = 0;
     foreach ($this->showCategories as $category) {
         $category = get_term($category, 'product_category');
         $productIds = $this->getProductsInCategory($category->term_id);
         $categoryTotal = 0;
         $categoryChartData = array();
         for ($i = 0; $i <= $this->chartInterval; $i++) {
             $intervalTotal = 0;
             switch ($this->chartGroupBy) {
                 case 'hour':
                     $time = strtotime(date('YmdHi', strtotime($this->range['start']))) + $i * 3600000;
                     break;
                 case 'day':
                     $time = strtotime(date('Ymd', strtotime("+{$i} DAY", $this->range['start']))) * 1000;
                     break;
                 case 'month':
                 default:
                     $time = strtotime(date('Ym', strtotime("+{$i} MONTH", $this->range['start'])) . '01') * 1000;
                     break;
             }
             foreach ($productIds as $id) {
                 if (isset($this->reportData->itemSalesAndTimes[$time][$id])) {
                     $intervalTotal += $this->reportData->itemSalesAndTimes[$time][$id];
                     $categoryTotal += $this->reportData->itemSalesAndTimes[$time][$id];
                 }
             }
             $categoryChartData[] = array($time, $intervalTotal);
         }
         $chartData[$category->term_id]['category'] = $category->name;
         $chartData[$category->term_id]['data'] = $categoryChartData;
         $index++;
     }
     $index = 0;
     $data = array();
     $data['series'] = array();
     foreach ($chartData as $singleData) {
         $width = $this->barwidth / sizeof($chartData);
         $offset = $width * $index;
         foreach ($singleData['data'] as $key => $seriesData) {
             $singleData['data'][$key][0] = $seriesData[0] + $offset;
         }
         $data['series'][] = $this->arrayToObject(array('label' => esc_js($singleData['category']), 'data' => $singleData['data'], 'color' => $this->chartColours[$index % sizeof($this->chartColours)], 'bars' => $this->arrayToObject(array('fillColor' => $this->chartColours[$index % sizeof($this->chartColours)], 'fill' => true, 'show' => true, 'lineWidth' => 1, 'align' => 'center', 'barWidth' => $width * 0.8, 'stack' => false)), 'append_tooltip' => Currency::symbol(), 'enable_tooltip' => true));
         $index++;
     }
     $data['options'] = $this->arrayToObject(array('legend' => $this->arrayToObject(array('show' => false)), 'grid' => $this->arrayToObject(array('color' => '#aaa', 'borderColor' => 'transparent', 'borderWidth' => 0, 'hoverable' => true)), 'xaxes' => array($this->arrayToObject(array('color' => '#aaa', 'reserveSpace' => false, 'position' => 'bottom', 'tickColor' => 'transparent', 'mode' => 'time', 'timeformat' => $this->chartGroupBy == 'hour' ? '%H' : $this->chartGroupBy == 'day' ? '%d %b' : '%b', 'monthNames' => array_values($wp_locale->month_abbrev), 'tickLength' => 1, 'minTickSize' => array(1, $this->chartGroupBy), 'tickSize' => array(1, $this->chartGroupBy), 'font' => $this->arrayToObject(array('color' => '#aaa'))))), 'yaxes' => array($this->arrayToObject(array('min' => 0, 'tickDecimals' => 2, 'color' => '#d4d9dc', 'font' => $this->arrayToObject(array('color' => '#aaa')))))));
     if ($this->chartGroupBy == 'hour') {
         $data['options']->xaxes[0]->min = 0;
         $data['options']->xaxes[0]->max = 24 * 60 * 60 * 1000;
     }
     return $data;
 }
Example #9
0
 /**
  * @return array
  */
 public function getMainChart()
 {
     global $wp_locale;
     $startTime = $this->range['start'];
     $endTime = $this->range['end'];
     $filterTimes = function ($item) use($startTime, $endTime) {
         $time = strtotime($item->post_date);
         return $time >= $startTime && $time < $endTime;
     };
     // Prepare data for report
     $orderCouponCounts = $this->prepareChartData(array_filter($this->reportData->orderCouponCounts, $filterTimes), 'post_date', 'order_coupon_count', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $orderDiscountAmounts = $this->prepareChartData(array_filter($this->reportData->orderDiscountAmounts, $filterTimes), 'post_date', 'discount_amount', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $data = array();
     $data['series'] = array();
     $data['series'][] = $this->arrayToObject(array('label' => esc_js(__('Number of coupons used', 'jigoshop')), 'data' => array_values($orderCouponCounts), 'color' => $this->chartColours['coupon_count'], 'bars' => $this->arrayToObject(array('fillColor' => $this->chartColours['coupon_count'], 'fill' => true, 'show' => true, 'lineWidth' => 0, 'align' => 'center', 'barWidth' => $this->barwidth * 0.8)), 'shadowSize' => 0, 'hoverable' => false));
     $data['series'][] = $this->arrayToObject(array('label' => esc_js(__('Discount amount', 'jigoshop')), 'data' => array_values($orderDiscountAmounts), 'yaxis' => 2, 'color' => $this->chartColours['discount_amount'], 'points' => $this->arrayToObject(array('show' => true, 'radius' => 5, 'lineWidth' => 4, 'fillColor' => '#fff', 'fill' => true)), 'lines' => $this->arrayToObject(array('show' => true, 'lineWidth' => 4, 'fill' => false)), 'shadowSize' => 0, 'append_tooltip' => Currency::symbol()));
     $data['options'] = $this->arrayToObject(array('legend' => $this->arrayToObject(array('show' => false)), 'grid' => $this->arrayToObject(array('color' => '#aaa', 'borderColor' => 'transparent', 'borderWidth' => 0, 'hoverable' => true)), 'xaxes' => array($this->arrayToObject(array('color' => '#aaa', 'position' => 'bottom', 'tickColor' => 'transparent', 'mode' => 'time', 'timeformat' => $this->chartGroupBy == 'hour' ? '%H' : $this->chartGroupBy == 'day' ? '%d %b' : '%b', 'monthNames' => array_values($wp_locale->month_abbrev), 'tickLength' => 1, 'minTickSize' => array(1, $this->chartGroupBy), 'font' => $this->arrayToObject(array('color' => '#aaa'))))), 'yaxes' => array($this->arrayToObject(array('min' => 0, 'minTickSize' => 1, 'tickDecimals' => 0, 'color' => '#ecf0f1', 'font' => $this->arrayToObject(array('color' => '#aaa')))), $this->arrayToObject(array('position' => 'right', 'min' => 0, 'tickDecimals' => 2, 'alignTicksWithAxis' => 1, 'autoscaleMargin' => 0, 'color' => 'transparent', 'font' => $this->arrayToObject(array('color' => '#aaa')))))));
     if ($this->chartGroupBy == 'hour') {
         $data['options']->xaxes[0]->min = 0;
         $data['options']->xaxes[0]->max = 24 * 60 * 60 * 1000;
     }
     return $data;
 }
Example #10
0
 /**
  * @param $price float Price to format.
  *
  * @return string Formatted price as numeric value.
  */
 public static function formatNumericPrice($price)
 {
     return number_format($price, Currency::decimals(), Currency::decimalSeparator(), Currency::thousandsSeparator());
 }
Example #11
0
			<input type="hidden" id="min_price" name="min_price" value="0" />
			<?php 
\Jigoshop\Helper\Forms::printHiddenFields($fields, array('max_price', 'min_price'));
?>
		</div>
		<div class="clear"></div>
	</div>
</form>
<script type="text/javascript">
	/*<![CDATA[*/
	jQuery(document).ready(function($){
		// Price slider
		var min_price = parseInt($('.price_slider_amount #min_price').val());
		var max_price = parseInt($('.price_slider_amount #max_price').val());
		var html = '<?php 
echo sprintf(Currency::format(), Currency::symbol(), Currency::code(), '%s%');
?>
';
		var current_min_price, current_max_price;
		current_min_price = min_price;
		current_max_price = max_price;
		$('.price_slider').slider({
			range: true,
			min: min_price,
			max: max_price,
			values: [min_price, max_price],
			create: function(){
				$(".price_slider_amount span").html(html.replace(/%s%/g, min_price) + " - " + html.replace(/%s%/g, max_price));
				$(".price_slider_amount #min_price").val(current_min_price);
				$(".price_slider_amount #max_price").val(current_max_price);
			},
Example #12
0
<?php

use Jigoshop\Admin\Helper\Forms;
use Jigoshop\Entity\Product;
use Jigoshop\Helper\Currency;
use Jigoshop\Helper\Product as ProductHelper;
/**
 * @var $product Product The product.
 */
?>
<fieldset>
	<?php 
Forms::text(array('name' => 'product[regular_price]', 'label' => __('Price', 'jigoshop') . ' (' . Currency::symbol() . ')', 'placeholder' => __('Price not announced', 'jigoshop'), 'classes' => array('product-simple', $product instanceof Product\Purchasable ? '' : 'not-active'), 'value' => $product instanceof Product\Purchasable ? $product->getRegularPrice() : 0));
Forms::text(array('name' => 'product[sku]', 'label' => __('SKU', 'jigoshop'), 'value' => $product->getSku(), 'placeholder' => $product->getId()));
Forms::text(array('name' => 'product[brand]', 'label' => __('Brand', 'jigoshop'), 'value' => $product->getBrand()));
Forms::text(array('name' => 'product[gtin]', 'label' => __('GTIN', 'jigoshop'), 'tip' => 'Global Trade Item Number', 'value' => $product->getGtin()));
Forms::text(array('name' => 'product[mpn]', 'label' => __('MPN', 'jigoshop'), 'tip' => 'Manufacturer Part Number', 'value' => $product->getMpn()));
?>
</fieldset>
<fieldset>
	<?php 
Forms::text(array('name' => 'product[size_weight]', 'label' => __('Weight', 'jigoshop') . ' (' . ProductHelper::weightUnit() . ')', 'value' => $product->getSize()->getWeight()));
Forms::text(array('name' => 'product[size_length]', 'label' => __('Length', 'jigoshop') . ' (' . ProductHelper::dimensionsUnit() . ')', 'value' => $product->getSize()->getLength()));
Forms::text(array('name' => 'product[size_width]', 'label' => __('Width', 'jigoshop') . ' (' . ProductHelper::dimensionsUnit() . ')', 'value' => $product->getSize()->getWidth()));
Forms::text(array('name' => 'product[size_height]', 'label' => __('Height', 'jigoshop') . ' (' . ProductHelper::dimensionsUnit() . ')', 'value' => $product->getSize()->getHeight()));
?>
</fieldset>
<fieldset>
	<?php 
Forms::select(array('name' => 'product[visibility]', 'label' => __('Visibility', 'jigoshop'), 'options' => array(Product::VISIBILITY_PUBLIC => __('Catalog & Search', 'jigoshop'), Product::VISIBILITY_CATALOG => __('Catalog Only', 'jigoshop'), Product::VISIBILITY_SEARCH => __('Search Only', 'jigoshop'), Product::VISIBILITY_NONE => __('Hidden', 'jigoshop')), 'value' => $product->getVisibility()));
Forms::checkbox(array('name' => 'product[featured]', 'label' => __('Featured?', 'jigoshop'), 'checked' => $product->isFeatured(), 'description' => __('Enable this option to feature this product', 'jigoshop')));
Example #13
0
 /**
  * Get the main chart
  *
  * @return string
  */
 public function getMainChart()
 {
     // TODO: Remove this...
     global $wp_locale;
     $orderCounts = $this->prepareChartData($this->reportData->orders, 'post_date', 'count', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $orderItemCounts = $this->prepareChartData($this->reportData->orders, 'post_date', 'order_item_count', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $orderAmounts = $this->prepareChartData($this->reportData->orders, 'post_date', 'total_sales', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $couponAmounts = $this->prepareChartData($this->reportData->orders, 'post_date', 'discount_amount', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $shippingAmounts = $this->prepareChartData($this->reportData->orders, 'post_date', 'total_shipping', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $shippingTaxAmounts = $this->prepareChartData($this->reportData->orders, 'post_date', 'total_shipping_tax', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $taxAmounts = $this->prepareChartData($this->reportData->orders, 'post_date', 'total_tax', $this->chartInterval, $this->range['start'], $this->chartGroupBy);
     $netOrderAmounts = array();
     foreach ($orderAmounts as $orderAmountKey => $orderAmountValue) {
         $netOrderAmounts[$orderAmountKey] = $orderAmountValue;
         $netOrderAmounts[$orderAmountKey][1] = $netOrderAmounts[$orderAmountKey][1] - $shippingAmounts[$orderAmountKey][1] - $shippingTaxAmounts[$orderAmountKey][1] - $taxAmounts[$orderAmountKey][1];
     }
     $data = array();
     $data['series'] = array();
     $data['series'][] = $this->arrayToObject(array('label' => esc_js(__('Number of items sold', 'jigoshop')), 'data' => array_values($orderItemCounts), 'color' => $this->chartColours['item_count'], 'bars' => array('fillColor' => $this->chartColours['item_count'], 'fill' => true, 'show' => true, 'lineWidth' => 0, 'align' => 'left', 'barWidth' => $this->barwidth * 0.2), 'shadowSize' => 0, 'hoverable' => false));
     $data['series'][] = $this->arrayToObject(array('label' => esc_js(__('Number of orders', 'jigoshop')), 'data' => array_values($orderCounts), 'color' => $this->chartColours['order_count'], 'bars' => array('fillColor' => $this->chartColours['order_count'], 'fill' => true, 'show' => true, 'lineWidth' => 0, 'align' => 'right', 'barWidth' => $this->barwidth * 0.2), 'shadowSize' => 0, 'hoverable' => false));
     $data['series'][] = $this->arrayToObject(array('label' => esc_js(__('Average sales amount', 'jigoshop')), 'data' => array(array(min(array_keys($orderAmounts)), $this->reportData->averageSales), array(max(array_keys($orderAmounts)), $this->reportData->averageSales)), 'yaxis' => 2, 'color' => $this->chartColours['average'], 'points' => $this->arrayToObject(array('show' => false)), 'lines' => $this->arrayToObject(array('show' => true, 'lineWidth' => 2, 'fill' => false)), 'shadowSize' => 0, 'hoverable' => false));
     $data['series'][] = $this->arrayToObject(array('label' => esc_js(__('Coupon amount', 'jigoshop')), 'data' => array_map(array($this, 'roundChartTotals'), array_values($couponAmounts)), 'yaxis' => 2, 'color' => $this->chartColours['coupon_amount'], 'points' => $this->arrayToObject(array('show' => true, 'radius' => 5, 'lineWidth' => 2, 'fillColor' => '#fff', 'fill' => true)), 'lines' => $this->arrayToObject(array('show' => true, 'lineWidth' => 2, 'fill' => false)), 'shadowSize' => 0, 'append_tooltip' => Currency::symbol()));
     $data['series'][] = $this->arrayToObject(array('label' => esc_js(__('Shipping amount', 'jigoshop')), 'data' => array_map(array($this, 'roundChartTotals'), array_values($shippingAmounts)), 'yaxis' => 2, 'color' => $this->chartColours['shipping_amount'], 'points' => $this->arrayToObject(array('show' => true, 'radius' => 5, 'lineWidth' => 2, 'fillColor' => '#fff', 'fill' => true)), 'lines' => $this->arrayToObject(array('show' => true, 'lineWidth' => 2, 'fill' => false)), 'shadowSize' => 0, 'append_tooltip' => Currency::symbol()));
     $data['series'][] = $this->arrayToObject(array('label' => esc_js(__('Gross Sales amount', 'jigoshop')), 'data' => array_map(array($this, 'roundChartTotals'), array_values($orderAmounts)), 'yaxis' => 2, 'color' => $this->chartColours['sales_amount'], 'points' => $this->arrayToObject(array('show' => true, 'radius' => 5, 'lineWidth' => 2, 'fillColor' => '#fff', 'fill' => true)), 'lines' => $this->arrayToObject(array('show' => true, 'lineWidth' => 2, 'fill' => false)), 'shadowSize' => 0, 'append_tooltip' => Currency::symbol()));
     $data['series'][] = $this->arrayToObject(array('label' => esc_js(__('Net Sales amount', 'jigoshop')), 'data' => array_map(array($this, 'roundChartTotals'), array_values($netOrderAmounts)), 'yaxis' => 2, 'color' => $this->chartColours['net_sales_amount'], 'points' => $this->arrayToObject(array('show' => true, 'radius' => 6, 'lineWidth' => 4, 'fillColor' => '#fff', 'fill' => true)), 'lines' => $this->arrayToObject(array('show' => true, 'lineWidth' => 5, 'fill' => false)), 'shadowSize' => 0, 'append_tooltip' => Currency::symbol()));
     $data['options'] = $this->arrayToObject(array('legend' => $this->arrayToObject(array('show' => false)), 'grid' => $this->arrayToObject(array('color' => '#aaa', 'borderColor' => 'transparent', 'borderWidth' => 0, 'hoverable' => true)), 'xaxis' => $this->arrayToObject(array('color' => '#aaa', 'position' => 'bottom', 'tickColor' => 'transparent', 'mode' => 'time', 'timeformat' => $this->chartGroupBy == 'hour' ? '%H' : ($this->chartGroupBy == 'day' ? '%d %b' : '%b'), 'monthNames' => array_values($wp_locale->month_abbrev), 'tickLength' => 1, 'minTickSize' => array(1, $this->chartGroupBy), 'font' => $this->arrayToObject(array('color' => '#aaa')))), 'yaxes' => array($this->arrayToObject(array('min' => 0, 'minTickSize' => 1, 'color' => '#d4d9dc', 'font' => $this->arrayToObject(array('color' => '#aaa')))), $this->arrayToObject(array('position' => 'right', 'min' => 0, 'tickDecimals' => 2, 'alignTicksWithAxis' => 1, 'autoscaleMargin' => 0, 'color' => 'transparent', 'font' => $this->arrayToObject(array('color' => '#aaa')))))));
     if ($this->chartGroupBy == 'hour') {
         $data['options']->xaxis->min = 0;
         $data['options']->xaxis->max = 24 * 60 * 60 * 1000;
     }
     return $data;
 }