Esempio n. 1
0
 public function genreYML()
 {
     header('content-type: text/xml');
     $ci = ShopCore::$ci;
     $pictureBaseUrl = base_url() . "uploads/shop/products/main/";
     /* @var $p SProducts */
     foreach ($this->getProducts() as $p) {
         /* @var $v SProductVariants */
         foreach ($p->getProductVariants() as $v) {
             if (!$v->getPrice()) {
                 continue;
             }
             $unique_id = $p->getId() . $v->getId();
             $param = ShopCore::app()->SPropertiesRenderer->renderPropertiesArray($p);
             $this->offers[$unique_id]['url'] = ShopCore::$ci->config->item('base_url') . '/shop/product/' . $p->url;
             $this->offers[$unique_id]['price'] = $v->getPrice();
             $this->offers[$unique_id]['currencyId'] = $this->currencyCode;
             $this->offers[$unique_id]['categoryId'] = $p->getCategoryId();
             $this->offers[$unique_id]['picture'] = $pictureBaseUrl . $v->getMainImage();
             $images = null;
             $images = $p->getSProductImagess();
             if (count($images) > 0) {
                 foreach ($images as $key => $image) {
                     $this->offers[$unique_id]['picture' . $key] = productImageUrl('products/additional/' . $image->getImageName());
                 }
             }
             $this->offers[$unique_id]['name'] = $this->forName($p->getName(), $v->getName());
             $this->offers[$unique_id]['vendor'] = $p->getBrand() ? htmlspecialchars($p->getBrand()->getName()) : ' ';
             $this->offers[$unique_id]['vendorCode'] = $v->getNumber() ? htmlspecialchars($v->getNumber()) : ' ';
             $this->offers[$unique_id]['description'] = htmlspecialchars($p->getFullDescription());
             $this->db->select('value');
             $this->db->where('id', 1);
             $query = $this->db->get('mod_yandex_market_adalt');
             $adalt = $query->row_array();
             if ($adalt['value'] == 1) {
                 $this->offers[$unique_id]['adult'] = 'true';
             }
             $this->offers[$unique_id]['param'] = $param;
         }
     }
     echo '<?xml version="1.0" encoding="utf-8"?>
                         <!DOCTYPE yml_catalog SYSTEM "shops.dtd">
                         <yml_catalog date="' . date('Y-m-d H:i') . '">
                         <shop>
                         <name>' . $this->settings['site_short_title'] . '</name>
                         <company>' . $this->settings['site_title'] . '</company>
                         <url>' . $ci->config->item('base_url') . '</url>
                         <platform>ImageCMS</platform>
                         <version>' . IMAGECMS_NUMBER . '</version>
                         <email>' . siteinfo('siteinfo_adminemail') . '</email>';
     echo "\n\n";
     echo '<currencies>
                         <currency id="' . $this->currencyCode . '" rate="1"/>
                 </currencies>' . "\n\n";
     echo $this->renderCategories();
     echo $this->renderOffers();
     echo "</shop>\n";
     echo "</yml_catalog>";
 }
Esempio n. 2
0
 /**
  *
  * @param SProducts $product
  * @return array
  */
 private function getAdditionalImages(SProducts $product)
 {
     $offers = array();
     $images = $iterator = $offers = null;
     $images = $product->getSProductImagess();
     if (count($images) > 0 && ++$iterator < 9) {
         foreach ($images as $key => $image) {
             $offers[] = productImageUrl('products/additional/' . $image->getImageName());
         }
     }
     return $offers;
 }
initDownloadScripts(['cusel-min-2.5', 'cloud-zoom.1.0.3.min', 'product'], 'initPhotoTrEv', 'initPhotoTrEv');
</script>
<div style="display: none;">
    <img src="<?php 
echo $model->firstVariant->getLargePhoto();
?>
" alt="<?php 
echo ShopCore::encode($model->getName());
?>
" class="vImgPr"/>
    <?php 
