Example #1
0
 /**
  * show live editor tools 
  */
 protected function showLiveEditorSetting()
 {
     $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/ui/jquery.ui.dialog.min.js');
     $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/ui/jquery.ui.draggable.min.js');
     $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/ui/jquery.ui.droppable.min.js');
     $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/leobootstrapmenu/assets/admin/form.js');
     $this->context->controller->addCss(__PS_BASE_URI__ . 'modules/leobootstrapmenu/assets/admin/liveeditor.css');
     $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/leobootstrapmenu/assets/admin/liveeditor.js');
     $tcss = _PS_ROOT_DIR_ . '/themes/' . $this->context->shop->getTheme() . '/css/modules/leobootstrapmenu/megamenu.css';
     if (file_exists($tcss)) {
         # validate module
         $this->context->controller->addCss(_THEMES_DIR_ . $this->context->shop->getTheme() . '/css/modules/leobootstrapmenu/megamenu.css');
     } else {
         # validate module
         $this->context->controller->addCss(__PS_BASE_URI__ . 'modules/leobootstrapmenu/megamenu.css');
     }
     $liveedit_action = $this->base_config_url . '&liveeditor=1&do=livesave';
     $action_backlink = $this->base_config_url;
     $action_widget = _MODULE_DIR_ . $this->name . '/widget.php';
     $action_addwidget = $this->base_config_url . '&liveeditor=1&do=addwidget';
     $ajxgenmenu = $this->base_config_url . '&liveeditor=1&do=ajxgenmenu';
     $ajxmenuinfo = $this->base_config_url . '&liveeditor=1&do=ajxmenuinfo';
     $id_shop = $this->context->shop->id;
     $shop = Shop::getShop($id_shop);
     if (!empty($shop)) {
         $live_site_url = $shop['uri'];
     } else {
         $live_site_url = __PS_BASE_URI__;
     }
     $model = $this->widget;
     $widgets = $model->getWidgets($id_shop);
     $type_menu = array('carousel', 'categoriestabs', 'manucarousel', 'map', 'producttabs', 'tab', 'accordion', 'specialcarousel');
     foreach ($widgets as $key => $widget) {
         if (in_array($widget['type'], $type_menu)) {
             unset($widgets[$key]);
         }
     }
     ob_start();
     $this_module = $this;
     require_once dirname(__FILE__) . '/liveeditor.php';
     $output = ob_get_contents();
     ob_end_clean();
     # validate module
     unset($liveedit_action);
     unset($action_backlink);
     unset($action_widget);
     unset($action_addwidget);
     unset($ajxgenmenu);
     unset($ajxmenuinfo);
     unset($live_site_url);
     unset($this_module);
     return $output;
 }
