Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace ORORI\FrontendBundle\Controller;
- use Symfony\Component\HttpFoundation\JsonResponse;
- use Symfony\Component\HttpFoundation\Request;
- class CartController extends MainController
- {
- private $diamondPromo = [
- ];
- private $clearencePromo = [
- 'WP-1014',
- 'WP-1041',
- 'WP-1029',
- 'WP-1033',
- 'WP-1026',
- 'WP-1028',
- 'WP-1024',
- 'WP-1032',
- 'WP-1067',
- 'WR-1023',
- 'WR-1033',
- 'WR-1028',
- 'WR-1026',
- 'WR-1060',
- 'WR-1021',
- 'WR-1025',
- 'WR-1010',
- 'WR-1031',
- 'WR-1034',
- 'WR-1040',
- 'WR-1050',
- 'WR-1065'
- ];
- private $satujutavoucherPromo = [
- 'VC-FLASH-1000-GOLD'
- ];
- protected function rateLimitAccess()
- {
- $session = $this->get('session');
- $rateLimitQuota = $session->get('rate_limit_quota', null); // quota of api call
- $rateLimitRefresh = $session->get('rate_limit_refresh', null); // time to refresh quota
- $rateLimitWindow = 1 * 60; // minutes
- $rateLimitMaxQuota = 5; // 5 max requests per $rateLimitWindow
- if ($rateLimitQuota === null) {
- $rateLimitQuota = $rateLimitMaxQuota;
- $rateLimitRefresh = time() + $rateLimitWindow;
- } else {
- if ($rateLimitQuota == 0) {
- if ($rateLimitRefresh > time()) {
- return false;
- } else {
- $rateLimitRefresh = time() + $rateLimitWindow;
- $rateLimitQuota = $rateLimitMaxQuota;
- }
- } else {
- --$rateLimitQuota;
- }
- }
- $session->set('rate_limit_quota', $rateLimitQuota);
- $session->set('rate_limit_refresh', $rateLimitRefresh);
- return true; // all good
- }
- protected function checkVoucherAction(Request $request)
- {
- if ($this->rateLimitAccess() == false) {
- return new JsonResponse(['status' => 'error', 'message' => 'Too many request'], 429);
- }
- $request->request->set('method', 'GET');
- $request->request->set('url', '/frontend/voucher/'.$request->query->get('voucher'));
- $request->request->set('param', [
- 'shopping_cart_id' => $request->query->get('shoppingcart_id'),
- 'value' => $request->query->get('value'),
- ]);
- $result = $this->apiAction($request);
- if ($result->getStatusCode() == 200) {
- $response = json_decode($result->getContent());
- return new JsonResponse(['status' => 'success', 'voucher' => $response->voucher]);
- } elseif ($result->getStatusCode() == 400) {
- $response = json_decode($result->getContent());
- $message = isset($response->error->user_message) ? $response->error->user_message : 'Invalid voucher'; // alias for 'server error'
- return new JsonResponse(['status' => 'error', 'message' => $message]);
- } else {
- return new JsonResponse([]);
- }
- }
- protected function deleteAction(Request $request)
- {
- $shop_id = array();
- $ac = $request->query->get('ac');
- $pg = $request->query->get('pg');
- $shoppingcart = $this->getShoppingCart($request, $ac, $pg);
- if (!$shoppingcart) {
- return $this->redirect('/');
- }
- $x = 0;
- foreach ($shoppingcart as $row) {
- $shop_id[$x] = $row->id;
- ++$x;
- }
- return $this->render('ORORIFrontendBundle:Page:shopping-cart-thanks.html.twig', array(
- 'title' => 'Shopping Cart',
- 'id' => $shop_id,
- 'access_token' => $ac,
- 'page_cookie' => $pg,
- 'active' => 'cart',
- ));
- }
- protected function initializeShoppingcart(Request $request, $customer = null)
- {
- $shoppingCarts = $this->getShoppingCart($request, $request->cookies->get('access_token'), $request->cookies->get('pg'));
- if (!empty($shoppingCarts->shoppingcart)) {
- $apply = false;
- $isDiamondPromo = false;
- $payment_methode = [
- 'transfer' => true,
- 'cc' => true,
- 'bca_cicilan' => true,
- 'cimb' => true,
- 'klikbca' => true,
- 'klikpay' => true,
- 'mandiriclickpay' => true,
- 'mandirisms' => false,
- 'virtual' => true,
- 'edc' => true
- ];
- // $applyProductCategoryPrefix = ['custom_earring','custom_ring','custom_pendant', 'diamond'];
- //https://app.asana.com/0/36113108136077/140737874362676
- $applyProductCategoryPrefix = ['custom_earring','custom_ring','custom_pendant'];
- $type_free = [
- 'custom',
- 'ring',
- 'bridal',
- 'rolletto',
- 'signa',
- 'diamondjewelry',
- 'mensring',
- 'goldjewelry',
- 'engagement',
- 'package',
- 'customring',
- 'dmo_ring',
- 'ubs_fashion',
- 'ubs_gold',
- 'ubs_mensring',
- 'ubs_womensring',
- 'diamond'
- ];
- $bca_cicilan_except = [
- 'gold_antam',
- 'gold_pamp',
- 'gold_dowry',
- 'custom',
- // 'diamond',
- //'box',
- //'cleaning'
- ];
- $cc_except = [
- 'gold_antam',
- 'gold_pamp',
- 'gold_dowry',
- //'box',
- //'cleaning'
- ];
- $bca_klikpay_except = [
- 'gold_antam',
- 'gold_pamp',
- 'gold_dowry',
- //'box',
- //'cleaning'
- ];
- $titleExcept = ['diamond', 'gift', 'gold_antam', 'gold_pamp', 'gold_pendant_alphabet', 'bridal', 'rolletto', 'signa'];
- $titleMapper = array(
- 'box' => 'Kotak',
- 'cleaning' => 'Pembersih',
- 'custom_customer' => 'Custom',
- 'custom_for_customer' => 'Custom',
- 'customer_for_customer' => 'Custom',
- 'custom' => 'My Custom Design',
- 'custom_earring' => 'Rangka Anting',
- 'custom_pendant' => 'Rangka Liontin',
- 'custom_ring' => 'Rangka Cincin',
- 'custom_voucher' => 'Voucher',
- 'diamond_men_ring' => 'Cincin Pria',
- 'diamond_women_ring' => 'Cincin Wanita',
- 'diamond_pendant' => 'Liontin Berlian',
- 'diamond_earring' => 'Anting Berlian',
- 'diamond_religious' => 'Liontin Religius',
- 'diamond_bracelet' => 'Gelang Berlian',
- 'alphabet_frame' => 'Rangka Liontin',
- 'alphabet_frame_yellow' => 'Rangka Liontin',
- 'alphabet_frame_rose' => 'Rangka Liontin',
- 'gold_ankle_bracelet' => 'Gelang Kaki',
- 'gold_bracelet' => 'Gelang Emas',
- 'gold_earring' => 'Anting Emas',
- 'gold_necklace' => 'Kalung Emas',
- 'gold_pendant' => 'Liontin Emas',
- 'package' => 'Paket Perhiasan',
- 'solitaire_ring' => 'Love Ring',
- 'solitaire_pendant' => 'Love Charm',
- 'solitaire_earring' => 'Love Mee',
- 'bestvalue' => 'Cincin Kawin',
- 'beauty' => 'Cincin Kawin',
- 'design' => 'Cincin Kawin',
- 'simply' => 'Cincin Kawin',
- 'ethnic' => 'Cincin Kawin',
- 'bridal' => 'Bridal',
- 'rolletto' => 'Rolletto',
- 'signa' => 'Signa',
- 'ubs_necklace' => 'Kalung UBS',
- 'ubs_earring' => 'Anting UBS',
- 'ubs_bracelet' => 'Gelang UBS',
- 'ubs_bangle' => 'Gelang UBS',
- 'ubs_pendant' => 'Liontin UBS',
- 'ubs_women_ring' => 'Cincin Wanita UBS',
- 'ubs_men_ring' => 'Cincin Pria UBS',
- 'ubs_kids' => 'Perhiasan Anak UBS',
- 'diamond_threestone' => 'Diamond Threestone',
- );
- // Gold Bar, Loose Diamond, DMO, Jewelry Accessories, dan Alphabet pendant update
- // email from marcella , Ketentuan Promo Bank ( 11-01-2016 11:23 )
- // $ccExcept = array(
- // 'gold_antam',
- // 'gold_pamp',
- // 'gold_dowry',
- // 'gold_pendant_alphabet',
- // 'package',
- // 'box',
- // 'cleaning',
- // 'diamond',
- // 'custom_earring',
- // 'custom_pendant',
- // 'custom_ring',
- // 'custom'
- // );
- //- Gold Bar
- //- Loose Diamond
- //- DMO
- //- Pendant Alphabet
- //- promo sept
- $now = date('Y-m-d');
- $cart_count = 0;
- // $productGarage = $this->container->getParameter('orori.garage.product');
- // $garage_start = $this->container->getParameter('orori.garage.start');
- // $garage_end = $this->container->getParameter('orori.garage.end');
- $bank_start = $this->container->getParameter('orori.bank.start');
- $bank_end = $this->container->getParameter('orori.bank.end');
- $promo_bank_type = [
- 'diamondjewelry',
- 'mensring',
- 'engagement'
- ];
- $cookieFlashsale = ($request->cookies->get('flash-sale')) ? $request->cookies->get('flash-sale') : 0;
- $voucher_gold = 0;
- $voucher_free = 0;
- $hide_voucher = 0;
- $hide_cicilan = 0;
- $hide_goldpoint = 0;
- $freeshipping = 0;
- $cc = 0;
- $box = 0;
- $point = ($customer) ? $customer->point : 0;
- $discount = 0;
- $subtotal = 0;
- $goldbar = 0;
- $sameday = 0;
- $issameday = 0;
- $notsameday = 0;
- $isgoldbar = 0;
- $isdiamond = 0;
- $isspecial = 0;
- $isnoinstallment= 0;
- $isinstallment3 = 0;
- $isinstallment6 = 0;
- $isGroupbuy = false;
- $cartid = array();
- $promo = array();
- $container = array();
- // promo variable exist
- $promo_bank = 0;
- $promo_group_buy = 0;
- $isClearencePromo = false;
- $isSatujutavoucherPromo = false;
- foreach ($shoppingCarts->shoppingcart as $key => $shoppingCart) {
- ++$cart_count;
- // surcharge checking
- if ($shoppingCart->product->category) {
- if (in_array($shoppingCart->product->category, $applyProductCategoryPrefix) || in_array($shoppingCart->product->sub_category, $applyProductCategoryPrefix) || $shoppingCart->product->type == 'customring') {
- $apply = true;
- }
- }
- // special promo checking
- if($shoppingCart->product->is_special_promo){
- ++$isspecial;
- }
- // allowed installment checking
- if($shoppingCart->product->is_allowed_installment_3){
- ++$isinstallment3;
- }
- if($shoppingCart->product->is_allowed_installment_6){
- ++$isinstallment6;
- }
- // no installment checking
- if(!$shoppingCart->product->is_allowed_installment_3 && !$shoppingCart->product->is_allowed_installment_6){
- ++$isnoinstallment;
- }
- // // cashback checking
- // if(!in_array($shoppingCart->product->category, $ccExcept) && $shoppingCart->product->final_price >=5000000){
- // ++$iscashback;
- // $promo['cashback'] = 500000;
- // }
- // freeshipping checking
- if (in_array($shoppingCart->product->type, $type_free)) {
- ++$freeshipping;
- }
- // diamond promo check
- if (in_array($shoppingCart->product->code, $this->diamondPromo)) {
- $isDiamondPromo = true;
- }
- // clearence promo check
- if (in_array(strtoupper($shoppingCart->product->code), $this->clearencePromo)) {
- $isClearencePromo = true;
- }
- if (in_array(strtoupper($shoppingCart->product->code), $this->satujutavoucherPromo)) {
- $isSatujutavoucherPromo = true;
- }
- // group buy promo checking
- if($shoppingCart->product->groupbuy_discount_value > 0){
- ++$promo_group_buy;
- }
- // box shipping price exception
- if($shoppingCart->product->type=='box'){
- $total_box = $shoppingCart->count * $shoppingCart->product->final_price;
- $box += ($total_box);
- // box freeshipping
- if($total_box >= 3000000){
- // ++$freeshipping;
- }
- }
- // cleaning shipping price exception
- if($shoppingCart->product->type=='cleaning'){
- $total_cleaning = $shoppingCart->count * $shoppingCart->product->final_price;
- // cleaning freeshipping
- if($total_cleaning >= 3000000){
- // ++$freeshipping;
- }
- }
- // payment except
- if (in_array($shoppingCart->product->category, $bca_cicilan_except)) {
- $payment_methode['bca_cicilan'] = false;
- }
- if (in_array($shoppingCart->product->category, $cc_except)) {
- $payment_methode['cc'] = false;
- ++$cc;
- }
- if (in_array($shoppingCart->product->category, $bca_klikpay_except)) {
- $payment_methode['klikpay'] = false;
- }
- // enable installment for mahar / dowry
- if($shoppingCart->product->category == 'gold_dowry'){
- $payment_methode['cc'] = true;
- $payment_methode['bca_cicilan'] = true;
- $cc=0;
- }
- // goldbar counter
- if ($shoppingCart->product->category == 'gold_antam' || $shoppingCart->product->category == 'gold_dowry' || $shoppingCart->product->category == 'gold_pamp') {
- ++$goldbar;
- if($shoppingCart->product->category == 'gold_antam') {
- ++$isgoldbar;
- if ($shoppingCart->product->code == 'antam-100gr-new' || $shoppingCart->product->code == 'antam-50gr-new') {
- ++$sameday;
- } else {
- ++$notsameday;
- }
- }
- }
- // diamond counter
- if ($shoppingCart->product->type == 'diamond') {
- ++$isdiamond;
- }
- // voucher gold 500 checking
- if($shoppingCart->product->code == 'VC-FLASH-500-GOLD'){
- ++$voucher_gold;
- $promo['voucher_gold'] = $voucher_gold;
- }
- if($shoppingCart->product->code == 'VC-FLASH-500' || $shoppingCart->product->code == 'VC-FLASH-1000'){
- ++$voucher_free;
- $promo['voucher_free'] = $voucher_free;
- }
- // promo bank 1 april 2016 - 30 juni 2016
- if ($now >= $bank_start && $now <= $bank_end) {
- if (in_array($shoppingCart->product->type, $promo_bank_type) && $shoppingCart->product->is_special_promo == 0) {
- $promo_bank += $shoppingCart->product->final_price;
- $promo['bank'] = $promo_bank;
- }
- }
- // Groupbuy checking
- if ($shoppingCart->product->groupbuy_discount > 0) {
- $isGroupbuy = true;
- }
- // generate title
- if (in_array($shoppingCart->product->category, $titleExcept)) {
- if($shoppingCart->product->category == 'diamond'){
- $exp = explode('\\N', $shoppingCart->product->name);
- $title = $exp[0];
- }else{
- $title = $shoppingCart->product->name;
- }
- }else{
- $explode_code = explode('-', $shoppingCart->product->code);
- if(isset($explode_code[1])){
- $codes = ' ( '. $explode_code[1]. ' )';
- }else{
- $codes = '';
- }
- $title = $titleMapper[$shoppingCart->product->category].$codes;
- }
- $subtotal += $shoppingCart->product->final_price * $shoppingCart->count;
- $discount += $shoppingCart->product->total_discount * $shoppingCart->count;
- $container[$key] = array(
- 'id' => $shoppingCart->id,
- 'title' => $title,
- 'image' => $this->getImageSize($shoppingCart->product->main_image,'s'),
- 'quantity' => $shoppingCart->count,
- 'price' => $shoppingCart->product->final_price,
- 'category' => $shoppingCart->product->category
- );
- $cartid[$key] = $shoppingCart->id;
- }
- $total = array(
- 'count' => $cart_count,
- 'sub_total' => $subtotal,
- 'discount' => $discount,
- 'shipping_box' => $box
- );
- // if($subtotal < 20000000) {
- // $shipping = array(
- // array('id' => 11, 'text' => 'RPX Economy Package ( ECP ) (no extra insurance)'),
- // array('id' => 12, 'text' => 'RPX Next Day Package ( NDP ) (no extra insurance)')
- // );
- // }else{
- // $shipping = array(
- // array('id' => 16, 'text' => 'RPX Economy Package ( ECP ) (extra insurance)'),
- // array('id' => 17, 'text' => 'RPX Next Day Package ( NDP ) (extra insurance)')
- // );
- // }
- // if($goldbar == 0) {
- // $shipping_methode = array_merge($shipping, $shipping_methode);
- // }else{
- // $shipping_methode = $shipping;
- // }
- // sameday service
- if($customer && $sameday == $cart_count && strtoupper($customer->shipping_province)=='DKI JAKARTA'){
- // if(checkoutProcess.goldbarnew > 0 && provinsi.toUpperCase()=='DKI JAKARTA' && checkoutProcess.notsameDay == 0){
- $now = date('Y-m-d',strtotime($shoppingCarts->timestamp->date));
- $night = strtotime($now . ' 00:00:00');
- $day = strtotime($now . ' 11:00:00');
- $today = strtotime($shoppingCarts->timestamp->date);
- // make sure time for sameday
- if($today > $night && $today < $day){
- // $same_shipping = array(
- // array('id' => 21, 'text' => 'SAME DAY SHIPPING ( Dikirim hari ini )')
- // );
- $issameday = 1;
- // $shipping_methode = array_merge($same_shipping, $shipping_methode);
- }
- }
- // freeshipping except
- // if($freeshipping > 0 && $subtotal < 3000000){
- // if($voucher_free > 0 && $subtotal >= 3000000 && $cookieFlashsale == 0){
- // $freeshipping = 1;
- // }else {
- // $freeshipping = 0;
- // }
- // }else{
- // if($subtotal < 3000000) {
- // $freeshipping = 0;
- // }
- // }
- if($voucher_free == $cart_count) {
- $freeshipping = 1;
- }
- // if($customer && strtoupper($customer->shipping_province)=='DKI JAKARTA' && $subtotal >= 2500000 && $cookieFlashsale == 0){
- // $kurir = array(
- // array('id' => 0, 'text' => 'Kurir (Khusus Jakarta)')
- // );
- // $shipping_methode = array_merge($kurir, $shipping_methode);
- // }
- //
- // if($customer && strtoupper($customer->shipping_province)=='DKI JAKARTA' && $subtotal <= 1000000){
- // $popbox = array(
- // array('id' => 31, 'text' => 'Pop Box (Khusus Jakarta)')
- // );
- // $shipping_methode = array_merge($popbox, $shipping_methode);
- // }
- if(($freeshipping > 0 && $goldbar==0 && $subtotal >= 3000000 && $cookieFlashsale == 0) || ( $freeshipping > 0 && $voucher_free > 0 )){
- // if(($isgoldbar==0 && $subtotal >= 3000000 && $cookieFlashsale == 0) || ( $voucher_free > 0 )){
- $freeshipping = 1;
- }else{
- $freeshipping = 0;
- }
- // no freeshipping for box & cleaning
- // if($total_box > 0 || $total_cleaning > 0){
- // $freeshipping = 0;
- // }
- if($subtotal < 500000){
- $payment_methode['bca_cicilan'] = false;
- }
- if($cookieFlashsale) {
- $payment_methode = [
- 'transfer' => true,
- 'cc' => true,
- 'bca_cicilan' => false,
- 'cimb' => true,
- 'klikbca' => true,
- 'klikpay' => true,
- 'mandiriclickpay' => true,
- 'mandirisms' => false,
- 'virtual' => true,
- 'edc' => true
- ];
- $apply = true;
- }
- if($cc > 0) {
- $payment_methode['cc'] = false;
- }
- $now = date('Y-m-d');
- $flash_start = $this->container->getParameter('orori.flashsale.start');
- $flash_end = $this->container->getParameter('orori.flashsale.end');
- $cookieFlashsale = $request->cookies->get('flash-sale');
- // promo flashsale 27 nov 2015 - 29 nov 2015
- // flashsale check customer
- $error = '';
- if ($now >= $flash_start && $now <= $flash_end && $cookieFlashsale) {
- if($customer) {
- $cek = $this->checkFlashSale($request, $customer->id);
- if(isset($cek->error)){
- $error = $cek->error;
- }
- }
- }
- // overide installment
- if($isnoinstallment > 0){
- $isinstallment3 = 0;
- $isinstallment6 = 0;
- $payment_methode['bca_cicilan'] = false;
- }else{
- if($isinstallment3 > $isinstallment6) {
- $isinstallment6 = 0;
- }
- }
- // echo '$isnoinstallment : '.$isnoinstallment.'<br>';
- // echo '$isinstallment3 : '.$isinstallment3.'<br>';
- // echo '$isinstallment6 : '.$isinstallment6.'<br>';
- // echo '$cart_count : '.$cart_count.'<br>';
- if($isspecial>0){
- // $iscashback = 0;
- $promo = array();
- }
- if ($isDiamondPromo) {
- $payment_methode = [
- 'transfer' => true,
- 'cc' => false,
- 'bca_cicilan' => false,
- 'cimb' => false,
- 'klikbca' => true,
- 'klikpay' => false,
- 'mandiriclickpay' => false,
- 'mandirisms' => false,
- 'virtual' => false,
- 'edc' => false
- ];
- }
- // Hide for a while because still error
- $payment_methode['bca_cicilan'] = false;
- // For special product can use voucher promo
- $startSpecialVoucher = \DateTime::createFromFormat('Y-m-d H:i:s', '2016-05-17 00:00:00');
- $endSpecialVoucher = \DateTime::createFromFormat('Y-m-d H:i:s', '2016-05-20 23:59:59');
- $nowVoucher = new \DateTime();
- if ($startSpecialVoucher <= $nowVoucher && $nowVoucher <= $endSpecialVoucher) {
- $hide_voucher = 0;
- $eternity = ['WR-1097','WR-1098','WR-1099','WR-1100','WR-1101',
- 'WR-1102','WR-1103','WR-1104','WR-1105','WR-1106',];
- foreach ($shoppingCarts->shoppingcart as $key => $cart) {
- if (in_array($cart->product->code , $eternity)) {
- $hide_voucher = 1;
- break;
- } else if (!in_array(strtolower($cart->product->category), ['solitaire_ring','solitaire_earring','solitaire_pendant','diamond_women_ring',
- 'diamond_men_ring','diamond_pendant','diamond_earring','diamond_religious']) && $cart->product->type !== 'ring') {
- $hide_voucher = 1;
- break;
- }
- }
- }
- // Hide VA on production
- $env = $this->get('kernel')->getEnvironment();
- if ($env == 'prod')
- $payment_methode['virtual'] = false;
- // freeshipping all item
- $startFreeshipping = \DateTime::createFromFormat('Y-m-d H:i:s', '2016-06-08 00:00:00');
- $endFreeshipping = \DateTime::createFromFormat('Y-m-d H:i:s', '2016-06-16 23:59:59');
- $nowVoucher = new \DateTime();
- if ($startFreeshipping <= $nowVoucher && $nowVoucher <= $endFreeshipping) {
- if($customer && strtoupper($customer->shipping_province)!='DKI JAKARTA') {
- if($isgoldbar + $isdiamond == $cart_count){
- $freeshipping = 0;
- }else{
- $freeshipping = 1;
- }
- }else{
- $freeshipping = 1;
- $isgoldbar = 0;
- }
- }
- $now = date('Y-m-d');
- $error = '';
- $flash_start = $this->container->getParameter('orori.flashsale.start');
- $flash_end = $this->container->getParameter('orori.flashsale.end');
- $access_token = $request->cookies->get('access_token');
- $cookieFlashsale = $request->cookies->get('flash-sale');
- // promo flashsale 27 nov 2015 - 29 nov 2015
- if ($now >= $flash_start && $now <= $flash_end && $cookieFlashsale) {
- if($access_token && $customer) {
- $freeshipping = 0;
- }
- }
- if($promo_group_buy > 0) {
- if(isset($customer) && isset($customer->email) && ($customer->email === '[email protected]' || $customer->email === '[email protected]')) {
- $payment_methode = [
- 'transfer' => true,
- 'cc' => true,
- 'bca_cicilan' => false,
- 'cimb' => true,
- 'klikbca' => true,
- 'klikpay' => true,
- 'mandiriclickpay' => true,
- 'mandirisms' => false,
- 'virtual' => true,
- 'edc' => true
- ];
- }else {
- $payment_methode = [
- 'transfer' => true,
- 'cc' => false,
- 'bca_cicilan' => false,
- 'cimb' => false,
- 'klikbca' => false,
- 'klikpay' => false,
- 'mandiriclickpay' => false,
- 'mandirisms' => false,
- 'virtual' => false,
- 'edc' => false
- ];
- }
- $hide_voucher = 1;
- $hide_cicilan = 1;
- $hide_goldpoint = 1;
- }
- if($isClearencePromo) {
- $payment_methode = [
- 'transfer' => true,
- 'cc' => false,
- 'bca_cicilan' => false,
- 'cimb' => false,
- 'klikbca' => false,
- 'klikpay' => false,
- 'mandiriclickpay' => false,
- 'mandirisms'=> false,
- 'virtual' => false,
- 'edc' => false
- ];
- }
- if($isSatujutavoucherPromo) {
- $hide_voucher = 1;
- }
- if($isspecial > 0){
- $hide_voucher = 1;
- }
- $cc_installment = array();
- if ($apply){
- if ($hide_cicilan > 0) {
- $cc_installment['full'] = 'Full Payment';
- }else{
- $cc_installment['full'] = 'Full Payment';
- if ($isinstallment3 && $isinstallment3 > 0 && $subtotal >= 500000) {
- $cc_installment['anz-3'] = 'ANZ 3 bulan(5 %)';
- $cc_installment['cimb-3'] = 'CIMB 3 bulan(6 %)';
- $cc_installment['sc-3'] = 'Standard Chartered 3 bulan(4.5 %)';
- }
- }
- }else {
- if ($hide_cicilan > 0) {
- $cc_installment['full'] = 'Full Payment';
- } else {
- $cc_installment['full'] = 'Full Payment';
- if ($isinstallment3 && $isinstallment3 > 0 && $subtotal >= 500000) {
- $cc_installment['anz-3'] = 'ANZ 3 bulan(0 %)';
- $cc_installment['cimb-3'] = 'CIMB 3 bulan(0 %)';
- $cc_installment['sc-3'] = 'Standard Chartered 3 bulan(0 %)';
- $cc_installment['mandiri-3'] = 'Mandiri 3 bulan(0 %)';
- $cc_installment['bca-3'] = 'BCA 3 bulan(0 %)';
- }
- if ($isinstallment6 && $isinstallment6 > 0 && $subtotal >= 500000) {
- $cc_installment['hsbc-6'] = 'HSBC 6 bulan(0 %)';
- $cc_installment['anz-6'] = 'ANZ 6 bulan(0 %)';
- $cc_installment['cimb-6'] = 'CIMB 6 bulan(0 %)';
- $cc_installment['sc-6'] = 'Standard Chartered 6 bulan(0 %)';
- $cc_installment['mandiri-6'] = 'Mandiri 6 bulan(0 %)';
- }
- }
- }
- // echo "".$isgoldbar."<br>";
- // echo "".$isdiamond."<br>";
- // echo "".$cart_count."<br>";
- // echo "".$freeshipping."<br>";
- // echo "".$customer->shipping_province."<br>";
- // die;
- return [
- 'apply' => $apply,
- 'total' => $total,
- 'freeshipping' => $freeshipping,
- 'payment_methode' => $payment_methode,
- // 'shipping_methode' => $shipping_methode,
- 'promo' => $promo,
- 'cart' => $container,
- 'cartid' => $cartid,
- 'customer' => $customer,
- 'sameday' => $issameday,
- 'point' => $point,
- 'error' => $error,
- 'is_diamond' => $isdiamond,
- 'is_goldbar' => $isgoldbar,
- 'is_special' => $isspecial,
- 'installment' => $cc_installment,
- 'flashsale' => ($cookieFlashsale) ? $cookieFlashsale : 0,
- 'hide_voucher' => $hide_voucher,
- 'hide_cicilan' => $hide_cicilan,
- 'hide_goldpoint' => $hide_goldpoint
- ];
- }
- return [];
- }
- public function getImageSize($src, $size)
- {
- $img = explode('/', $src);
- if ($img[0]) {
- $imgname = end($img);
- $split = explode('.', $imgname);
- $path = explode($imgname, $src);
- $result = $path[0].$split[0].'_'.$size.'.'.$split[1];
- } else {
- $result = '';
- }
- return $result;
- }
- public function generateURLs($category, $code, $meta, $id=0){
- $mapper = array(
- 'simply' => 'wedding',
- 'beauty' => 'wedding',
- 'design' => 'wedding',
- 'palladium' => 'wedding',
- 'silver' => 'wedding',
- 'bestvalue' => 'wedding',
- 'best_design' => 'wedding',
- 'exclusive' => 'wedding',
- 'solitaire_ring' => 'solitaire',
- 'solitaire_earring' => 'solitaire',
- 'solitaire_pendant' => 'solitaire',
- 'diamond_women_ring' => 'jewelry',
- 'diamond_men_ring' => 'jewelry',
- 'diamond_earring' => 'jewelry',
- 'diamond_bracelet' => 'jewelry',
- 'diamond_pendant' => 'jewelry',
- 'diamond_religious' => 'jewelry',
- 'diamond_religious_moslem' => 'jewelry',
- 'gold_ring' => 'jewelry',
- 'gold_pendant' => 'jewelry',
- 'gold_bracelet' => 'jewelry',
- 'gold_earring' => 'jewelry',
- 'gold_necklace' => 'jewelry',
- 'gold_pendant_alphabet' => 'jewelry',
- 'alphabet_frame' => 'jewelry',
- 'gold_ankle_bracelet' => 'jewelry',
- 'box' => 'jewelry',
- 'cleaning' => 'jewelry',
- 'others' => 'jewelry',
- 'custom' => 'jewelry',
- 'custom_customer' => 'jewelry',
- 'custom_for_customer' => 'jewelry',
- 'customer_for_customer' => 'jewelry',
- 'custom_earring' => 'jewelry',
- 'custom_pendant' => 'jewelry',
- 'custom_ring' => 'jewelry',
- 'custom_voucher' => 'jewelry',
- 'package' => 'package',
- 'diamond' => 'diamond',
- 'bridal' => 'bridal-detail',
- 'rolletto' => 'rolletto-detail',
- 'signa' => 'signa-detail',
- 'gold_dowry' => 'goldbar',
- 'gold_antam' => 'antam-goldbar',
- 'gold_pamp' => 'pamp-goldbar',
- 'ubs_necklace' => 'jewelry',
- 'ubs_earring' => 'jewelry',
- 'ubs_bracelet' => 'jewelry',
- 'ubs_bangle' => 'jewelry',
- 'ubs_pendant' => 'jewelry',
- 'ubs_women_ring' => 'jewelry',
- 'ubs_men_ring' => 'jewelry',
- 'diamond_threestone' => 'engagement'
- );
- $paramMeta = http_build_query($meta);
- if ($category == 'diamond') {
- $url = '/' . $mapper[$category] . '/product/' . $category . '/' . $id;
- } else {
- if($category == 'gold_pendant_alphabet'){
- $code_split = explode('-', $code);
- if(array_pop($code_split) == 'Y') $code = implode('-', $code_split).'-W';
- }
- $url = '/' . $mapper[$category] . '/product/' . $category . '/' . $code . '?' . $paramMeta;
- }
- if ($category == 'bridal' || $category == 'rolletto' || $category == 'signa') {
- $url = '/' . $mapper[$category] . '?' . $paramMeta;
- }
- if ($category == 'gold_antam') {
- $url = '/' . $mapper[$category] . '?' . $paramMeta;
- }
- if ($category == 'gold_pamp') {
- $url = '/' . $mapper[$category];
- }
- return $url;
- }
- public function getUserInfo(Request $request)
- {
- $me = null;
- if ($request->cookies->has('access_token')) {
- // get '/me'
- $request->request->set('method', 'GET');
- $request->request->set('url', '/me');
- $result = $this->apiAction($request);
- if ($result->getStatusCode() == 200) {
- $response = json_decode($result->getContent());
- $me = $response->customer;
- } else {
- $me = $result->getStatusCode();
- $request->cookies->remove('access_token');
- }
- }
- return $me;
- }
- public function calculateGoldPoint(Request $request, $type, $value)
- {
- $me = 0;
- $request->request->set('method', 'GET');
- $request->request->set('url', '/gold-point/calculate');
- $request->request->set('param', [
- 'type' => $type,
- 'value' => $value,
- ]);
- $result = $this->apiAction($request);
- if ($result->getStatusCode() == 200) {
- $response = json_decode($result->getContent());
- $me = $response;
- } else {
- $request->cookies->remove('access_token');
- }
- return $me;
- }
- public function checkFlashSale($request, $id)
- {
- $me = null;
- // get
- $request->request->set('method', 'GET');
- $request->request->set('url', '/promotion/flash-sales/check-customer/' .$id);
- $result = $this->apiAction($request);
- if ($result->getStatusCode() == 200) {
- $response = json_decode($result->getContent());
- $me = $response;
- }else{
- $response = json_decode($result->getContent());
- $me = $response;
- }
- return $me;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment