$data_post = $_POST; $merchant_default_country = Yii::app()->functions->getOptionAdmin('merchant_default_country'); $package_id = isset($_GET['package_id']) ? $_GET['package_id'] : ''; $mode_autho = Yii::app()->functions->getOptionAdmin('admin_mode_autho'); $autho_api_id = Yii::app()->functions->getOptionAdmin('admin_autho_api_id'); $autho_key = Yii::app()->functions->getOptionAdmin('admin_autho_key'); if (empty($mode_autho) && empty($autho_api_id) && empty($autho_key)) { $error = t("Authorize.net is not properly configured"); } if ($res = Yii::app()->functions->getSMSPackagesById($package_id)) { $amount_to_pay = $res['price']; if ($res['promo_price'] > 0) { $amount_to_pay = $res['promo_price']; } $amount_to_pay = is_numeric($amount_to_pay) ? normalPrettyPrice($amount_to_pay) : ''; $amount_to_pay = unPrettyPrice($amount_to_pay); $payment_description .= isset($res['title']) ? $res['title'] : ''; /*dump($amount_to_pay); dump($payment_description);*/ if (isset($_POST['x_card_num'])) { define("AUTHORIZENET_API_LOGIN_ID", $autho_api_id); define("AUTHORIZENET_TRANSACTION_KEY", $autho_key); define("AUTHORIZENET_SANDBOX", $mode_autho == "sandbox" ? true : false); //define("TEST_REQUEST", $mode_autho=="sandbox"?"FALSE":"TRUE"); require_once 'anet_php_sdk/AuthorizeNet.php'; $transaction = new AuthorizeNetAIM(); $transaction->setSandbox(AUTHORIZENET_SANDBOX); $params = array('description' => $payment_description, 'amount' => $amount_to_pay, 'card_num' => $_POST['x_card_num'], 'exp_date' => $_POST['expiration_month'] . "/" . $_POST['expiration_yr'], 'first_name' => $_POST['x_first_name'], 'last_name' => $_POST['x_last_name'], 'address' => $_POST['x_address'], 'city' => $_POST['x_city'], 'state' => $_POST['x_state'], 'country' => $_POST['x_country'], 'zip' => $_POST['x_zip'], 'card_code' => $_POST['cvv']); $transaction->setFields($params); $response = $transaction->authorizeAndCapture(); if ($response->approved) {
<?php echo displayPrice(baseCurrency(), prettyFormat($minimum_order, $merchant_id)); ?> </p> <?php } ?> <?php $merchant_maximum_order = Yii::app()->functions->getOption("merchant_maximum_order", $merchant_id); ?> <?php if (is_numeric($merchant_maximum_order)) { ?> <?php echo CHtml::hiddenField('merchant_maximum_order', unPrettyPrice($merchant_maximum_order)); echo CHtml::hiddenField('merchant_maximum_order_pretty', baseCurrency() . prettyFormat($merchant_maximum_order)); ?> <p class="uk-text-muted"><?php echo Yii::t("default", "Maximum Order is"); ?> <?php echo displayPrice(baseCurrency(), prettyFormat($merchant_maximum_order, $merchant_id)); ?> </p> <?php } ?> <div class="delivery_options uk-form" style="margin-top:10px;">
public function chartTotalSales() { $merchant_id = Yii::app()->functions->getMerchantID(); $data = ''; $db_ext = new DbExt(); $date_now = date('Y-m-d 23:00:59'); $start_date = date('Y-m-d 00:00:00', strtotime($date_now . "-30 days")); $stmt = "SELECT DATE_FORMAT(date_created, '%M-%D') as date_created_format,SUM(total_w_tax) as total\r\n\t \tFROM\r\n\t \t{{order}}\r\n\t \tWHERE\r\n\t \tdate_created BETWEEN '{$start_date}' AND '{$date_now}'\r\n\t \tAND\r\n\t \tmerchant_id ='{$merchant_id}'\r\n\t \tAND status NOT IN ('" . initialStatus() . "')\r\n\t \tGROUP BY DATE_FORMAT(date_created, '%M-%D')\r\n\t \tORDER BY date_created ASC\r\n\t \t"; //dump($stmt); if ($res = $db_ext->rst($stmt)) { foreach ($res as $val) { //$data[$val['date_created_format']]=prettyFormat($val['total'],$merchant_id); $t = explode("-", $val['date_created_format']); if (is_array($t) && count($t) >= 1) { $tt = Yii::t("default", $t[0]) . "-" . $t[1]; $data[$tt] = unPrettyPrice($val['total']); } else { $data[$val['date_created_format']] = unPrettyPrice($val['total']); } } } echo Yii::app()->functions->formatAsChart($data); die; }
$publishable_key = Yii::app()->functions->getOption('live_stripe_pub_key', $merchant_id); } /*COMMISSION*/ if (Yii::app()->functions->isMerchantCommission($merchant_id)) { $mode = Yii::app()->functions->getOptionAdmin('admin_stripe_mode'); if ($mode == "Sandbox") { $secret_key = Yii::app()->functions->getOptionAdmin('admin_sanbox_stripe_secret_key'); $publishable_key = Yii::app()->functions->getOptionAdmin('admin_sandbox_stripe_pub_key'); } elseif ($mode == "live") { $secret_key = Yii::app()->functions->getOptionAdmin('admin_live_stripe_secret_key'); $publishable_key = Yii::app()->functions->getOptionAdmin('admin_live_stripe_pub_key'); } } if (!empty($mode) && !empty($secret_key) && !empty($publishable_key)) { $amount_to_pay = isset($data['total_w_tax']) ? Yii::app()->functions->standardPrettyFormat($data['total_w_tax']) : ''; $amount_to_pay = is_numeric($amount_to_pay) ? unPrettyPrice($amount_to_pay * 100) : ''; $amount_to_pay = Yii::app()->functions->normalPrettyPrice2($amount_to_pay); $payment_description .= isset($data['merchant_name']) ? $data['merchant_name'] : ''; $merchant_name = isset($data['merchant_name']) ? $data['merchant_name'] : ''; $stripe = array("secret_key" => $secret_key, "publishable_key" => $publishable_key); Stripe::setApiKey($stripe['secret_key']); } else { $error = Yii::t("default", "Stripe payment is not properly configured on merchant portal."); } } else { $error = Yii::t("default", "Sorry but we cannot find what your are looking for."); } if (isset($_POST)) { if (is_array($_POST) && count($_POST) >= 1) { $step2 = true; $token = isset($_POST['stripeToken']) ? $_POST['stripeToken'] : '';
public function getCart() { $merchant_id = isset($this->data['mtid']) ? $this->data['mtid'] : ''; if (!is_numeric($merchant_id)) { echo Yii::t("default", "Merchant ID is missing"); return; } $is_merchant_open = Yii::app()->functions->isMerchantOpen($merchant_id); $is_merchant_open1 = $is_merchant_open; $merchant_preorder = Yii::app()->functions->getOption("merchant_preorder", $merchant_id); $disbabled_table_booking = Yii::app()->functions->getOption("merchant_table_booking", $merchant_id); if ($merchant_preorder == 1) { $is_merchant_open = true; } echo CHtml::hiddenField('is_merchant_open', $is_merchant_open == true ? 1 : 2); $close_msg = Yii::app()->functions->getOption("merchant_close_msg", $merchant_id); if (empty($close_msg)) { $close_msg = Yii::t("default", "This restaurant is closed now. Please check the opening times."); } ?> <div class="order-list-wrap"> <h5><?php echo Yii::t("default", "Your Order"); ?> </h5> <div class="item-order-wrap"></div> <!--END item-order-wrap--> <!--VOUCHER STARTS HERE--> <?php //Widgets::applyVoucher($merchant_id); ?> <!--VOUCHER STARTS HERE--> <?php $minimum_order = Yii::app()->functions->getOption('merchant_minimum_order', $merchant_id); ?> <?php if (!empty($minimum_order)) { ?> <?php echo CHtml::hiddenField('minimum_order', unPrettyPrice($minimum_order)); //echo CHtml::hiddenField('minimum_order_pretty',baseCurrency().prettyFormat($minimum_order)) echo CHtml::hiddenField('minimum_order_pretty', prettyFormat($minimum_order)); ?> <p class="uk-text-muted"><?php echo Yii::t("default", "Subtotal must exceed"); ?> <?php echo baseCurrency() . prettyFormat($minimum_order, $merchant_id); ?> </p> <?php } ?> <?php $merchant_maximum_order = Yii::app()->functions->getOption("merchant_maximum_order", $merchant_id); ?> <?php if (is_numeric($merchant_maximum_order)) { ?> <?php echo CHtml::hiddenField('merchant_maximum_order', unPrettyPrice($merchant_maximum_order)); echo CHtml::hiddenField('merchant_maximum_order_pretty', baseCurrency() . prettyFormat($merchant_maximum_order)); ?> <p class="uk-text-muted"><?php echo Yii::t("default", "Maximum Order is"); ?> <?php echo baseCurrency() . prettyFormat($minimum_order, $merchant_id); ?> </p> <?php } ?> <div class="delivery_options uk-form" style="margin-top:10px;"> <h5><?php echo Yii::t("default", "Delivery Options"); ?> </h5> <?php echo CHtml::dropDownList('delivery_type', $now, (array) Yii::app()->functions->DeliveryOptions($merchant_id)); ?> <?php echo CHtml::textField('delivery_date', $now, array('class' => "j_date")); ?> <?php echo CHtml::textField('delivery_time', $now_time, array('class' => "timepick", 'placeholder' => Yii::t("default", "Delivery Time"))); ?> <span class="uk-text-small uk-text-muted"><?php echo Yii::t("default", "Delivery ASAP?"); ?> </span> <?php echo CHtml::checkBox('delivery_asap', false, array('class' => "icheck")); ?> </div> <?php if (yii::app()->functions->validateSellLimit($merchant_id)) { ?> <?php if ($is_merchant_open1) { ?> <a href="javascript:;" class="uk-button checkout"><?php echo Yii::t("default", "Checkout"); ?> </a> <?php } else { ?> <?php if ($merchant_preorder == 1) { ?> <a href="javascript:;" class="uk-button checkout"><?php echo Yii::t("default", "Pre-Order"); ?> </a> <?php } else { ?> <p class="uk-alert uk-alert-warning"><?php echo Yii::t("default", "Sorry merchant is closed."); ?> </p> <p><?php echo prettyDate(date('c'), true); ?> </p> <?php } ?> <?php } ?> <?php } else { ?> <?php $msg = Yii::t("default", "This merchant is not currently accepting orders."); ?> <p class="uk-text-danger"><?php echo $msg; ?> </p> <?php } ?> </div> <!--order-list-wrap--> <?php die; }
<div class="order-list-wrap"> <h5><?php echo Yii::t("default", "Your Order"); ?> </h5> <div class="item-order-wrap"></div> <?php $minimum_order = Yii::app()->functions->getOption('merchant_minimum_order', $merchant_id); ?> <?php if (!empty($minimum_order)) { ?> <?php echo CHtml::hiddenField('minimum_order', unPrettyPrice($minimum_order)); echo CHtml::hiddenField('minimum_order_pretty', baseCurrency() . prettyFormat($minimum_order)); ?> <p class="uk-text-muted"><?php echo Yii::t("default", "Subtotal must exceed"); ?> <?php echo baseCurrency() . prettyFormat($minimum_order, $merchant_id); ?> </p> <?php } ?>
public function displayOrderHTML($data = '', $cart_item = '', $receipt = false, $new_order_id = '') { $item_array = ''; $this->code = 2; $htm = ''; $subtotal = 0; $mid = isset($data['merchant_id']) ? $data['merchant_id'] : ''; if (empty($mid)) { $this->msg = Yii::t("default", "Merchant ID is empty"); return; } Yii::app()->functions->data = "list"; $food_item = Yii::app()->functions->getFoodItemLists($mid); $subcat_list = Yii::app()->functions->getAddOnLists($mid); //dump($cart_item); //dump($food_item); if (isset($cart_item)) { if (is_array($cart_item) && count($cart_item) >= 1) { $x = 0; foreach ($cart_item as $key => $val) { $val['notes'] = isset($val['notes']) ? $val['notes'] : ""; $size_words = ''; $t = !empty($val['price']) ? explode("|", $val['price']) : ''; if (is_array($t) && count($t) >= 1) { $val['price'] = $t[0]; $size_words = $t[1]; } $price = cleanNumber(unPrettyPrice($val['price'])); if (!empty($val['discount'])) { $val['discount'] = unPrettyPrice($val['discount']); $price = $price - $val['discount']; } $qty = $val['qty']; /** fixed addon qty */ $total_price = $val['qty'] * $price; /** check if item is taxable*/ //dump($val); $food_taxable = true; if (isset($val['non_taxable'])) { if ($val['non_taxable'] == 2) { $food_taxable = false; } } $subtotal = $subtotal + $total_price; if ($food_taxable == false) { $subtotal_non = $subtotal_non + $total_price; } /*$size_words=''; if ( $price_size=explodeData($val['price'])){ if (isset($price_size[1])){ $size_words=$price_size[1]; } } */ /** Translation */ $food_infos = ''; $size_info_trans = ''; $cooking_ref_trans = ''; if ($this->getOptionAdmin("enabled_multiple_translation") == 2) { $food_info = $this->getFoodItem($val['item_id']); $food_infos['item_name_trans'] = !empty($food_info['item_name_trans']) ? json_decode($food_info['item_name_trans'], true) : ''; if (!empty($size_words)) { $size_info_trans = $this->getSizeTranslation($size_words, $mid); } if (!empty($val['cooking_ref'])) { $cooking_ref_trans = $this->getCookingTranslation($val['cooking_ref'], $mid); } } $htm .= '<div class="item-order-list item-row">'; $htm .= '<div class="a">' . $val['qty'] . '</div>'; $htm .= '<div class="b">' . qTranslate($food_item[$val['item_id']], 'item_name', $food_infos); if (!empty($size_words)) { $htm .= "(" . ucwords(qTranslate($size_words, 'size_name', $size_info_trans)) . ")"; } // array value $item_array[$key] = array('item_id' => $val['item_id'], 'item_name' => $food_item[$val['item_id']], 'size_words' => $size_words, 'qty' => $val['qty'], 'normal_price' => prettyFormat($val['price']), 'discounted_price' => $price, 'order_notes' => isset($val['notes']) ? $val['notes'] : '', 'cooking_ref' => isset($val['cooking_ref']) ? $val['cooking_ref'] : '', 'ingredients' => isset($val['ingredients']) ? $val['ingredients'] : '', 'non_taxable' => isset($val['non_taxable']) ? $val['non_taxable'] : 1); $htm .= Widgets::displaySpicyIconByID($val['item_id']); if (!empty($val['discount'])) { $htm .= "<p class=\"uk-text-small\">" . "<span class=\"normal-price\">" . displayPrice(baseCurrency(), prettyFormat($val['price'])) . " </span>" . "<span class=\"sale-price\">" . displayPrice(baseCurrency(), prettyFormat($price)) . "</span>" . "</p>"; } else { $htm .= "<p class=\"uk-text-small\">" . "<span class=\"base-price\">" . displayPrice(baseCurrency(), prettyFormat($val['price'])) . "</span>" . "</p>"; } if (!empty($val['cooking_ref'])) { $htm .= "<p class=\"uk-text-small\">" . qTranslate($val['cooking_ref'], 'cooking_name', $cooking_ref_trans) . "</p>"; } if (!empty($val['notes'])) { $htm .= "<p class=\"uk-text-small\">" . $val['notes'] . "</p>"; } /*ingredients*/ if (isset($val['ingredients'])) { if (!empty($val['ingredients'])) { if (is_array($val['ingredients']) && count($val['ingredients']) >= 1) { $htm .= "<p class=\"uk-text-small ingredients-label\">" . t("Ingredients") . ":</p>"; foreach ($val['ingredients'] as $val_ingred) { $htm .= "<p class=\"uk-text-small\">" . $val_ingred . "</p>"; } } } } $htm .= '</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="c">'; if ($receipt == false) { $htm .= '<a href="javascript:;" class="edit_item" data-row="' . $key . '" rel="' . $val['item_id'] . '" > <i class="fa fa-pencil-square-o"></i> </a>'; $htm .= '<a href="javascript:;" class="delete_item" data-row="' . $key . '" rel="' . $val['item_id'] . '" > <i class="fa fa-trash-o"></i> </a>'; } $htm .= '</div>'; $htm .= '<div class="d">' . displayPrice(baseCurrency(), prettyFormat($total_price, $mid)) . '</div>'; $htm .= '</div>'; $htm .= '<div class="clear"></div>'; /*SUB ITEM*/ //dump($val); //$item_array[$key]['sub_item']=$val['sub_item']; $val['sub_item'] = isset($val['sub_item']) ? $val['sub_item'] : ''; if (is_array($val['sub_item']) && count($val['sub_item']) >= 1) { foreach ($val['sub_item'] as $cat_id => $val_sub) { if (array_key_exists($cat_id, (array) $subcat_list)) { //** Translation */ $subcategory_trans = ''; if ($this->getOptionAdmin("enabled_multiple_translation") == 2) { if ($subcategory_tran = $this->getAddonCategory($cat_id)) { $subcategory_trans['subcategory_name_trans'] = !empty($subcategory_tran['subcategory_name_trans']) ? json_decode($subcategory_tran['subcategory_name_trans'], true) : ''; } } $htm .= '<div class="a"></div>'; $htm .= '<div class="b uk-text-success">' . ucwords(qTranslate($subcat_list[$cat_id], 'subcategory_name', $subcategory_trans)) . '</div>'; $htm .= '<div class="clear"></div>'; } $addon_qty = 1; foreach ($val_sub as $addon_row => $val_subs) { if (isset($val['addon_qty'][$cat_id])) { $addon_qty = $val['addon_qty'][$cat_id][$addon_row]; } else { $addon_qty = $addon_qty * $qty; /** fixed addon qty */ /*if ( in_array($val['item_id'],(array)$added_item)){ $addon_qty=0; }*/ } $val_subs = explodeData($val_subs); //dump($val_subs); $addon_raw_price = prettyFormat($val_subs[1]); $addon_item_price = unPrettyPrice($val_subs[1]); $addon_item_price = $addon_qty * $addon_item_price; /** two flavor */ if ($val['two_flavors'] == 2) { if ($val_subs[3] == "") { $subtotal += $addon_item_price; if ($food_taxable == false) { $subtotal_non += $addon_item_price; } } } else { /** check if item is taxable*/ $subtotal += $addon_item_price; if ($food_taxable == false) { $subtotal_non += $addon_item_price; } } $item_array[$key]['sub_item'][] = array('addon_name' => $val_subs[2], 'addon_category' => $subcat_list[$cat_id], 'addon_qty' => $addon_qty, 'addon_price' => unPrettyPrice($val_subs[1])); /**translation */ $addon_name_trans = ''; if ($this->getOptionAdmin("enabled_multiple_translation") == 2) { $addon_name_trans = $this->getAddonTranslation($val_subs[2], $mid); } $htm .= '<div class="a">' . $addon_qty . 'x</div>'; $htm .= '<div class="b uk-text-muted">' . "{$addon_raw_price} " . ucwords(qTranslate($val_subs[2], 'sub_item_name', $addon_name_trans)) . '</div>'; $htm .= '<div class="manage">'; if ($addon_item_price != 0) { $htm .= '<div class="d">' . displayPrice(baseCurrency(), prettyFormat($addon_item_price)) . '</div>'; } else { $htm .= '<div class="d">-</div>'; } $htm .= '</div>'; $htm .= '<div class="clear"></div>'; } } } $htm .= '</div>'; $x++; $added_item[] = $val['item_id']; /** fixed addon qty */ } $taxable_subtotal = 0; $tax_amt = 0; $tax = Yii::app()->functions->getOption('merchant_tax', $mid); //dump($tax); /*if transaction is pickup*/ /*if ($data['delivery_type']=="pickup"){ $tax=0; }*/ $tax_amt = $tax; $delivery_charges = Yii::app()->functions->getOption('merchant_delivery_charges', $mid); //shipping rates if (isset($_SESSION['shipping_fee'])) { if (is_numeric($_SESSION['shipping_fee'])) { $delivery_charges = $_SESSION['shipping_fee']; } } //if (isset($data['delivery_charge']) && $data['delivery_charge']>=1){ if (isset($data['delivery_charge'])) { $delivery_charges = $data['delivery_charge']; } //end shipping rates $merchant_packaging_charge = Yii::app()->functions->getOption('merchant_packaging_charge', $mid); //fixed packaging charge if (isset($data['packaging'])) { if ($data['packaging'] > 0) { $merchant_packaging_charge = $data['packaging']; } } if (!empty($delivery_charges)) { $delivery_charges = unPrettyPrice($delivery_charges); } else { $delivery_charges = 0; } /*if transaction is pickup*/ //dump($data); if ($data['delivery_type'] == "pickup") { $delivery_charges = 0; } /*VOUCHER*/ $has_voucher = false; $less_voucher = 0; $voucher_type = ""; if (isset($_SESSION['voucher_code'])) { if (is_array($_SESSION['voucher_code'])) { $has_voucher = true; //dump($_SESSION['voucher_code']); $_SESSION['voucher_code']['amount'] = unPrettyPrice($_SESSION['voucher_code']['amount']); if ($_SESSION['voucher_code']['voucher_type'] == "fixed amount") { $less_voucher = $_SESSION['voucher_code']['amount']; } else { $less_voucher = $subtotal * ($_SESSION['voucher_code']['amount'] / 100); $voucher_type = normalPrettyPrice($_SESSION['voucher_code']['amount']) . "%"; } $_SESSION['less_voucher'] = $less_voucher; } } if ($receipt == TRUE) { $order_ids = isset($data['order_id']) ? $data['order_id'] : ''; if (isset($_GET['id'])) { $order_ids = $_GET['id']; } $order_infos = $this->getOrderInfo($order_ids); //dump($order_infos); if (!empty($order_infos['voucher_code'])) { $has_voucher = true; if ($order_infos['voucher_type'] == "fixed amount") { $less_voucher = $order_infos['voucher_amount']; } else { $voucher_type = normalPrettyPrice((int) $order_infos['voucher_amount']) . "%"; $less_voucher = $subtotal * ($order_infos['voucher_amount'] / 100); } } } if ($less_voucher == TRUE) { $subtotal = $subtotal - $less_voucher; /** check if item is taxable*/ if ($food_taxable == false) { $subtotal_non = $subtotal_non - $less_voucher; } } /*PROMO STARTS HERE*/ $show_discount = false; $discounted_amount = 0; $merchant_discount_amount = 0; if ($receipt == TRUE) { $_GET['id'] = isset($_GET['id']) ? $_GET['id'] : $new_order_id; if ($promo_res = $this->getOrderDiscount($_GET['id'])) { if ($promo_res['discounted_amount'] >= 0.1) { $show_discount = true; $merchant_discount_amount = number_format($promo_res['discount_percentage'], 0); $discounted_amount = $promo_res['discounted_amount']; $subtotal = $subtotal - $discounted_amount; /** check if item is taxable*/ if ($food_taxable == false) { $subtotal_non = $subtotal_non - $discounted_amount; } } } } else { if ($promo_res = Yii::app()->functions->getMerchantOffersActive($mid)) { $merchant_spend_amount = $promo_res['offer_price']; $merchant_discount_amount = number_format($promo_res['offer_percentage'], 0); if ($subtotal >= $merchant_spend_amount) { $show_discount = true; $merchant_discount_amount1 = $merchant_discount_amount / 100; $discounted_amount = $subtotal * $merchant_discount_amount1; $subtotal = $subtotal - $discounted_amount; /** check if item is taxable*/ if ($food_taxable == false) { $subtotal_non = $subtotal_non - $discounted_amount; } } } } /**above sub total free delivery*/ $free_delivery = false; if ($data['delivery_type'] == "delivery") { $free_delivery_above_price = Yii::app()->functions->getOption("free_delivery_above_price", $mid); if (!empty($free_delivery_above_price)) { if ($subtotal >= $free_delivery_above_price) { $delivery_charges = 0; $free_delivery = true; } } } /**above sub total free delivery*/ /** packaging incremental*/ if (Yii::app()->functions->getOption("merchant_packaging_increment", $mid) == 2) { if (!isset($data['packaging'])) { $total_cart_item = 0; foreach ($cart_item as $cart_item_x) { $total_cart_item += $cart_item_x['qty']; } $merchant_packaging_charge = $total_cart_item * $merchant_packaging_charge; } } if (!empty($tax)) { $tax = $tax / 100; /** check if item is taxable*/ $temp_delivery_charges = $delivery_charges; if (Yii::app()->functions->getOption("merchant_tax_charges", $merchant_id) == 2) { $temp_delivery_charges = 0; } if ($receipt == true) { if (isset($data['donot_apply_tax_delivery'])) { if ($data['donot_apply_tax_delivery'] == 2) { $temp_delivery_charges = 0; } } } if ($subtotal_non >= 1) { $temp_subtotal = $subtotal - $subtotal_non; $taxable_subtotal = ($temp_subtotal + $temp_delivery_charges + $merchant_packaging_charge) * $tax; } else { $taxable_subtotal = ($subtotal + $delivery_charges + $merchant_packaging_charge) * $tax; } /*dump($subtotal); dump($subtotal_non); dump("taxable_subtotal=>".$taxable_subtotal);*/ } $total = $subtotal + $taxable_subtotal + $delivery_charges + $merchant_packaging_charge; $htm .= '<div class="summary-wrap">'; if ($has_voucher == TRUE) { if ($show_discount == true) { $htm .= '<div class="a">' . t("Discount") . " {$merchant_discount_amount}%" . ':</div>'; $htm .= '<div class="manage manage-ux">'; $htm .= '<div class="b">(' . displayPrice(baseCurrency(), prettyFormat($discounted_amount, $mid)) . ')</div>'; $htm .= '</div>'; } /*$cart_subtotal_raw=$subtotal+$less_voucher; $htm.="<span class=\"cart_subtotal_raw\" data-value=\"$cart_subtotal_raw\" ></span>";*/ $htm .= '<div class="a">' . Yii::t("default", "Sub Total") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b cart_subtotal">' . displayPrice(baseCurrency(), prettyFormat($subtotal + $less_voucher, $mid)) . '</div>'; $htm .= '</div>'; if ($receipt == TRUE) { $voucher_code = " - " . $order_infos['voucher_code'] . ""; } else { $voucher_code = ''; } $htm .= '<div class="a">' . Yii::t("default", "Less Voucher") . " " . $voucher_type . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">-' . displayPrice(baseCurrency(), prettyFormat($less_voucher, $mid)) . '</div>'; $htm .= '</div>'; $htm .= '<div class="a">' . Yii::t("default", "Sub Total") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($subtotal, $mid)) . '</div>'; $htm .= '</div>'; } else { if ($show_discount == true) { $htm .= '<div class="a">' . t("Discount") . " {$merchant_discount_amount}%" . ':</div>'; $htm .= '<div class="manage manage-ux">'; $htm .= '<div class="b">(' . displayPrice(baseCurrency(), prettyFormat($discounted_amount, $mid)) . ')</div>'; $htm .= '</div>'; } /*$cart_subtotal_raw=$subtotal; $htm.="<span class=\"cart_subtotal_raw\" data-value=\"$cart_subtotal_raw\" ></span>";*/ $htm .= '<div class="a">' . Yii::t("default", "Sub Total") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b cart_subtotal">' . displayPrice(baseCurrency(), prettyFormat($subtotal, $mid)) . '</div>'; $htm .= '</div>'; } if (!empty($delivery_charges)) { $htm .= '<div class="a">' . Yii::t("default", "Delivery Fee") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($delivery_charges, $mid)) . '</div>'; $htm .= '</div>'; } if ($free_delivery == true) { $htm .= '<div class="a">' . Yii::t("default", "Delivery Fee") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . t("Free") . '</div>'; $htm .= '</div>'; } if (!empty($merchant_packaging_charge)) { $htm .= '<div class="a">' . Yii::t("default", "Packaging") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($merchant_packaging_charge, $mid)) . '</div>'; $htm .= '</div>'; } if (!empty($tax)) { $htm .= '<div class="a">' . Yii::t("default", "Tax") . ' ' . $tax_amt . '% :</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($taxable_subtotal, $mid)) . '</div>'; $htm .= '</div>'; } if (isset($data['cart_tip_value'])) { if ($data['cart_tip_value'] >= 0.1) { $htm .= '<div class="a">' . Yii::t("default", "Tips") . ' ' . number_format($data['cart_tip_percentage'], 0) . '% :</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($data['cart_tip_value'], $mid)) . '</div>'; $htm .= '</div>'; $total += $data['cart_tip_value']; } } if (isset($data['card_fee'])) { if ($data['card_fee'] >= 0.1) { $htm .= '<div class="a">' . Yii::t("default", "Card Fee") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($data['card_fee'], $mid)) . '</div>'; $htm .= '</div>'; $total += $data['card_fee']; } } $htm .= '<div class="a bold cart_total_wrap">' . Yii::t("default", "Total") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b bold cart_total">' . displayPrice(baseCurrency(), prettyFormat($total, $mid)) . '</div>'; $htm .= '</div>'; $htm .= '<div class="clear"></div>'; $htm .= '</div>'; $htm .= CHtml::hiddenField("subtotal_order", unPrettyPrice($subtotal + $less_voucher)); $htm .= CHtml::hiddenField("subtotal_order2", unPrettyPrice($subtotal)); $htm .= CHtml::hiddenField("subtotal_extra_charge", unPrettyPrice($delivery_charges + $merchant_packaging_charge + $taxable_subtotal)); // array value $item_array_total = array('subtotal' => $subtotal, 'taxable_total' => $taxable_subtotal, 'delivery_charges' => $delivery_charges, 'total' => $total, 'tax' => $tax, 'tax_amt' => $tax_amt, 'curr' => baseCurrency(), 'mid' => $mid, 'discounted_amount' => $discounted_amount, 'merchant_discount_amount' => $merchant_discount_amount, 'merchant_packaging_charge' => $merchant_packaging_charge); /*dump($data); dump($htm);*/ $this->code = 1; $this->msg = "OK"; $this->details = array('item-count' => $x, 'html' => $htm, 'raw' => array('item' => $item_array, 'total' => $item_array_total)); } else { $this->msg = Yii::t("default", "No Item added yet!"); } } else { $this->msg = Yii::t("default", "No Item added yet!"); } }