Example #2
0
 public function initShopContext()
 {
     if (!$this->context->employee->isLoggedBack()) {
         return;
     }
     // Change shop context ?
     if (Shop::isFeatureActive() && Tools::getValue('setShopContext') !== false) {
         $this->context->cookie->shopContext = Tools::getValue('setShopContext');
         $url = parse_url($_SERVER['REQUEST_URI']);
         $query = isset($url['query']) ? $url['query'] : '';
         parse_str($query, $parse_query);
         unset($parse_query['setShopContext'], $parse_query['conf']);
         $this->redirect_after = $url['path'] . '?' . http_build_query($parse_query, '', '&');
     } elseif (!Shop::isFeatureActive()) {
         $this->context->cookie->shopContext = 's-' . Configuration::get('PS_SHOP_DEFAULT');
     } elseif (Shop::getTotalShops(false, null) < 2) {
         $this->context->cookie->shopContext = 's-' . $this->context->employee->getDefaultShopID();
     }
     $shop_id = '';
     Shop::setContext(Shop::CONTEXT_ALL);
     if ($this->context->cookie->shopContext) {
         $split = explode('-', $this->context->cookie->shopContext);
         if (count($split) == 2) {
             if ($split[0] == 'g') {
                 if ($this->context->employee->hasAuthOnShopGroup($split[1])) {
                     Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
                 } else {
                     $shop_id = $this->context->employee->getDefaultShopID();
                     Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
                 }
             } elseif (Shop::getShop($split[1]) && $this->context->employee->hasAuthOnShop($split[1])) {
                 $shop_id = $split[1];
                 Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
             } else {
                 $shop_id = $this->context->employee->getDefaultShopID();
                 Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
             }
         }
     }
     // Check multishop context and set right context if need
     if (!($this->multishop_context & Shop::getContext())) {
         if (Shop::getContext() == Shop::CONTEXT_SHOP && !($this->multishop_context & Shop::CONTEXT_SHOP)) {
             Shop::setContext(Shop::CONTEXT_GROUP, Shop::getContextShopGroupID());
         }
         if (Shop::getContext() == Shop::CONTEXT_GROUP && !($this->multishop_context & Shop::CONTEXT_GROUP)) {
             Shop::setContext(Shop::CONTEXT_ALL);
         }
     }
     // Replace existing shop if necessary
     if (!$shop_id) {
         $this->context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
     } elseif ($this->context->shop->id != $shop_id) {
         $this->context->shop = new Shop($shop_id);
     }
     if ($this->context->shop->id_theme != $this->context->theme->id) {
         $this->context->theme = new Theme($this->context->shop->id_theme);
     }
     // Replace current default country
     $this->context->country = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT'));
 }
Example #3
0
 public function hookActionObjectUpdateBefore($params)
 {
     // do not sync all updated object by default,
     // only if certain fields are updated
     self::$syncUpdatedObject = false;
     $object = $params['object'];
     // sync only if following fields are changed
     if ($object instanceof Employee) {
         $employee = new Employee();
         $oldObject = $employee->getByEmail($object->email);
         if ($oldObject) {
             if ($object->lastname != $oldObject->lastname || $object->firstname != $oldObject->firstname || $object->email != $oldObject->email || $object->active != $oldObject->active) {
                 self::$syncUpdatedObject = true;
             }
         } else {
             // sync if email change
             self::$syncUpdatedObject = true;
         }
     } elseif ($object instanceof Shop) {
         $oldShop = Shop::getShop($object->id);
         if ($object->name != $oldShop['name'] || $object->active != $oldShop['active']) {
             self::$syncUpdatedObject = true;
         }
     }
 }