if (is_true_array($productImages)) {
    foreach ($productImages as $key => $image) {
        ?>
    <img src="<?php 
        echo productImageUrl('products/additional/' . $image->getImageName());
        ?>
" alt="<?php 
        echo ShopCore::encode($model->getName());
        ?>
 - <?php 
        echo ++$key;
        ?>
"/>
    <?php 
    }
}
?>
</div><?php 
$mabilis_ttl = 1444767728;
$mabilis_last_modified = 1440056636;
Esempio n. 4
0
 public function processPayment()
 {
     $PSystem_ID = $_GET['PSystem_ID'];
     $order_key = $this->order->getKey();
     $order_id = $this->order->getId();
     $paymentMethod = $this->paymentMethod->getId();
     $CurrencyId = $this->paymentMethod->getCurrencyId();
     $data = $this->loadSettings();
     $MerchantGuid = $data['MerchantGuid'];
     $MerchantSecretKey = $data['MerchantSecretKey'];
     $currencies = SCurrenciesQuery::create()->find();
     foreach ($currencies as $c) {
         $this->currencies[$c->getId()] = $c;
     }
     $currency = $this->currencies[$CurrencyId];
     $currency_Code = $currency->code;
     $currency_Rate = $currency->getRate();
     $TotalPrice = 0;
     $PSystem_ID = isset($PSystem_ID) ? $PSystem_ID : $this->getPSI();
     $send_data['SelectedPaySystemId'] = $PSystem_ID;
     $db = \CI::$APP->db;
     $db->where('shop_orders_products.order_id', $order_id);
     $db->join('shop_products', 'shop_orders_products.product_id=shop_products.id', 'left outer');
     $Products = $db->get('shop_orders_products')->result_array();
     foreach ($Products as $orderProduct) {
         $product_item = array();
         $product_item['ImageUrl'] = productImageUrl($orderProduct['mainModImage']);
         $product_item['ProductItemsNum'] = number_format($orderProduct['quantity'], 2, '.', '');
         $product_item['ProductName'] = $orderProduct['product_name'];
         $product_item['ProductPrice'] = number_format($orderProduct['price'] * $currency_Rate, 2, '.', '');
         $product_item['ProductId'] = $orderProduct['product_id'];
         $send_data['Products'][] = $product_item;
         $TotalPrice += $product_item['ProductPrice'] * $product_item['ProductItemsNum'];
         $product_count += $product_item['ProductItemsNum'];
     }
     $TotalPrice = number_format($TotalPrice, 2, '.', '');
     $product_count = number_format($product_count, 2, '.', '');
     //Инициализация
     if ($PSystem_ID && !$_GET['back']) {
         if ($user_id = $this->order->getUserId()) {
             $profile = SUserProfileQuery::create()->filterById($user_id)->findone();
         } else {
             $user_id = 1;
         }
         $send_data['PaymentDetails']['MerchantInternalPaymentId'] = $order_id;
         $send_data['PaymentDetails']['MerchantInternalUserId'] = $user_id;
         $send_data['PaymentDetails']['EMail'] = $this->order->user_email;
         $send_data['PaymentDetails']['PhoneNumber'] = $profile->getPhone();
         $send_data['PaymentDetails']['Description'] = "Оплата заказа {$order_id}";
         $send_data['PaymentDetails']['DeliveryType'] = $this->order->getSDeliveryMethods()->getName();
         $send_data['PaymentDetails']['CustomMerchantInfo'] = '';
         $send_data['PaymentDetails']['StatusUrl'] = shop_url("cart/view/{$order_key}?back=1&pm={$paymentMethod}");
         $send_data['PaymentDetails']['ReturnUrl'] = shop_url("cart/view/{$order_key}?back=1");
         $send_data['PaymentDetails']['BuyerLastname'] = '';
         $send_data['PaymentDetails']['BuyerFirstname'] = $this->order->user_full_name;
         $send_data['PaymentDetails']['BuyerPatronymic'] = '';
         $send_data['PaymentDetails']['BuyerStreet'] = $profile->getAddress();
         $send_data['PaymentDetails']['BuyerCity'] = '';
         $send_data['PaymentDetails']['BuyerZone'] = '';
         $send_data['PaymentDetails']['BuyerZip'] = '';
         $send_data['PaymentDetails']['BuyerCountry'] = '';
         $send_data['PaymentDetails']['DeliveryLastname'] = '';
         $send_data['PaymentDetails']['DeliveryFirstname'] = $this->order->user_full_name;
         $send_data['PaymentDetails']['DeliveryPatronymic'] = '';
         $send_data['PaymentDetails']['DeliveryStreet'] = $profile->getAddress();
         $send_data['PaymentDetails']['DeliveryCity'] = '';
         $send_data['PaymentDetails']['DeliveryZone'] = '';
         $send_data['PaymentDetails']['DeliveryZip'] = '';
         $send_data['PaymentDetails']['DeliveryCountry'] = '';
         $signature_s = $MerchantGuid . $TotalPrice . $product_count . $send_data['PaymentDetails']['MerchantInternalUserId'] . $send_data['PaymentDetails']['MerchantInternalPaymentId'] . $PSystem_ID . $data['MerchantSecretKey'];
         if (stristr($currency_Code, 'R') === 0) {
             $currency_Code = 'RUB';
         } elseif (stristr($currency_Code, 'UA') === 0) {
             $currency_Code = 'UAH';
         } elseif (stristr($currency_Code, 'US') === 0) {
             $currency_Code = 'USD';
         } elseif (stristr($currency_Code, 'E') === 0) {
             $currency_Code = 'EUR';
         }
         $send_data['Signature'] = md5($signature_s);
         $send_data['MerchantGuid'] = $MerchantGuid;
         $send_data['Currency'] = $currency_Code;
         $res = $this->Treasurer_Request($this->URL_CreatePayment, $send_data);
         $data = json_decode($res, 1);
         $ErrorCode = $data['ErrorCode'];
         $ExternalForm = $data['ExternalForm'];
         if ($ErrorCode) {
             die("ErrorCode={$ErrorCode}");
         }
         $ExternalForm = base64_decode($ExternalForm);
         die($ExternalForm);
     } else {
         //CallBack оплаты
         $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : file_get_contents('php://input');
         $req_data = json_decode($HTTP_RAW_POST_DATA, 1);
         $MerchantInternalPaymentId = abs(intval($req_data['MerchantInternalPaymentId']));
         $Signature = strtoupper($req_data['Signature']);
         $Sum = $req_data['Sum'];
         $ErrorCode = $req_data['ErrorCode'];
         $MerchantInternalUserId = $req_data['MerchantInternalUserId'];
         $CustomMerchantInfo = $req_data['CustomMerchantInfo'];
         if (!$MerchantInternalPaymentId) {
             return false;
         }
         if ($ErrorCode) {
             return false;
         }
         $Sum = number_format($Sum, 2, '.', '');
         //857.00 => 857 WTF!!!
         $signature_true = strtoupper(md5($ErrorCode . $order_id . $MerchantInternalUserId . $Sum . $CustomMerchantInfo . $MerchantSecretKey));
         if ($Signature != $signature_true) {
             return false;
         }
         if ($this->order->getPaid() == true) {
             return ERROR_ORDER_PAID_BEFORE;
         }
         $this->setOrderPaid();
         die("OK{$order_id}");
     }
 }