Esempio n. 1
0
 static function getWishObjsOfMember($controller, $member, $key_pl)
 {
     $ids = Helper_String::commaStrToArr($member->getWishProductIdStr());
     $objs = $controller->_indicesToObjects($ids, $key_pl, 'getActiveItemById');
     return $objs;
 }
Esempio n. 2
0
 static function getPointsEarned($controller, $cart)
 {
     $pointRule = $controller->getPointRule();
     if ($pointRule) {
         if (is_callable($pointRule)) {
             $points = $pointRule($controller, $cart);
             return $points;
         }
         $isEligible = TRUE;
         if ($isEligibleFunc = Helper_Structure::getArrayValue($pointRule, 'is_earn_eligible')) {
             $isEligible = $isEligibleFunc($controller, $cart);
         }
         if ($eligibleMemberTypes = Helper_Structure::getArrayValue($pointRule, 'eligible_member_types')) {
             $isEligible = self::isMemberEligible($controller, Helper_String::commaStrToArr($eligibleMemberTypes));
         }
         if ($isEligible) {
             $spent = Helper_Cart::getAmountSpent($cart);
             if (!empty($pointRule['with_exclude_sale_items'])) {
                 $saleItems = array_filter($cart['items'], function ($x) {
                     return !empty($x['is_sale']);
                 });
                 $saleTotal = self::getItemTotal($saleItems);
                 $spent = max($spent - $saleTotal, 0);
             }
             return self::getPointsEarnedByAmountSpent($controller, $spent);
         }
     }
     return 0;
 }
Esempio n. 3
0
 static function sircloRenderPaymentNotifForm($params)
 {
     $_order_id = !empty($params['order_id']) ? $params['order_id'] : '';
     $_order_email = !empty($params['order_email']) ? $params['order_email'] : '';
     $_btn_class = !empty($params['btn_class']) ? $params['btn_class'] : 'btn-flat';
     $_lang = !empty($params['lang']) ? $params['lang'] : "en";
     $_label_order_id = $_lang == "id" ? "Order ID" : "Order ID";
     $_label_transaction_date = $_lang == "id" ? "Tanggal Transaksi" : "Transaction Date";
     $_label_transaction_ref = $_lang == "id" ? "Nama Pengirim" : "Sender Name";
     $_label_amount_transferred = $_lang == "id" ? "Jumlah Ditransfer" : "Amount Transferred";
     $_label_email = $_lang == "id" ? "E-mail" : "Email";
     $_label_confirm_payment = $_lang == "id" ? "Konfirmasi Pembayaran" : "Confirm Payment";
     $_label_bank_to = $_lang == "id" ? "Pembayaran ke Bank" : "Payment to";
     $_label_receipt_file = $_lang == "id" ? "Bukti Transfer (opsional)" : "Receipt File (optional)";
     if (!empty($params['bank_accounts'])) {
         $_bank_accounts = array_map(function ($acc) {
             return $acc['title'];
         }, $params['bank_accounts']);
     } else {
         if (!empty($params['configs']['theme_bank_accounts'])) {
             $_bank_accounts = Helper_String::commaStrToArr($params['configs']['theme_bank_accounts']);
         }
     }
     if (!empty($_bank_accounts)) {
         $_bank_accounts_options = array(array('title' => '-- Select Bank Account --', 'value' => ''));
         foreach ($_bank_accounts as $_ba) {
             $_bank_accounts_options[] = array('title' => trim($_ba), 'value' => trim($_ba));
         }
         $_bank_account_form = array('name' => 'bank_to', 'type' => 'dropdown', 'value' => '', 'label' => $_label_bank_to, 'attribute' => 'required', 'options' => $_bank_accounts_options);
         $params['fields'] = array(array('name' => 'order_id', 'type' => 'text', 'value' => $_order_id, 'label' => $_label_order_id, 'attribute' => 'required'), array('name' => 'transaction_date', 'type' => 'text', 'value' => '', 'label' => $_label_transaction_date, 'attribute' => 'required'), array('name' => 'transaction_reference', 'type' => 'text', 'value' => '', 'label' => $_label_transaction_ref, 'attribute' => 'required'), array('name' => 'amount_transfered', 'type' => 'text', 'value' => '', 'label' => $_label_amount_transferred, 'attribute' => 'required'), $_bank_account_form, array('name' => 'email', 'type' => 'email', 'value' => $_order_email, 'label' => $_label_email, 'attribute' => 'required'), array('name' => 'attachment', 'type' => 'file', 'label' => $_label_receipt_file), array('name' => '', 'type' => 'submit', 'value' => $_label_confirm_payment, 'label' => '', 'attribute' => 'class="' . $_btn_class . '"'));
     } else {
         $params['fields'] = array(array('name' => 'order_id', 'type' => 'text', 'value' => $_order_id, 'label' => $_label_order_id, 'attribute' => 'required'), array('name' => 'transaction_date', 'type' => 'text', 'value' => '', 'label' => $_label_transaction_date, 'attribute' => 'required'), array('name' => 'transaction_reference', 'type' => 'text', 'value' => '', 'label' => $_label_transaction_ref, 'attribute' => 'required'), array('name' => 'amount_transfered', 'type' => 'text', 'value' => '', 'label' => $_label_amount_transferred, 'attribute' => 'required'), array('name' => 'email', 'type' => 'email', 'value' => $_order_email, 'label' => $_label_email, 'attribute' => 'required'), array('name' => 'attachment', 'type' => 'file', 'label' => $_label_receipt_file), array('name' => '', 'type' => 'submit', 'value' => $_label_confirm_payment, 'label' => '', 'attribute' => 'class="' . $_btn_class . '"'));
     }
     $_html = Helper_Renderer::renderForm($params);
     return $_html;
 }
Esempio n. 4
0
 static function _setObjProp($obj, $val, $lang, $method)
 {
     $method_name = '';
     $newVal = $val;
     if (is_string($method)) {
         $method_name = 'set' . $method;
         if (strpos($method, 'Array') === 0 && is_string($val)) {
             $newVal = Helper_String::commaStrToArr($val);
         }
     } else {
         if (is_array($method)) {
             if (!empty($method['attr'])) {
                 $obj->setAttr($method['attr'], $val);
                 return;
             } else {
                 if (!empty($method['extra_attribute'])) {
                     $extra = $obj->getExtraAttribute();
                     if ($extra) {
                         $setMethod = 'set' . $method['extra_attribute'];
                         $extra->{$setMethod}($val);
                     }
                     return;
                 } else {
                     $method_name = 'set' . $method['method'];
                     $newVal = $method['filter']($val);
                 }
             }
         } else {
             if (is_callable($method)) {
                 $method($obj, $val, $lang);
                 return;
             }
         }
     }
     $obj->{$method_name}($newVal, $lang);
 }