Example #4
0
 private function getCategoryOption($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true, $link = false)
 {
     $html = '';
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         $spacer = str_repeat('&nbsp;', 3 * (int) $category->level_depth);
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     if (!in_array($category->id, array(Configuration::get('PS_HOME_CATEGORY'), Configuration::get('PS_ROOT_CATEGORY')))) {
         if ($link) {
             $html .= '<option value="' . $this->context->link->getCategoryLink($category->id) . '">' . (isset($spacer) ? $spacer : '') . str_repeat('&nbsp;', 3 * (int) $category->level_depth) . $category->name . '</option>';
         } else {
             $html .= '<option value="CAT' . (int) $category->id . '">' . str_repeat('&nbsp;', 3 * (int) $category->level_depth) . $category->name . '</option>';
         }
     } elseif ($category->id != Configuration::get('PS_ROOT_CATEGORY')) {
         $html .= '<optgroup label="' . str_repeat('&nbsp;', 3 * (int) $category->level_depth) . $category->name . '">';
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $html .= $this->getCategoryOption((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop'], $recursive, $link);
         }
     }
     return $html;
 }
    die(Tools::displayError());
}
$shop_id = '';
Shop::setContext(Shop::CONTEXT_ALL);
if (Context::getContext()->cookie->shopContext) {
    $split = explode('-', Context::getContext()->cookie->shopContext);
    if (count($split) == 2) {
        if ($split[0] == 'g') {
            if (Context::getContext()->employee->hasAuthOnShopGroup($split[1])) {
                Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
            } else {
                $shop_id = Context::getContext()->employee->getDefaultShopID();
                Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
            }
        } else {
            if (Shop::getShop($split[1]) && Context::getContext()->employee->hasAuthOnShop($split[1])) {
                $shop_id = $split[1];
                Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
            } else {
                $shop_id = Context::getContext()->employee->getDefaultShopID();
                Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
            }
        }
    }
}
// Check multishop context and set right context if need
if (Shop::getContext()) {
    if (Shop::getContext() == Shop::CONTEXT_SHOP && !Shop::CONTEXT_SHOP) {
        Shop::setContext(Shop::CONTEXT_GROUP, Shop::getContextShopGroupID());
    }
    if (Shop::getContext() == Shop::CONTEXT_GROUP && !Shop::CONTEXT_GROUP) {
Example #6
0
if(isset($_POST['submit'])) {
    foreach($_POST AS $key => $value) {
        if(in_array($key, $allowed)) {
            $$key = $value;
            
            if($common->startsWith($key, 'buy') || $common->startsWith($key, 'sell') || $common->startsWith($key, 'bundle') || $key == 'stock') {
                if($value == "" || $value < 0 || empty($value)) $$key = 0;
            }
     
            if(in_array($key, $required) && empty($value) || $value == "") {
                $errors[] = "The field <strong>{$key}</strong> is required.";
            }
        }
    }
    
    $file = $Shop->getShop($shop);
    
    if($file == false || $file == null) {
        $errors[] = "No shop with the name {$shop} was found.";
    }

    if(count($errors) < 1) { 
        $data = explode(":", $item);
        $item = new Shop_Item($data[0], $data[1]);
        $item->setBuy($buyprice, $bundlebuy);
        $item->setSell($sellprice, $bundlesell);
        $item->setStock(0, $stock);
        
        if($Shop->addItem($item)) {
            $success = "<strong>Added item</strong> ".$items->getName($data[0] . ':' . $data[1])." to <strong>{$shop}</strong> - <a href='editor.php?edit={$shop}'>view changes</a> or add another:<br />";
        } else {
Example #7
0
 public function getCategoryOption($selected = null, $id_category = 1, $id_lang = false, $id_shop = false, $recursive = true)
 {
     $html = '';
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     if ($category->id != 1) {
         $html .= '<option ' . ($selected == $category->id ? 'selected="selected"' : '') . ' value="' . (int) $category->id . '">' . $category->name . '</option>';
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $html .= $this->getCategoryOption($selected, (int) $child['id_category'], (int) $id_lang, (int) $child['id_shop']);
         }
     }
     return $html;
 }
Example #8
0
echo "<h4>Currently Under Construction...</h4>";

$shop = "";
$Shop = new Shop();

$allowed = array(
    'uuid', 'name', 'world', 'creator', 'owner', 'managers', 'locationA', 'locationB', 'money', 'stock',
);

$required = array(
    'uuid', 'shop', 'name', 'world', 'owner', 'locationA', 'locationB',
);

if((isset($_GET['shop']) && $_GET['shop'] != "") || (isset($_POST['shop']) && $_POST['shop'] != "")) {
    $shop = (isset($_POST['shop'])) ? $_POST['shop'] : $_GET['shop'];
    $exists = $Shop->getShop($shop);
    $values = $Shop->readFile()->getValues();
    $itemlist = $Shop->readFile()->getItems();
    if(!$exists) $shop = "";
    if(!$values) $shop = "";
    
    if($shop != "") {
        foreach($values AS $key => $value) {
            $key = str_replace('unlimited-', '', $key);
            
            if(in_array($key, $allowed)) {
                $$key = $value;
            }
        }
        
        if(isset($_POST['submit'])) {
Example #9
0
 public function getCategoryOption($id_category = 1, $selected = null, $id_lang = false, $id_shop = false, $recursive = true, $link = false)
 {
     $html = '';
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         $spacer = str_repeat('&nbsp;', 5 * (int) $category->level_depth);
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     if ($category->id != 1) {
         if ($link) {
             $html .= '<option ' . ($selected == $category->id ? 'selected="selected" ' : '') . 'value="' . $this->context->link->getCategoryLink($category->id) . '">' . (isset($spacer) ? $spacer : '') . $category->name . '</option>';
         } else {
             $html .= '<option ' . ($selected == $category->id ? 'selected="selected" ' : '') . 'value="' . (int) $category->id . '">' . (isset($spacer) ? $spacer : '') . $category->name . '</option>';
         }
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $html .= $this->getCategoryOption((int) $child['id_category'], $selected, (int) $id_lang, (int) $child['id_shop'], $recursive, $link);
         }
     }
     return $html;
 }
Example #10
0
 private function getCategoryOption($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true)
 {
     $html = '';
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         $spacer = '';
         if ($category->level_depth > 0) {
             $spacer = str_repeat('-', 2 * ((int) $category->level_depth - 1));
         }
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     if ($category->id != Configuration::get('PS_ROOT_CATEGORY')) {
         $html .= '<option value="' . (int) $category->id . '">' . $spacer . $category->name . '</option>';
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $html .= $this->getCategoryOption((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop'], $recursive);
         }
     }
     return $html;
 }
Example #11
0
 private function getStoreUrl($id_shop)
 {
     $this->setContext();
     $store_info = Shop::getShop($id_shop);
     $store_url = $store_info['domain'] . $store_info['uri'];
     $store_url = str_replace('http://', '', $store_url);
     $store_url = str_replace('https://', '', $store_url);
     preg_replace('/\\/*$/i', '', $store_url);
     return $store_url;
 }
Example #12
0
 private function generateCategoriesOption2($categories, $frontend)
 {
     $return_categories = array();
     foreach ($categories as $key => $category) {
         $shop = (object) Shop::getShop((int) $category['id_shop']);
         $return_categories[$key]['id'] = (int) $category['id_category'];
         $return_categories[$key]['name'] = (!$frontend ? str_repeat('&nbsp;', $this->spacer_size * (int) $category['level_depth']) : '') . $category['name'] . ' (' . $shop->name . ')';
         if (isset($category['children']) && !empty($category['children'])) {
             $return_categories[$key]['children'] = $this->generateCategoriesOption2($category['children'], $frontend);
         }
     }
     return $return_categories;
 }
Example #13
0
 /**
  * Generate form fields to post to the payment gateway.
  */
 public function getFormFields($type = 'standard', $data = array())
 {
     /* @var $cust Customer */
     /* @var $cart Cart */
     $cust = $this->context->customer;
     $cart = $this->context->cart;
     /* @var $billingCountry Address */
     $billingAddress = new Address($cart->id_address_invoice);
     $billingCountry = new Country($billingAddress->id_country);
     /* @var $deliveryAddress Address */
     $deliveryAddress = new Address($cart->id_address_delivery);
     // TODO to remove when So Colissimo fix cart delivery address id
     $colissimoAddress = $this->_getColissimoShippingAddress($cart, $deliveryAddress, $cust->id);
     if (is_a($colissimoAddress, 'Address')) {
         $deliveryAddress = $colissimoAddress;
     }
     $deliveryCountry = new Country($deliveryAddress->id_country);
     /* @var $api PayzenApi */
     $api = $this->getLoadedApi();
     /* detect default language */
     $language = strtolower(Language::getIsoById(intval($this->context->language->id)));
     if (!$api->isSupportedLanguage($language)) {
         $language = Configuration::get('PAYZEN_DEFAULT_LANGUAGE');
     }
     /* detect store currency */
     $cartCurrency = new Currency(intval($cart->id_currency));
     $currency = $api->findCurrencyByAlphaCode($cartCurrency->iso_code);
     /* Amount */
     $amount = $cart->getOrderTotal();
     $api->set('amount', $currency->convertAmountToInteger($amount));
     $api->set('currency', $currency->num);
     $api->set('cust_email', $cust->email);
     $api->set('cust_id', $cust->id);
     $custTitle = new Gender((int) $cust->id_gender);
     $api->set('cust_title', $custTitle->name[Context::getContext()->language->id]);
     $api->set('cust_first_name', $billingAddress->firstname);
     $api->set('cust_last_name', $billingAddress->lastname);
     $api->set('cust_address', $billingAddress->address1 . ' ' . $billingAddress->address2);
     $api->set('cust_zip', $billingAddress->postcode);
     $api->set('cust_city', $billingAddress->city);
     $api->set('cust_phone', $billingAddress->phone);
     $api->set('cust_country', $billingCountry->iso_code);
     if ($billingAddress->id_state) {
         $state = new State((int) $billingAddress->id_state);
         $api->set('cust_state', $state->iso_code);
     }
     $title = '';
     $this->logger->logInfo("Form data generation for cart #{$cart->id} with {$type} payment.");
     switch ($type) {
         case 'standard':
             // single payment card data
             if (key_exists('card_type', $data) && $data['card_type']) {
                 // override payemnt_cards var
                 $api->set('payment_cards', $data['card_type']);
             }
             if (key_exists('card_number', $data) && $data['card_number']) {
                 $api->set('card_number', $data['card_number']);
                 $api->set('cvv', $data['cvv']);
                 $api->set('expiry_year', $data['expiry_year']);
                 $api->set('expiry_month', $data['expiry_month']);
                 // override action_mode to do a silent payment
                 $api->set('action_mode', 'SILENT');
             }
             $title = Configuration::get('PAYZEN_STD_TITLE', $this->context->language->id);
             if (!$title) {
                 $title = $this->l('Payment by bank card');
             }
             break;
         case 'multi':
             // multiple payment options
             $multiOptions = $this->_getAvailableMultiPaymentOptions();
             $option = $multiOptions[$data['opt']];
             $configFirst = $option['first'];
             $first = $configFirst != '' ? $currency->convertAmountToInteger($configFirst / 100 * $amount) : null;
             $api->setMultiPayment(null, $first, $option['count'], $option['period']);
             // override cb contract
             $api->set('contracts', $option['contract'] ? 'CB=' . $option['contract'] : null);
             $title = Configuration::get('PAYZEN_MULTI_TITLE', $this->context->language->id);
             if (!$title) {
                 $title = $this->l('Payment by bank card in several times');
             }
             $title .= ' (' . $option['count'] . ' x)';
             break;
         case 'oney':
             // Oney payment
             // override with Oney payment cards
             $api->set('payment_cards', 'ONEY_SANDBOX;ONEY');
             $products = $cart->getProducts(true);
             if (Configuration::get('PAYZEN_ONEY_CAT_MODE') == '1') {
                 $category = Configuration::get('PAYZEN_ONEY_COM_CAT');
             } else {
                 $oneyCategories = @unserialize(Configuration::get('PAYZEN_ONEY_PROD_CAT'));
             }
             foreach ($products as $product) {
                 if (!isset($category)) {
                     // build query to get product default category
                     $sql = 'SELECT `id_category_default` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . (int) $product['id_product'];
                     $dbCategory = Db::getInstance()->getValue($sql);
                     $category = $oneyCategories[$dbCategory];
                 }
                 $api->addProductRequestField($product['name'], $currency->convertAmountToInteger($product['total_wt']), $product['cart_quantity'], $product['id_product'], $category);
             }
             // Oney delivery options defined in admin panel
             $oneyOptions = @unserialize(Configuration::get('PAYZEN_ONEY_SHIP_OPTIONS'));
             // retrieve carrier ID from cart
             if (isset($cart->id_carrier) && $cart->id_carrier > 0) {
                 $carrierId = $cart->id_carrier;
             } else {
                 $deliveryOptionList = $cart->getDeliveryOptionList();
                 $deliveryOption = $cart->getDeliveryOption();
                 $carrierKey = $deliveryOption[$deliveryAddress->id];
                 foreach ($deliveryOptionList[$deliveryAddress->id][$carrierKey]['carrier_list'] as $id => $data) {
                     $carrierId = $id;
                     break;
                 }
             }
             $shopNameRegexNotAllowed = "#[^A-Z0-9ÁÀÂÄÉÈÊËÍÌÎÏÓÒÔÖÚÙÛÜÇ /'-]#ui";
             if ($cart->isVirtualCart() || !isset($carrierId) || !is_array($oneyOptions) || empty($oneyOptions)) {
                 // No shipping options
                 $api->set('ship_to_type', 'ETICKET');
                 $api->set('ship_to_speed', 'EXPRESS');
                 $shop = Shop::getShop($cart->id_shop);
                 $api->set('ship_to_delivery_company_name', preg_replace($shopNameRegexNotAllowed, ' ', $shop['name']));
             } elseif (Configuration::get('TNT_CARRIER_' . self::TNT_RELAY_POINT_PREFIX . '_ID') == $carrierId) {
                 $api->set('ship_to_type', 'RELAY_POINT');
                 $api->set('ship_to_speed', 'EXPRESS');
                 if ($row = Db::getInstance()->getRow("SELECT * FROM `" . _DB_PREFIX_ . "tnt_carrier_drop_off`\r\n\t\t\t\t\t\t\t\tWHERE `id_cart` = '" . $cart->id . "'")) {
                     $tntRelayAddress = $row['name'] . ' ' . $row['address'] . ' ' . $row['zipcode'] . ' ' . $row['city'];
                     $api->set('ship_to_delivery_company_name', preg_replace($shop_name_regex, ' ', $tntRelayAddress));
                     $api->set('ship_to_last_name', preg_replace($shop_name_regex, ' ', $row['name']));
                     $api->set('ship_to_street', preg_replace($shop_name_regex, ' ', $row['address']));
                     $api->set('ship_to_zip', $row['zipcode']);
                     $api->set('ship_to_city', preg_replace($shop_name_regex, ' ', $row['city']));
                     $api->set('ship_to_country', 'FR');
                 }
             } else {
                 $deliveryType = $oneyOptions[$carrierId]['delivery_type'];
                 $api->set('ship_to_type', $deliveryType);
                 $companyName = $oneyOptions[$carrierId]['carrier_label'];
                 if ($deliveryType === 'RECLAIM_IN_SHOP') {
                     $companyName .= ' ' . $oneyOptions[$carrierId]['address'];
                 }
                 $api->set('ship_to_delivery_company_name', $companyName);
                 $api->set('ship_to_speed', $oneyOptions[$carrierId]['delivery_speed']);
             }
             $api->set('cust_status', 'PRIVATE');
             // Prestashop don't manage customer type
             $api->set('ship_to_status', $deliveryAddress->company != '' ? 'COMPANY' : 'PRIVATE');
             $api->set('insurance_amount', '');
             // not available in Prestashop by default
             $api->set('tax_amount', $currency->convertAmountToInteger($cart->getOrderTotal() - $cart->getOrderTotal(false)));
             $api->set('shipping_amount', $currency->convertAmountToInteger($cart->getTotalShippingCost()));
             $title = Configuration::get('PAYZEN_ONEY_TITLE', $this->context->language->id);
             if (!$title) {
                 $title = $this->l('Payment with FacilyPay Oney');
             }
     }
     if ($api->get('ship_to_type') == null || $api->get('ship_to_type') == 'PACKAGE_DELIVERY_COMPANY') {
         $api->set('ship_to_first_name', $deliveryAddress->firstname);
         $api->set('ship_to_last_name', $deliveryAddress->lastname);
         $api->set('ship_to_street', $deliveryAddress->address1);
         $api->set('ship_to_street2', $deliveryAddress->address2);
         $api->set('ship_to_zip', $deliveryAddress->postcode);
         $api->set('ship_to_city', $deliveryAddress->city);
         $api->set('ship_to_phone_num', $deliveryAddress->phone);
         $api->set('ship_to_country', $deliveryCountry->iso_code);
         if ($deliveryAddress->id_state) {
             $state = new State((int) $deliveryAddress->id_state);
             $api->set('ship_to_state', $state->iso_code);
         }
     }
     $api->set('order_info', $title);
     // activate 3ds ?
     $threedsMpi = null;
     if (Configuration::get('PAYZEN_3DS_MIN_AMOUNT') != '' && $amount < Configuration::get('PAYZEN_3DS_MIN_AMOUNT')) {
         $threedsMpi = '2';
     }
     $api->set('threeds_mpi', $threedsMpi);
     $api->set('language', $language);
     $api->set('order_id', $cart->id);
     $api->set('url_return', $this->context->link->getModuleLink($this->name, 'submit', array(), true));
     // patch to avoid signature error with HTML minifier introduced since Prestashop 1.6.0.3
     if (Configuration::get('PS_HTML_THEME_COMPRESSION') && Tools::version_compare(_PS_VERSION_, '1.6.0.3', '>=')) {
         foreach ($api->getRequestFields() as $field) {
             $value = preg_replace('/\\s+/m', ' ', $field->getValue());
             $api->set($field->getName(), $value);
         }
     }
     // prepare data for PayZen payment form
     return $api->getRequestFieldsArray();
 }
 private function getCategoryOption($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     $spacer = NULL;
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         $spacer = str_repeat('&nbsp;', $this->spacer_size * (int) $category->level_depth);
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     $cateCurrent = Configuration::get($this->name . '_list_cate');
     $cateCurrent = explode(',', $cateCurrent);
     $value = (int) $category->id;
     if (in_array($value, $cateCurrent)) {
         $this->_html .= '<option value="' . (int) $category->id . '"  selected ="selected">' . (isset($spacer) ? $spacer : '') . $category->name . '</option>';
     } else {
         $this->_html .= '<option value="' . (int) $category->id . '">' . (isset($spacer) ? $spacer : '') . $category->name . '</option>';
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $this->getCategoryOption((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop']);
         }
     }
 }
 private function getCategoryOption($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         $spacer = str_repeat('&nbsp;', $this->spacer_size * (int) $category->level_depth);
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     $this->_html .= '<option value="CAT' . (int) $category->id . '">' . (isset($spacer) ? $spacer : '') . $category->name . ' (' . $shop->name . ')</option>';
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $this->getCategoryOption((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop']);
         }
     }
 }
 /**
  * Shop id is exist
  *
  * @param  $id_shop (string) | (int) - Shop id
  * @return boolean
  */
 public static function shopIsAvailable($id_shop)
 {
     if (!Shop::getShop($id_shop)) {
         self::log('shopIsAvailable -> Shop not found given shop id: ' . $id_shop);
         return false;
     }
     return true;
 }
Example #17
0
 protected function generateCategoriesOption($categories, $items_to_skip = null)
 {
     $html = '';
     foreach ($categories as $key => $category) {
         if (isset($items_to_skip)) {
             $shop = (object) Shop::getShop((int) $category['id_shop']);
             $html .= '<option value="CAT' . (int) $category['id_category'] . '">' . str_repeat('&nbsp;', $this->spacer_size * (int) $category['level_depth']) . $category['name'] . ' (' . $shop->name . ')</option>';
         }
         if (isset($category['children']) && !empty($category['children'])) {
             $html .= $this->generateCategoriesOption($category['children'], $items_to_skip);
         }
     }
     return $html;
 }
Example #18
0
 private function getCategoryTree($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         $spacer = 12 * (int) $category->level_depth;
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     $this->temp_html .= '<li style="padding-left:' . (isset($spacer) ? $spacer + 10 . 'px' : '10px') . ';" data-cat="' . (int) $category->id . '" >' . $category->name . ' <span>(' . $shop->name . ')</span><i class="fa fa-circle-o"></i></li>';
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $this->getCategoryTree((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop']);
         }
     }
 }