echo JHTML::_('date', $order->created_date, $this->params->get('date_format', JText::_('DATE_FORMAT_LC1'))); ?> </td> <td><strong><a href="<?php echo $link; ?> "><?php echo $order->order_id; ?> </a></strong></td> <td><?php echo $order->user_email; ?> </td> <td><?php echo K2StorePrices::number($order->orderpayment_amount, $order->currency_code, $order->currency_value); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php }
?> <div class="k2store_cart_module_<?php echo $module->id; ?> "> <?php } ?> <?php if (!$hide) { ?> <?php if ($list['product_count'] > 0) { ?> <?php echo JText::sprintf('K2STORE_CART_TOTAL', $list['product_count'], K2StorePrices::number($list['total'])); ?> <?php } else { ?> <?php echo JText::_('K2STORE_NO_ITEMS_IN_CART'); ?> <?php } ?> <div class="k2store-minicart-button"> <?php if ($link_type == 'link') { ?>
echo JText::_("K2STORE_CART_GRANDTOTAL"); ?> </td> <td style="text-align: right;"> <?php if ($this->params->get('auto_calculate_tax', 1)) { ?> <?php echo K2StorePrices::number($this->totals['total']); ?> <?php } else { ?> <?php echo K2StorePrices::number($this->totals['total_without_tax']); ?> <?php } ?> </td> <td></td> </tr> </tfoot> </table> <table id="cart_actions" width="100%"> <tr> <?php if (isset($continue_shopping_url)) { ?>
function confirm() { $app = JFactory::getApplication(); $user = JFactory::getUser(); $lang = JFactory::getLanguage(); $db = JFactory::getDbo(); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2store'); $view = $this->getView('checkout', 'html'); $model = $this->getModel('checkout'); $cart_helper = new K2StoreHelperCart(); $cart_model = $this->getModel('mycart'); $orders_model = $this->getModel('orders'); $address_model = $this->getModel('address'); $redirect_url = JRoute::_('index.php?option=com_k2store&view=checkout'); $redirect = ''; //get the payment plugin form values set in the session. if ($this->session->has('payment_values', 'k2store')) { $values = $this->session->get('payment_values', array(), 'k2store'); //backward compatibility. TODO: change the way the plugin gets its data foreach ($values as $name => $value) { $app->input->set($name, $value); } } //prepare order $order = $this->_order; $order = $this->populateOrder(false); // get the order totals $order->calculateTotals(); //set shiping address if ($user->id && $this->session->has('shipping_address_id', 'k2store')) { $shipping_address = $address_model->getAddress($this->session->get('shipping_address_id', '', 'k2store')); } elseif ($this->session->has('guest', 'k2store')) { $guest = $this->session->get('guest', array(), 'k2store'); if ($guest['shipping']) { $shipping_address = $guest['shipping']; } } else { $shipping_address = array(); } //validate shipping $showShipping = false; if ($isShippingEnabled = $cart_model->getShippingIsEnabled()) { if (empty($shipping_address)) { $redirect = $redirect_url; } $showShipping = true; if ($this->session->has('shipping_values', 'k2store')) { //set the shipping methods $shipping_values = $this->session->get('shipping_values', array(), 'k2store'); $this->setShippingMethod($shipping_values); } } else { $this->session->clear('shipping_method', 'k2store'); $this->session->clear('shipping_methods', 'k2store'); $this->session->clear('shipping_values', 'k2store'); } $view->assign('showShipping', $showShipping); //process payment plugins $showPayment = true; if ((double) $order->order_total == (double) '0.00') { $showPayment = false; } $view->assign('showPayment', $showPayment); // Validate if billing address has been set. if ($user->id && $this->session->has('billing_address_id', 'k2store')) { $billing_address = $address_model->getAddress($this->session->get('billing_address_id', '', 'k2store')); } elseif ($this->session->has('guest', 'k2store')) { $guest = $this->session->get('guest', array(), 'k2store'); $billing_address = $guest['billing']; } if (empty($billing_address)) { $redirect = $redirect_url; } // Validate if payment method has been set. if ($showPayment == true && !$this->session->has('payment_method', 'k2store')) { $redirect = $redirect_url; if (!$this->validateSelectPayment($this->session->get('payment_method', '', 'k2store'), $values)) { $redirect = $redirect_url; } } // Validate cart has products and has stock. if (!$cart_helper->hasProducts()) { $redirect = $redirect_url; } //minimum order value check if (!$this->checkMinimumOrderValue($order)) { $error_msg[] = JText::_('K2STORE_ERROR_MINIMUM_ORDER_VALUE') . K2StorePrices::number($this->params->get('global_minordervalue')); $redirect = $redirect_url; } if (!$redirect) { $order_id = time(); $values['order_id'] = $order_id; //all is well so far. If this is a guest checkout, store the billing and shipping values of the guest in the address table. if ($this->session->has('guest', 'k2store')) { $guest = $this->session->get('guest', array(), 'k2store'); if (isset($guest['billing']) && count($guest['billing'])) { $address_model->addAddress('billing', $guest['billing']); } if (isset($guest['shipping']) && count($guest['shipping'])) { $address_model->addAddress('shipping', $guest['shipping']); } } // Save the orderitems with status if (!$this->saveOrderItems($values)) { // Output error message and halt $error_msg[] = $this->getError(); } $orderpayment_type = $this->session->get('payment_method', '', 'k2store'); //trigger onK2StoreBeforePayment event if ($showPayment == true && !empty($orderpayment_type)) { $results = $dispatcher->trigger("onK2StoreBeforePayment", array($orderpayment_type, $order)); } //set a default transaction status. $transaction_status = JText::_("K2STORE_TRANSACTION_INCOMPLETE"); // in the case of orders with a value of 0.00, use custom values if ((double) $order->order_total == (double) '0.00') { $orderpayment_type = 'free'; $transaction_status = JText::_("K2STORE_TRANSACTION_COMPLETE"); } //set order values $order->user_id = $user->id; $order->ip_address = $_SERVER['REMOTE_ADDR']; //generate a unique hash $order->token = JApplication::getHash($order_id); //user email $user_email = $user->id ? $user->email : $billing_address['email']; $order->user_email = $user_email; //generate invoice number $invoice = $orders_model->createInvoiceNumber($order_id); $order->invoice_number = $invoice->number; $order->invoice_prefix = $invoice->prefix; //get the customer note $customer_note = $this->session->get('customer_note', '', 'k2store'); $order->customer_note = $customer_note; $order->customer_language = $lang->getTag(); $order->customer_group = implode(',', $user->getAuthorisedGroups()); // Save an order with an Incomplete status $order->order_id = $order_id; $order->orderpayment_type = $orderpayment_type; // this is the payment plugin selected $order->transaction_status = $transaction_status; // payment plugin updates this field onPostPayment $order->order_state_id = 5; // default incomplete order state $order->orderpayment_amount = $order->order_total; // this is the expected payment amount. payment plugin should verify actual payment amount against expected payment amount //get currency id, value and code and store it $currency = K2StoreFactory::getCurrencyObject(); $order->currency_id = $currency->getId(); $order->currency_code = $currency->getCode(); $order->currency_value = $currency->getValue($currency->getCode()); //save whether to show shipping address or not if ($showShipping) { $order->is_shippable = 1; } else { $order->is_shippable = 0; } if ($order->save()) { //set values for orderinfo table // send the order_id and orderpayment_id to the payment plugin so it knows which DB record to update upon successful payment $values["order_id"] = $order->order_id; //$values["orderinfo"] = $order->orderinfo; $values["orderpayment_id"] = $order->id; $values["orderpayment_amount"] = $order->orderpayment_amount; // Save the orderitems with status if (!$this->saveOrderTax($values)) { // Output error message and halt $error_msg[] = $this->getError(); } if ($billing_address) { //dump all billing fields as json as it may contain custom field values as well $uset_account_type = ''; if ($this->session->has('uaccount', 'k2store')) { $uset_account_type = $this->session->get('uaccount', 'billing', 'k2store'); } if ($uset_account_type == 'register') { $type = 'register'; } elseif ($uset_account_type == 'guest') { $type = 'guest'; } elseif ($uset_account_type == 'login') { $type = 'billing'; } else { $type = 'billing'; } $values['orderinfo']['all_billing'] = $db->escape($this->processCustomFields($type, $billing_address)); foreach ($billing_address as $key => $value) { $values['orderinfo']['billing_' . $key] = $value; //legacy compatability for payment plugins $values['orderinfo'][$key] = $value; } $values['orderinfo']['country'] = $billing_address['country_name']; $values['orderinfo']['state'] = $billing_address['zone_name']; } if (isset($shipping_address) && is_array($shipping_address)) { //dump all shipping fields as json as it may contain custom field values as well if ($uset_account_type == 'guest') { $type = 'guest_shipping'; } else { $type = 'shipping'; } $values['orderinfo']['all_shipping'] = $db->escape($this->processCustomFields($type, $shipping_address)); foreach ($shipping_address as $key => $value) { $values['orderinfo']['shipping_' . $key] = $value; } } //now dump all payment_values as well. Because we may have custom fields there to if ($this->session->has('payment_values', 'k2store')) { $pay_values = $this->session->get('payment_values', array(), 'k2store'); $values['orderinfo']['all_payment'] = $db->escape($this->processCustomFields('payment', $pay_values)); } $values['orderinfo']['user_email'] = $user_email; $values['orderinfo']['user_id'] = $user->id; $values['orderinfo']['order_id'] = $order->order_id; $values['orderinfo']['orderpayment_id'] = $order->id; try { $this->saveOrderInfo($values['orderinfo']); } catch (Exception $e) { $redirect = $redirect_url; echo $e->getMessage() . "\n"; } //save shipping info if (isset($order->shipping) && !$this->saveOrderShippings($shipping_values)) { // TODO What to do if saving order shippings fails? $error = true; } } else { // Output error message and halt JError::raiseNotice('K2STORE_ERROR_SAVING_ORDER', $order->getError()); $redirect = $redirect_url; } // IMPORTANT: Store the order_id in the user's session for the postPayment "View Invoice" link $app->setUserState('k2store.order_id', $order->order_id); $app->setUserState('k2store.orderpayment_id', $order->id); $app->setUserState('k2store.order_token', $order->token); // in the case of orders with a value of 0.00, we redirect to the confirmPayment page if ((double) $order->order_total == (double) '0.00') { $free_redirect = JRoute::_('index.php?option=com_k2store&view=checkout&task=confirmPayment'); $view->assign('free_redirect', $free_redirect); } $payment_plugin = $this->session->get('payment_method', '', 'k2store'); $values['payment_plugin'] = $payment_plugin; $results = $dispatcher->trigger("onK2StorePrePayment", array($payment_plugin, $values)); // Display whatever comes back from Payment Plugin for the onPrePayment $html = ""; for ($i = 0; $i < count($results); $i++) { $html .= $results[$i]; } //check if plugins set a redirect if ($this->session->has('plugin_redirect', 'k2store')) { $redirect = $this->session->get('plugin_redirect', '', 'k2store'); } $view->assign('plugin_html', $html); $summary = $this->getOrderSummary(); $view->assign('orderSummary', $summary); } // Set display $view->setLayout('checkout_confirm'); $view->set('_doTask', true); $view->assign('order', $order); $view->assign('redirect', $redirect); $view->setModel($model, true); ob_start(); $view->display(); $html = ob_get_contents(); ob_end_clean(); echo $html; $app->close(); }
$id = JFactory::getApplication()->input->getInt('id', '0'); ?> <span style="float: right;"> [<?php echo K2StorePopup::popup("index.php?option=com_k2store&view=shipping&task=view&id={$id}&shippingTask=setRates&tmpl=component&sid={$item->shipping_method_id}", JText::_('K2STORE_SHIPM_SET_RATES')); ?> ]</span> <?php if ($shipping_method_type = K2StoreShipping::getType($item->shipping_method_type)) { echo "<b>" . JText::_('K2STORE_STANDARD_SHIPPING_TYPE') . "</b>: " . $shipping_method_type->title; } if ($item->subtotal_minimum > '0') { echo "<br/><b>" . JText::_('K2STORE_SHIPPING_METHODS_MINIMUM_SUBTOTAL_REQUIRED') . "</b>: " . K2StorePrices::number($item->subtotal_minimum); } if ($item->subtotal_maximum > '-1') { echo "<br/><b>" . JText::_('K2STORE_SHIPPING_METHODS_SUBTOTAL_MAX') . "</b>: " . K2StorePrices::number($item->subtotal_maximum); } ?> </div> </td> <td style="text-align: center;"> <?php echo $item->taxprofile_name; ?> </td> <td style="text-align: center;"> <?php if ($item->published) { $img_url = JUri::root(true) . '/media/k2store/images/tick.png'; $value = 0; } else {
} $daysin = gmdate('d'); $numsubs = $this->order_model->clearState()->since(gmdate('Y') . '-' . gmdate('m') . '-01')->until(gmdate('Y') . '-' . gmdate('m') . '-' . $lmday . ' 23:59:59')->nozero(1)->paystate(1)->getOrdersTotal(); $summoney = $this->order_model->clearState()->since(gmdate('Y') . '-' . gmdate('m') . '-01')->until(gmdate('Y') . '-' . gmdate('m') . '-' . $lmday . ' 23:59:59')->moneysum(1)->paystate(1)->getOrdersTotal(); ?> <td> <strong><?php echo sprintf('%01.1f', $numsubs / $daysin); ?> <strong> </td> <td> <strong> <?php echo K2StorePrices::number(sprintf('%01.2f', $summoney / $daysin)); ?> </strong> </td> </tr> </tbody> </table> </div>
, '<?php echo $rate['code']; ?> ', true );" <?php echo $checked; ?> /> <strong><?php echo $rate['name']; ?> </strong> <?php if (K2StorePrices::number($rate['total']) > 0) { ?> ( <?php echo K2StorePrices::number($rate['total']); ?> ) <?php } ?> </label> </div> <?php } ?> <?php } ?> <?php }
?> </th> <th style="text-align: right;"><?php echo K2StorePrices::number($row->order_surcharge, $row->currency_code, $row->currency_value); ?> </th> </tr> <?php } ?> <tr> <th colspan="<?php echo $colspan; ?> " style="font-size: 120%; text-align: right;"><?php echo JText::_("K2STORE_CART_GRANDTOTAL"); ?> </th> <th style="font-size: 120%; text-align: right;"><?php echo K2StorePrices::number($row->order_total, $row->currency_code, $row->currency_value); ?> </th> </tr> </tfoot> </table> </div> </div>
} } if ($order->order_discount > 0) { echo "(-)"; echo K2StorePrices::number($order->order_discount); echo "<br />"; } if ($order->order_tax) { echo K2StorePrices::number($order->order_tax); echo "<br />"; } if ($order->order_surcharge > 0) { echo K2StorePrices::number($order->order_surcharge); } ?> </td> </tr> <tr> <td style="text-align: right; font-weight: bold; white-space: nowrap;"> <?php echo JText::_("K2STORE_CART_GRANDTOTAL"); ?> </td> <td style="text-align: right;"> <?php echo K2StorePrices::number($order->order_total); ?> </td> </tr> </tfoot> </table>
?> ',<?php echo $method['tax']; ?> ,<?php echo $method['extra']; ?> , '<?php echo $method['code']; ?> ', true );" /> <?php echo $method['name']; ?> ( <?php echo K2StorePrices::number($method['total']); ?> ) </label> </div> <?php } ?> <?php } ?> </div> <?php }
<?php defined('_JEXEC') or die('Restricted access'); $rates = array(); foreach ($vars->rates as $rate) { $r = new JObject(); $r->value = $rate->shipping_rate_id; $r->text = K2StorePrices::number($rate->shipping_rate_price); $rates[] =& $r; } ?> <div class="shipping_rates"> <?php echo JHTML::_('select.radiolist', $rates, 'shipping_rate', array()); ?> </div>
</strong> <ol> <?php foreach ($a_options as $a_option) { ?> <li> <span><?php echo $a_option->optionvalue_name; ?> </span> <span> <?php echo $a_option->product_optionvalue_prefix; ?> <?php echo K2StorePrices::number($a_option->product_optionvalue_price); ?> </span> </li> <?php } ?> </ol> <?php } ?> <?php } ?> </ol>
function add() { $app = JFactory::getApplication(); JFactory::getDocument()->setCharset('utf-8'); $params = JComponentHelper::getParams('com_k2store'); $model = $this->getModel('mycart'); $cart_helper = new K2StoreHelperCart(); require_once JPATH_COMPONENT . '/helpers/cart.php'; $error = array(); $json = array(); //get the product id $product_id = $app->input->getInt('product_id', 0); //no product id?. return an error if (empty($product_id)) { $error['error']['product'] = JText::_('K2STORE_ADDTOCART_ERROR_MISSING_PRODUCT_ID'); echo json_encode($error); $app->close(); } //Ok. we have a product id. so proceed. //get the quantity $quantity = $app->input->get('product_qty'); if (isset($quantity)) { $quantity = $quantity; } else { $quantity = 1; } $product = $cart_helper->getItemInfo($product_id); //get the product options $options = $app->input->get('product_option', array(0), 'ARRAY'); $fabrics = $app->input->get('fabric', array(0), 'ARRAY'); if (isset($options)) { $options = array_filter($options); } else { $options = array(); } $product_options = $model->getProductOptions($product_id); //iterate through stored options for this product and validate foreach ($product_options as $product_option) { if ($product_option['required'] && empty($options[$product_option['product_option_id']])) { $json['error']['option'][$product_option['product_option_id']] = JText::sprintf('K2STORE_ADDTOCART_PRODUCT_OPTION_REQUIRED', $product_option['option_name']); } } //trigger before addtocart plugin event now... send post values $post_data = $app->input->getArray($_POST); JPluginHelper::importPlugin('k2store'); $results = $app->triggerEvent("onK2StoreBeforeAddCart", array($post_data)); if (isset($results) && count($results)) { foreach ($results as $result) { if (!empty($result['error'])) { $json['warning'] = $result['error']; } } } //validation is ok. Now add the product to the cart. if (!$json) { // JFactory::getSession()->set('fabric_id', $post_data['fabric_id']); // $fabricid[$product_id] = $post_data['fabric_id']; $cart_helper->add($product_id, $quantity, $options, $fabrics); //trigger plugin event- after addtocart $app->triggerEvent("onK2StoreAfterAddCart", array($post_data)); $product_info = K2StoreHelperCart::getItemInfo($product_id); $cart_link = JRoute::_('index.php?option=com_k2store&view=mycart'); $json['success'] = true; $json['successmsg'] = $product_info->product_name . ' ' . JText::sprintf('K2STORE_ADDTOCART_ADDED_TO_CART'); $json['data'] = $post_data; //$total = K2StoreHelperCart::getTotal(); $totals = $model->getTotals(); if ($params->get('auto_calculate_tax', 1)) { $total = $totals['total']; } else { $total = $totals['total_without_tax']; } $product_count = K2StoreHelperCart::countProducts(); //get product total $json['total'] = JText::sprintf('K2STORE_CART_TOTAL', $product_count, K2StorePrices::number($total)); //get cart info //do we have to redirect to the cart if ($params->get('popup_style', 1) == 3) { $json['redirect'] = $cart_link; } } else { //do we have to redirect // $url = 'index.php?option=com_k2&view=item&id='.$product_id; // $json['redirect'] = JRoute::_($url); } echo json_encode($json); $app->close(); }
public static function dispayPriceWithTax($price = '0', $tax = '0', $plus = '1') { $txt = ''; //price+tax //first calculate tax if ($plus == 2 && $tax) { $txt .= K2StorePrices::number($price + $tax); //$txt .= JText::sprintf('SHOW_TAX_WITH_PRICE', K2StorePrices::number($tax) ); } elseif ($plus == 3 && $tax) { $txt .= K2StorePrices::number($price); $txt .= JText::sprintf('K2STORE_SHOW_TAX_WITH_PRICE', K2StorePrices::number($tax)); } else { $txt .= K2StorePrices::number($price); } return $txt; }