Jump to content

Andron777

Members
  • Posts

    38
  • Joined

  • Last visited

Profile Information

  • Activity
    Freelancer

Recent Profile Visitors

2,387,719 profile views

Andron777's Achievements

Newbie

Newbie (1/14)

0

Reputation

2

Community Answers

  1. I found the solution: Prestashop: 1.6 1. edit classes/PaymentModule.php after line 467 add: 'condition' => $product['condition'], 2. In your email template the file "order_conf_product_list.tpl" use: {$product['condition']}
  2. I need to show product condition in mails/en/**order_conf_product_list.tpl** I tried adding {$product['condition']} but i get this error: *Notice: Undefined index: condition in /home/yourserver/public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(171) : eval()'d code on line 70* I guess I must make modification of mailalerts.php, but how to get the product condition? if I do {$product|@var_dump} "condition" is not in the array
  3. Hi guys, I think this would be usefull not only for me. So, I am working now on blockcart module. And I want to make somethink that will calculate how much remains to add to cart until free shipping. I saw this on some websites, it is very usefull, it makes users to get interested and adds some more items to cart. So, by far its not that hard to make it in the blockcart.tpl, however it will work only after user refresh the page. But in my case where all products are on homepage, and there will be no refresh from user side, I really need to get it done through ajax-cart.js and blockcart-json.tpl. 1. I use one shipping option only & and one payment method (however I think that is not so important) 2. I configured my carrier so that it will be a fixed price for shipping for order under 200$ and free shipping for orders above 200$ In blockcart.tpl I made this: <span>{l s='Shipping' mod='blockcart'} <b class="price cart_block_shipping_cost ajax_cart_shipping_cost{if !($page_name == 'order-opc') && $shipping_cost_float == 0 && (!$cart_qties || $cart->isVirtualCart() || !isset($cart->id_address_delivery) || !$cart->id_address_delivery || $free_ship)} unvisible{/if}"> {if $shipping_cost_float == 0} {if !($page_name == 'order-opc')} <!-- && (!isset($cart->id_address_delivery) || !$cart->id_address_delivery) --> {l s='To be determined' mod='blockcart'} {else} {l s='Free shipping!' mod='blockcart'} {/if} {else} {$shipping_cost} {/if} </b> </span> <span class="small price cart_block_shipping_cost ajax_cart_shipping_cost_2">{l s='For free delivery still needs' mod='blockcart'} - {200 - {$total[spam-filter]</span> in blockcart-json.tpl, right after line "shippingCost": {$shipping_cost|json_encode}," I added this: "shippingCost_2": {l s='For free delivery still needs' mod='blockcart'} - {200 - $total|json_encode}, And in ajax-cart.js right after: //update general cart informations everywhere in the page updateCartEverywhere : function(jsonData){ $('.ajax_cart_total').text($.trim(jsonData.productTotal)); I added: $('.ajax_cart_shipping_cost_2').text(jsonData.shippingCost_2); AND IT'S NOT WORKING! But I am sure I am on the right way. I only need help to fix my mistakes since I am not [spam-filter] in ajax and json. please help me!
  4. Hello, I want to show product condition in blockcart module, I already have done some success but i cant make it work in ajax. this is what I have done: added in classes > cart.php at line 510 p.condition added in blockcart-json.tpl "condition": {$product.condition|intval}, it works in blockcart.tpl but it is not working in the ajax-cart.tpl. In other words I must refresh the page so that it will work. But it should work without refresh when adding products to cart. in ajax-cart.js I call it by this variable "this.condition" but the result i get after adding product to cart is "undefined" Any idea what I am missing?
  5. It looks like I found a solution, in file: {root}/classes/Product.php at line '305' I changed required to FALSE.... And i dont get any errors.... Hope I fixed it.... If it will appear again I will write here...
  6. Hello, the title of the topic was the error sorry This link_rewrite field is required at least in English (English) And the field is filled... but i still get this error.... and it happens not all the time.... In some categories when adding/edit a product it works good, no errors.... All modifications i made in BO files are like comments the fileds i dont need to use, however all required fields are not touched.... I AM SURE there must be a way to disable it for ever, maybe some php tricks? There must be a file which validates this form before inserting/updating data in DB.... Please help!
  7. Hello, I am using PS 1.6.0.9. when adding a new product, i get this error... Is it possible to disable this error? I know this might happen because I made some modification in BO to meet my needs, but ant way is it a way to dissable this check? Anyway I am not planning to be using SEO so I really dont need this link_rewrite option.... Please help me!!!
  8. Hello, I am modifying PS for my needs and i am quite confused about this: 1. If I go in BO > catalog > Products. When selecting any category, the top URL changes and id_category=12 is added in URL: 2. If i go and edit a product or add new product the id_category remains in the URL: 3. But after I save the product, or in some case after saving it comes with some errors, the id_category disappears: Question: How to keep id_category always inside URL? The reason i need this is because under each category_Id i have some script modification, and in order to keep those scripts working i need to have a URL with id_category! I already solved this by my self. in case anyone needs help on this please leave a comment!
  9. Hello, I need to bring in the list "Condition" but if i add this code: $this->fields_list['condition'] = array( 'title' => $this->l('Condition'), 'align' => 'left', 'width' => 40 ); its not workin! Any idea?
  10. Hello, After playing around with it, errors disappeared, but the image2 is not uploading in DB. Here is me code, and what i have achieved till now. continue playing with it. Hope some one will give me a hint!!! protected function createTables() { /* Slides */ $res = (bool)Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'homesliderafisa` ( `id_homesliderafisa_slides` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_shop` int(10) unsigned NOT NULL, PRIMARY KEY (`id_homesliderafisa_slides`, `id_shop`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8; '); /* Slides configuration */ $res &= Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'homesliderafisa_slides` ( `id_homesliderafisa_slides` int(10) unsigned NOT NULL AUTO_INCREMENT, `position` int(10) unsigned NOT NULL DEFAULT \'0\', `active` tinyint(1) unsigned NOT NULL DEFAULT \'0\', PRIMARY KEY (`id_homesliderafisa_slides`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8; '); /* Slides lang configuration */ $res &= Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'homesliderafisa_slides_lang` ( `id_homesliderafisa_slides` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `title` varchar(255) NOT NULL, `description` text NOT NULL, `legend` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, `image` varchar(255) NOT NULL, `image2` varchar(255) NOT NULL, PRIMARY KEY (`id_homesliderafisa_slides`,`id_lang`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8; '); return $res; } /** * deletes tables */ protected function deleteTables() { $slides = $this->getSlides(); foreach ($slides as $slide) { $to_del = new HomeSlideafisa($slide['id_slide']); $to_del->delete(); } return Db::getInstance()->execute(' DROP TABLE IF EXISTS `'._DB_PREFIX_.'homesliderafisa`, `'._DB_PREFIX_.'homesliderafisa_slides`, `'._DB_PREFIX_.'homesliderafisa_slides_lang`; '); } public function getContent() { $this->_html .= $this->headerHTML(); /* Validate & process */ if (Tools::isSubmit('submitSlide') || Tools::isSubmit('delete_id_slide') || Tools::isSubmit('submitSlider') || Tools::isSubmit('changeStatus') ) { if ($this->_postValidation()) { $this->_postProcess(); $this->_html .= $this->renderForm(); $this->_html .= $this->renderList(); } else $this->_html .= $this->renderAddForm(); $this->clearCache(); } elseif (Tools::isSubmit('addSlide') || (Tools::isSubmit('id_slide') && $this->slideExists((int)Tools::getValue('id_slide')))) $this->_html .= $this->renderAddForm(); else { $this->_html .= $this->renderForm(); $this->_html .= $this->renderList(); } return $this->_html; } private function _postValidation() { $errors = array(); /* Validation for Slider configuration */ if (Tools::isSubmit('submitSlider')) { if (!Validate::isInt(Tools::getValue('HOMESLIDER_SPEED')) || !Validate::isInt(Tools::getValue('HOMESLIDER_PAUSE')) || !Validate::isInt(Tools::getValue('HOMESLIDER_WIDTH')) ) $errors[] = $this->l('Invalid values'); } /* Validation for status */ elseif (Tools::isSubmit('changeStatus')) { if (!Validate::isInt(Tools::getValue('id_slide'))) $errors[] = $this->l('Invalid slide'); } /* Validation for Slide */ elseif (Tools::isSubmit('submitSlide')) { /* Checks state (active) */ if (!Validate::isInt(Tools::getValue('active_slide')) || (Tools::getValue('active_slide') != 0 && Tools::getValue('active_slide') != 1)) $errors[] = $this->l('Invalid slide state.'); /* Checks position */ if (!Validate::isInt(Tools::getValue('position')) || (Tools::getValue('position') < 0)) $errors[] = $this->l('Invalid slide position.'); /* If edit : checks id_slide */ if (Tools::isSubmit('id_slide')) { //d(var_dump(Tools::getValue('id_slide'))); if (!Validate::isInt(Tools::getValue('id_slide')) && !$this->slideExists(Tools::getValue('id_slide'))) $errors[] = $this->l('Invalid slide ID'); } /* Checks title/url/legend/description/image */ $languages = Language::getLanguages(false); foreach ($languages as $language) { if (Tools::strlen(Tools::getValue('title_'.$language['id_lang'])) > 255) $errors[] = $this->l('The title is too long.'); if (Tools::strlen(Tools::getValue('legend_'.$language['id_lang'])) > 255) $errors[] = $this->l('The caption is too long.'); if (Tools::strlen(Tools::getValue('url_'.$language['id_lang'])) > 255) $errors[] = $this->l('The URL is too long.'); if (Tools::strlen(Tools::getValue('description_'.$language['id_lang'])) > 4000) $errors[] = $this->l('The description is too long.'); if (Tools::strlen(Tools::getValue('url_'.$language['id_lang'])) > 0 && !Validate::isUrl(Tools::getValue('url_'.$language['id_lang']))) $errors[] = $this->l('The URL format is not correct.'); //if (Tools::getValue('image_'.$language['id_lang']) != null && !Validate::isFileName(Tools::getValue('image_'.$language['id_lang']))) // $errors[] = $this->l('Invalid filename.'); //if (Tools::getValue('image_old_'.$language['id_lang']) != null && !Validate::isFileName(Tools::getValue('image_old_'.$language['id_lang']))) // $errors[] = $this->l('Invalid filename.'); } /* Checks title/url/legend/description for default lang */ $id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT'); if (Tools::strlen(Tools::getValue('title_'.$id_lang_default)) == 0) $errors[] = $this->l('The title is not set.'); if (Tools::strlen(Tools::getValue('legend_'.$id_lang_default)) == 0) $errors[] = $this->l('The caption is not set.'); if (Tools::strlen(Tools::getValue('url_'.$id_lang_default)) == 0) $errors[] = $this->l('The URL is not set.'); //if (!Tools::isSubmit('has_picture') && (!isset($_FILES['image_'.$id_lang_default]) || empty($_FILES['image_'.$id_lang_default]['tmp_name']))) // $errors[] = $this->l('The image is not set.'); //if (Tools::getValue('image_old_'.$id_lang_default) && !Validate::isFileName(Tools::getValue('image_old_'.$id_lang_default))) // $errors[] = $this->l('The image is not set.'); } /* Validation for deletion */ elseif (Tools::isSubmit('delete_id_slide') && (!Validate::isInt(Tools::getValue('delete_id_slide')) || !$this->slideExists((int)Tools::getValue('delete_id_slide')))) $errors[] = $this->l('Invalid slide ID'); /* Display errors if needed */ if (count($errors)) { $this->_html .= $this->displayError(implode('<br />', $errors)); return false; } /* Returns if validation is ok */ return true; } private function _postProcess() { $errors = array(); /* Processes Slider */ if (Tools::isSubmit('submitSlider')) { $res = Configuration::updateValue('HOMESLIDER_WIDTH', (int)Tools::getValue('HOMESLIDER_WIDTH')); $res &= Configuration::updateValue('HOMESLIDER_SPEED', (int)Tools::getValue('HOMESLIDER_SPEED')); $res &= Configuration::updateValue('HOMESLIDER_PAUSE', (int)Tools::getValue('HOMESLIDER_PAUSE')); $res &= Configuration::updateValue('HOMESLIDER_LOOP', (int)Tools::getValue('HOMESLIDER_LOOP')); $this->clearCache(); if (!$res) $errors[] = $this->displayError($this->l('The configuration could not be updated.')); else Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true).'&conf=6&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name); } /* Process Slide status */ elseif (Tools::isSubmit('changeStatus') && Tools::isSubmit('id_slide')) { $slide = new HomeSlideafisa((int)Tools::getValue('id_slide')); if ($slide->active == 0) $slide->active = 1; else $slide->active = 0; $res = $slide->update(); $this->clearCache(); $this->_html .= ($res ? $this->displayConfirmation($this->l('Configuration updated')) : $this->displayError($this->l('The configuration could not be updated.'))); } /* Processes Slide */ elseif (Tools::isSubmit('submitSlide')) { /* Sets ID if needed */ if (Tools::getValue('id_slide')) { $slide = new HomeSlideafisa((int)Tools::getValue('id_slide')); if (!Validate::isLoadedObject($slide)) { $this->_html .= $this->displayError($this->l('Invalid slide ID')); return false; } } else $slide = new HomeSlideafisa(); /* Sets position */ $slide->position = (int)Tools::getValue('position'); /* Sets active */ $slide->active = (int)Tools::getValue('active_slide'); /* Sets each langue fields */ $languages = Language::getLanguages(false); foreach ($languages as $language) { $slide->title[$language['id_lang']] = Tools::getValue('title_'.$language['id_lang']); $slide->url[$language['id_lang']] = Tools::getValue('url_'.$language['id_lang']); $slide->legend[$language['id_lang']] = Tools::getValue('legend_'.$language['id_lang']); $slide->description[$language['id_lang']] = Tools::getValue('description_'.$language['id_lang']); /* Uploads image and sets slide */ $type = Tools::strtolower(Tools::substr(strrchr($_FILES['image_'.$language['id_lang']]['name'], '.'), 1)); $imagesize = @getimagesize($_FILES['image_'.$language['id_lang']]['tmp_name']); if (isset($_FILES['image_'.$language['id_lang']]) && isset($_FILES['image_'.$language['id_lang']]['tmp_name']) && !empty($_FILES['image_'.$language['id_lang']]['tmp_name']) && !empty($imagesize) && in_array( Tools::strtolower(Tools::substr(strrchr($imagesize['mime'], '/'), 1)), array( 'jpg', 'gif', 'jpeg', 'png' ) ) && in_array($type, array('jpg', 'gif', 'jpeg', 'png')) ) { $temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS'); $salt = sha1(microtime()); if ($error = ImageManager::validateUpload($_FILES['image_'.$language['id_lang']])) $errors[] = $error; elseif (!$temp_name || !move_uploaded_file($_FILES['image_'.$language['id_lang']]['tmp_name'], $temp_name)) return false; elseif (!ImageManager::resize($temp_name, dirname(__FILE__).'/images/'.$salt.'_'.$_FILES['image_'.$language['id_lang']]['name'], null, null, $type)) $errors[] = $this->displayError($this->l('An error occurred during the image upload process.')); if (isset($temp_name)) @unlink($temp_name); $slide->image[$language['id_lang']] = $salt.'_'.$_FILES['image_'.$language['id_lang']]['name']; } elseif (Tools::getValue('image_old_'.$language['id_lang']) != '') $slide->image[$language['id_lang']] = Tools::getValue('image_old_'.$language['id_lang']); /* Uploads image2 and sets slide */ $type2 = Tools::strtolower(Tools::substr(strrchr($_FILES['image2_'.$language['id_lang']]['name'], '.'), 1)); $imagesize2 = @getimagesize($_FILES['image2_'.$language['id_lang']]['tmp_name']); if (isset($_FILES['image2_'.$language['id_lang']]) && isset($_FILES['image2_'.$language['id_lang']]['tmp_name']) && !empty($_FILES['image2_'.$language['id_lang']]['tmp_name']) && !empty($imagesize2) && in_array( Tools::strtolower(Tools::substr(strrchr($imagesize2['mime'], '/'), 1)), array( 'jpg', 'gif', 'jpeg', 'png' ) ) && in_array($type2, array('jpg', 'gif', 'jpeg', 'png')) ) { $temp_name2 = tempnam(_PS_TMP_IMG_DIR_, 'PS'); $salt2 = sha1(microtime()); if ($error = ImageManager::validateUpload($_FILES['image2_'.$language['id_lang']])) $errors[] = $error; elseif (!$temp_name2 || !move_uploaded_file($_FILES['image2_'.$language['id_lang']]['tmp_name'], $temp_name2)) return false; elseif (!ImageManager::resize($temp_name2, dirname(__FILE__).'/images/'.$salt2.'_'.$_FILES['image2_'.$language['id_lang']]['name'], null, null, $type2)) $errors[] = $this->displayError($this->l('An error occurred during the image2 upload process.')); if (isset($temp_name2)) @unlink($temp_name2); $slide2->image2[$language['id_lang']] = $salt2.'_'.$_FILES['image2_'.$language['id_lang']]['name']; } elseif (Tools::getValue('image2_old_'.$language['id_lang']) != '') $slide2->image2[$language['id_lang']] = Tools::getValue('image2_old_'.$language['id_lang']); } /* Processes if no errors */ if (!$errors) { /* Adds */ if (!Tools::getValue('id_slide')) { if (!$slide->add()) $errors[] = $this->displayError($this->l('The slide could not be added.')); } /* Update */ elseif (!$slide->update()) $errors[] = $this->displayError($this->l('The slide could not be updated.')); $this->clearCache(); } } /* Deletes */ elseif (Tools::isSubmit('delete_id_slide')) { $slide = new HomeSlideafisa((int)Tools::getValue('delete_id_slide')); $res = $slide->delete(); $this->clearCache(); if (!$res) $this->_html .= $this->displayError('Could not delete.'); else Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true).'&conf=1&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name); } /* Display errors if needed */ if (count($errors)) $this->_html .= $this->displayError(implode('<br />', $errors)); elseif (Tools::isSubmit('submitSlide') && Tools::getValue('id_slide')) Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true).'&conf=4&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name); elseif (Tools::isSubmit('submitSlide')) Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true).'&conf=3&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name); } private function _prepareHook() { if (!$this->isCached('homesliderafisa.tpl', $this->getCacheId())) { $slides = $this->getSlides(true); if (is_array($slides)) foreach ($slides as &$slide) { $slide['sizes'] = @getimagesize((dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$slide['image'])); if (isset($slide['sizes'][3]) && $slide['sizes'][3]) $slide['size'] = $slide['sizes'][3]; $slide2['sizes'] = @getimagesize((dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$slide2['image2'])); if (isset($slide2['sizes'][3]) && $slide2['sizes'][3]) $slide2['size'] = $slide2['sizes'][3]; } if (!$slides) return false; $this->smarty->assign(array('homesliderafisa_slides' => $slides)); } return true; } public function hookdisplayHeader($params) { if (!isset($this->context->controller->php_self) || $this->context->controller->php_self != 'index') return; $this->context->controller->addCSS($this->_path.'homesliderafisa.css'); $this->context->controller->addJS($this->_path.'js/homesliderafisa.js'); $this->context->controller->addJqueryPlugin(array('bxslider')); $slider = array( 'width' => Configuration::get('HOMESLIDER_WIDTH'), 'speed' => Configuration::get('HOMESLIDER_SPEED'), 'pause' => Configuration::get('HOMESLIDER_PAUSE'), 'loop' => (bool)Configuration::get('HOMESLIDER_LOOP'), ); $this->smarty->assign('homesliderafisa', $slider); return $this->display(__FILE__, 'header.tpl'); } public function hookdisplayHomeAfisa($params) { return $this->hookdisplayHeader($params); } public function hookdisplayTop($params) { return $this->hookdisplayTopColumn($params); } public function hookdisplayTopColumn($params) { if (!isset($this->context->controller->php_self) || $this->context->controller->php_self != 'index') return; if (!$this->_prepareHook()) return false; return $this->display(__FILE__, 'homesliderafisa.tpl', $this->getCacheId()); } public function hookDisplayHome() { if (!$this->_prepareHook()) return false; return $this->display(__FILE__, 'homesliderafisa.tpl', $this->getCacheId()); } public function clearCache() { $this->_clearCache('homesliderafisa.tpl'); } public function hookActionShopDataDuplication($params) { Db::getInstance()->execute(' INSERT IGNORE INTO '._DB_PREFIX_.'homesliderafisa (id_homesliderafisa_slides, id_shop) SELECT id_homesliderafisa_slides, '.(int)$params['new_id_shop'].' FROM '._DB_PREFIX_.'homesliderafisa WHERE id_shop = '.(int)$params['old_id_shop'] ); $this->clearCache(); } public function headerHTML() { if (Tools::getValue('controller') != 'AdminModules' && Tools::getValue('configure') != $this->name) return; $this->context->controller->addJqueryUI('ui.sortable'); /* Style & js for fieldset 'slides configuration' */ $html = '<script type="text/javascript"> $(function() { var $mySlides = $("#slides"); $mySlides.sortable({ opacity: 0.6, cursor: "move", update: function() { var order = $(this).sortable("serialize") + "&action=updateSlidesPosition"; $.post("'.$this->context->shop->physical_uri.$this->context->shop->virtual_uri.'modules/'.$this->name.'/ajax_'.$this->name.'.php?secure_key='.$this->secure_key.'", order); } }); $mySlides.hover(function() { $(this).css("cursor","move"); }, function() { $(this).css("cursor","auto"); }); }); </script>'; return $html; } public function getNextPosition() { $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT MAX(hss.`position`) AS `next_position` FROM `'._DB_PREFIX_.'homesliderafisa_slides` hss, `'._DB_PREFIX_.'homesliderafisa` hs WHERE hss.`id_homesliderafisa_slides` = hs.`id_homesliderafisa_slides` AND hs.`id_shop` = '.(int)$this->context->shop->id ); return (++$row['next_position']); } public function getSlides($active = null) { $this->context = Context::getContext(); $id_shop = $this->context->shop->id; $id_lang = $this->context->language->id; return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT hs.`id_homesliderafisa_slides` as id_slide, hssl.`image`, hssl.`image2`, hss.`position`, hss.`active`, hssl.`title`, hssl.`url`, hssl.`legend`, hssl.`description`, hssl.`image`, hssl.`image2` FROM '._DB_PREFIX_.'homesliderafisa hs LEFT JOIN '._DB_PREFIX_.'homesliderafisa_slides hss ON (hs.id_homesliderafisa_slides = hss.id_homesliderafisa_slides) LEFT JOIN '._DB_PREFIX_.'homesliderafisa_slides_lang hssl ON (hss.id_homesliderafisa_slides = hssl.id_homesliderafisa_slides) WHERE id_shop = '.(int)$id_shop.' AND hssl.id_lang = '.(int)$id_lang. ($active ? ' AND hss.`active` = 1' : ' ').' ORDER BY hss.position' ); } public function getAllImagesBySlidesId($id_slides, $active = null, $id_shop = null) { $this->context = Context::getContext(); $images = array(); if (!isset($id_shop)) $id_shop = $this->context->shop->id; $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT hssl.`image`, hssl.`image2`, hssl.`id_lang` FROM '._DB_PREFIX_.'homesliderafisa hs LEFT JOIN '._DB_PREFIX_.'homesliderafisa_slides hss ON (hs.id_homesliderafisa_slides = hss.id_homesliderafisa_slides) LEFT JOIN '._DB_PREFIX_.'homesliderafisa_slides_lang hssl ON (hss.id_homesliderafisa_slides = hssl.id_homesliderafisa_slides) WHERE hs.`id_homesliderafisa_slides` = '.(int)$id_slides.' AND hs.`id_shop` = '.(int)$id_shop. ($active ? ' AND hss.`active` = 1' : ' ') ); foreach ($results as $result) $images[$result['id_lang']] = $result['image']; $images2[$result['id_lang']] = $result2['image']; return $images; } public function displayStatus($id_slide, $active) { $title = ((int)$active == 0 ? $this->l('Disabled') : $this->l('Enabled')); $icon = ((int)$active == 0 ? 'icon-remove' : 'icon-check'); $class = ((int)$active == 0 ? 'btn-danger' : 'btn-success'); $html = '<a class="btn '.$class.'" href="'.AdminController::$currentIndex. '&configure='.$this->name.' &token='.Tools::getAdminTokenLite('AdminModules').' &changeStatus&id_slide='.(int)$id_slide.'" title="'.$title.'"><i class="'.$icon.'"></i> '.$title.'</a>'; return $html; } public function slideExists($id_slide) { $req = 'SELECT hs.`id_homesliderafisa_slides` as id_slide FROM `'._DB_PREFIX_.'homesliderafisa` hs WHERE hs.`id_homesliderafisa_slides` = '.(int)$id_slide; $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($req); return ($row); } public function renderList() { $slides = $this->getSlides(); foreach ($slides as $key => $slide) $slides[$key]['status'] = $this->displayStatus($slide['id_slide'], $slide['active']); $this->context->smarty->assign( array( 'link' => $this->context->link, 'slides' => $slides, 'image_baseurl' => $this->_path.'images/', 'image2_baseurl' => $this->_path.'images/' ) ); return $this->display(__FILE__, 'list.tpl'); } public function renderAddForm() { $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Slide information'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'file_lang', 'label' => $this->l('Select a file'), 'name' => 'image', 'lang' => true, 'desc' => $this->l(sprintf('Maximum image size: %s.', ini_get('upload_max_filesize'))) ), array( 'type' => 'file_lang', 'label' => $this->l('Select a file'), 'name' => 'image2', 'lang' => true, 'desc' => $this->l(sprintf('Maximum image size: %s.', ini_get('upload_max_filesize'))) ), array( 'type' => 'text', 'label' => $this->l('Slide title'), 'name' => 'title', 'lang' => true, ), array( 'type' => 'text', 'label' => $this->l('Target URL'), 'name' => 'url', 'lang' => true, ), array( 'type' => 'text', 'label' => $this->l('Caption'), 'name' => 'legend', 'lang' => true, ), array( 'type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'autoload_rte' => true, 'lang' => true, ), array( 'type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active_slide', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Yes') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('No') ) ), ), ), 'submit' => array( 'title' => $this->l('Save'), ) ), ); if (Tools::isSubmit('id_slide') && $this->slideExists((int)Tools::getValue('id_slide'))) { $slide = new HomeSlideafisa((int)Tools::getValue('id_slide')); $fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'id_slide'); $fields_form['form']['images'] = $slide->image; $has_picture = true; foreach (Language::getLanguages(false) as $lang) if (!isset($slide->image[$lang['id_lang']])) $has_picture &= false; if ($has_picture) $fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'has_picture'); } $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $this->fields_form = array(); $helper->module = $this; $helper->identifier = $this->identifier; $helper->submit_action = 'submitSlide'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $language = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->tpl_vars = array( 'base_url' => $this->context->shop->getBaseURL(), 'language' => array( 'id_lang' => $language->id, 'iso_code' => $language->iso_code ), 'fields_value' => $this->getAddFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, 'image_baseurl' => $this->_path.'images/' ); $helper->override_folder = '/'; return $helper->generateForm(array($fields_form)); } public function renderForm() { $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Maximum image width'), 'name' => 'HOMESLIDER_WIDTH', 'suffix' => 'pixels' ), array( 'type' => 'text', 'label' => $this->l('Speed'), 'name' => 'HOMESLIDER_SPEED', 'suffix' => 'milliseconds', 'desc' => $this->l('The duration of the transition between two slides.') ), array( 'type' => 'text', 'label' => $this->l('Pause'), 'name' => 'HOMESLIDER_PAUSE', 'suffix' => 'milliseconds', 'desc' => $this->l('The delay between two slides.') ), array( 'type' => 'switch', 'label' => $this->l('Auto play'), 'name' => 'HOMESLIDER_LOOP', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ) ), 'submit' => array( 'title' => $this->l('Save'), ) ), ); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $this->fields_form = array(); $helper->identifier = $this->identifier; $helper->submit_action = 'submitSlider'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); return $helper->generateForm(array($fields_form)); } public function getConfigFieldsValues() { return array( 'HOMESLIDER_WIDTH' => Tools::getValue('HOMESLIDER_WIDTH', Configuration::get('HOMESLIDER_WIDTH')), 'HOMESLIDER_SPEED' => Tools::getValue('HOMESLIDER_SPEED', Configuration::get('HOMESLIDER_SPEED')), 'HOMESLIDER_PAUSE' => Tools::getValue('HOMESLIDER_PAUSE', Configuration::get('HOMESLIDER_PAUSE')), 'HOMESLIDER_LOOP' => Tools::getValue('HOMESLIDER_LOOP', Configuration::get('HOMESLIDER_LOOP')), ); } public function getAddFieldsValues() { $fields = array(); if (Tools::isSubmit('id_slide') && $this->slideExists((int)Tools::getValue('id_slide'))) { $slide = new HomeSlideafisa((int)Tools::getValue('id_slide')); $fields['id_slide'] = (int)Tools::getValue('id_slide', $slide->id); } else $slide = new HomeSlideafisa(); $fields['active_slide'] = Tools::getValue('active_slide', $slide->active); $fields['has_picture'] = true; $languages = Language::getLanguages(false); foreach ($languages as $lang) { $fields['image'][$lang['id_lang']] = Tools::getValue('image_'.(int)$lang['id_lang']); $fields['title'][$lang['id_lang']] = Tools::getValue('title_'.(int)$lang['id_lang'], $slide->title[$lang['id_lang']]); $fields['url'][$lang['id_lang']] = Tools::getValue('url_'.(int)$lang['id_lang'], $slide->url[$lang['id_lang']]); $fields['legend'][$lang['id_lang']] = Tools::getValue('legend_'.(int)$lang['id_lang'], $slide->legend[$lang['id_lang']]); $fields['description'][$lang['id_lang']] = Tools::getValue('description_'.(int)$lang['id_lang'], $slide->description[$lang['id_lang']]); } return $fields; } } I think this part is the problem: /* Uploads image2 and sets slide */ $type2 = Tools::strtolower(Tools::substr(strrchr($_FILES['image2_'.$language['id_lang']]['name'], '.'), 1)); $imagesize2 = @getimagesize($_FILES['image2_'.$language['id_lang']]['tmp_name']); if (isset($_FILES['image2_'.$language['id_lang']]) && isset($_FILES['image2_'.$language['id_lang']]['tmp_name']) && !empty($_FILES['image2_'.$language['id_lang']]['tmp_name']) && !empty($imagesize2) && in_array( Tools::strtolower(Tools::substr(strrchr($imagesize2['mime'], '/'), 1)), array( 'jpg', 'gif', 'jpeg', 'png' ) ) && in_array($type2, array('jpg', 'gif', 'jpeg', 'png')) ) { $temp_name2 = tempnam(_PS_TMP_IMG_DIR_, 'PS'); $salt2 = sha1(microtime()); if ($error = ImageManager::validateUpload($_FILES['image2_'.$language['id_lang']])) $errors[] = $error; elseif (!$temp_name2 || !move_uploaded_file($_FILES['image2_'.$language['id_lang']]['tmp_name'], $temp_name2)) return false; elseif (!ImageManager::resize($temp_name2, dirname(__FILE__).'/images/'.$salt2.'_'.$_FILES['image2_'.$language['id_lang']]['name'], null, null, $type2)) $errors[] = $this->displayError($this->l('An error occurred during the image2 upload process.')); if (isset($temp_name2)) @unlink($temp_name2); $slide2->image2[$language['id_lang']] = $salt2.'_'.$_FILES['image2_'.$language['id_lang']]['name']; } elseif (Tools::getValue('image2_old_'.$language['id_lang']) != '') $slide2->image2[$language['id_lang']] = Tools::getValue('image2_old_'.$language['id_lang']);
  11. Hello! I am using PS 1.6.0.8 (theme: default-bootstrap) and I want to see the product rating stars when a user adds a comment either as a GUEST / USER. Right now the stars are not showing (please see img 1) however in the "productcomments.tpl" i can see there is something that has to do with the stars: {if $criterions|@count > 0} <ul id="criterions_list"> {foreach from=$criterions item='criterion'} <li> <label>{$criterion.name|escape:'html':'UTF-8'}:</label> <div class="star_content"> <input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|round}]" value="1" /> <input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|round}]" value="2" /> <input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|round}]" value="3" checked="checked" /> <input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|round}]" value="4" /> <input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|round}]" value="5" /> </div> <div class="clearfix"></div> </li> {/foreach} </ul> {/if} So, how to enable stars? There is something from Admin panel, or I need a code modification? Thank you!!!
  12. http://www.prestasho...to-reload-them/ http://www.prestasho...to-reload-them/ ... godaddy changed something in their configuraiton.... Thank you for those links, after reading it, and nothing solved my problem, I guess its a hosting problem... Is there a way to get it fixed through php.ini?
  13. Hello, I am using PS 1.5.6.2 - this error is poping up on product page, ADD/Edit. Before this didnt show up. Some tabs was not loaded correctly. Would you like to reload them? If i open console I can see there are few errors, please see PRINTSCREEN bellow. I tried many things like mode dev > true /* Debug only */ define('_PS_MODE_DEV_', true); I cleared smarty cache all this did not help. Please help!
  14. Hello, Never thought of this question before, till now, when a new client order to create online store for hand-made accessories. Hand-made 99% of items are unique, so stock amount will always be 1 item only. The problem is what if two or more customers will add the same product to cart and will go to checkout? I made this test, and both could confirm the order, although in back office the last order (that was by 10 seconds latter) got auto status "BACKORDER". But the payment was selected "Cash on delivery" what if the customers will select pay with credit card using paypal service, or skrill? This could be a problem to get the money back to the customer.... and also a bad mood for the last costumer. How about keeping happy costumer after such "Sorry but we dont have this item anymore, you where late by 10 sec. " I think it should be a filter when adding to cart a product, like if its last item and some one adds to cart first, other costumers should not be able to add this item to cart. Even if a differce in time will be 0.3 sec. Who have managed to find a solution to this problem, please share your experiences. Thank you!
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More