Jump to content

Amazzing

Members
  • Posts

    124
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Amazzing's Achievements

Newbie

Newbie (1/14)

27

Reputation

1

Community Answers

  1. It looks like module admin controllers depend on tabs. So if you want to activate an admin controller you have to create a corresponding tab, and if you don't want it to be included in menu, you can just hide it by setting $tab->id_parent = -1 so, first you create a file here: /controllers/admin/AdminYourModuleNameSpecialControllerName.php <?php class AdminYourModuleNameSpecialControllerNameController extends ModuleAdminController { public function __construct() { parent::__construct(); // do your stuff here } } Then you create a method for adding tab and run it on module install Something like this: public function install() { ... if (!parent::install() || !$this->addTab() ...) return false; return true; } public function addTab() { $tab = new Tab(); $tab->name = array(); foreach (Language::getLanguages() as $language) $tab->name[$language['id_lang']] = 'AdminYourModuleNameSpecialControllerName'; $tab->class_name = 'AdminYourModuleNameSpecialControllerName'; // if id_parent = -1, tab will not be visible in menu $tab->id_parent = -1; $tab->module = $this->name; if(!$tab->add()) return false; return true; } This may not be the official way of activating an admin module controller, but I didn't find any documentation on this point, so I currently use this way and it works fine.
  2. Hi everyone, I want to set a special order status from shipping module. I can actually change the status and it is visible in order history, but for some reason it is immideately updated by default one, so in order status history I see: 1) my_custom_status 2) default_status (current_state) I tried to do change order status with this code: // tried the following hooks: // hookActionValidateOrder // hookActionOrderStatusUpdate // hookActionOrderStatusPostUpdate public function hookActionOrderStatusPostUpdate($params) { ... $requires_status_update = true; $custom_order_status = 15; if ($params['newOrderStatus']->id == $custom_order_status || !$requires_status_update) return; $history = new OrderHistory(); $history->id_order = $params['id_order']; $history->changeIdOrderState($custom_order_status, $params['id_order']); ... } also tried to update order status in a different way, using same hooks as above: $order = new Order($params['id_order']); $order->setCurrentState($custom_order_status); None of these ways worked. everytime my custom order status is overriden by status set in paymentModule. So is there a way to change order status from shipping module, using hooks, without modifying payment module?
  3. According to Prestashop Validator requirements, all tpl {$variables} have to be escaped ('htmlall', 'intval', etc.). What if a variable contais HTML code, and needs to be displayed as is, without escaping any tags, quotes ar anything else? Is there any option, like |escape:'none'? Or may be there is another way to validate this kind of variables?
  4. OK, thanks for the reply. One more question, does id_reference always have to match id_carrier? In other words, can we have 2 carriers with different id-s and same reference?
  5. I am using webservice to get informations about different resources from a shop. Most of resources work fine. But 'combinations' and 'guests' return error 500. HTTP/1.1 500 Internal Server Error Server: nginx Date: Tue, 16 Sep 2014 21:22:12 GMT Content-Type: text/html; charset=utf-8 Content-Length: 0 Connection: keep-alive X-Powered-By: PHP/5.3.27 Most probably this is related to big quantities of these resources. If I access shop directly, all combinations work fine. So, it looks like there is a limit of resources, that can be transferred through Webservice. Is it possible to change that limit somehow?
  6. The default prestashop installation has 2 carriers with IDs 1,2 and same references, 1 and 2. When I create a new carrier, it gets a new ID and same reference (id=3, id_reference=3 etc.) So why do we need this reference? Where is it used?
  7. Hi everyone, I am updating a product using an ajax request. The php code is really basic: $product = new Product($id); $produc->description[$lang] = $new_description; $product->save(); ... die(Tools::jsonEncode($result)); But if for any reason product is not saved, function stops executing and I get an ajax error. For example, I have included an iframe in $new descrpiption for purpose. And I don't allow iframes in prestashop settings. So, if I call that ajax file directly from browser with same params, I can see that there is a Prestashop exception 'Property Product->description is not valid'. So, how can I catch this kind of error, and show it to user? Of course, I can validate the $new_descrtiption before saving the product. But first: in this case, validation code will be executed twice. Second: I am planning to save different fields, so a lot of validation rules have be hardcoded thus making code less adjustable to prestashop updates
  8. With error reporting OFF, the popup doesnt appear, but it looks like 'hiding the error', or may be I misunderstood your note about the empty char. Is there any way to prevent website from spawning that error when 'error reporting' is ON?
  9. You can do that on template level. No need to modify php. Here is a basic example of slider, used for a group of attributes. Group id: 6 Attribute type: Radio button go to blocklayered.tpl, find the following loop: {foreach from=$filters item=filter}. Just before ending this loop (...{/foreach}) insert the following code, modified according to your needs {if $filter.id_key == 6} <div class="yourslider_value"></div> <div class="layered_slider yourslider"></div> <script type="text/javascript"> $('#ul_layered_id_attribute_group_6').hide(); var filter = {$filter|json_encode}; var sliderVals = new Array(); var sliderMax = 0; var sliderValue = 0; for (var i in filter.values){ sliderMax++; sliderVals[sliderMax] = filter.values[i]['name']; if (filter.values[i].hasOwnProperty('checked')){ sliderValue = sliderMax; $('.yourslider_value').html(sliderVals[sliderValue]); } } $('.layered_slider.yourslider').slider({ max: sliderMax, values: [sliderValue], slide: function( event, ui ) { stopAjaxQuery(); $('#ul_layered_id_attribute_group_6 input[type="checkbox"]').each(function(i){ if (i+1 == ui.values[0]) $(this).prop('checked',true); else $(this).prop('checked',false); }) if (ui.values[0] > 0) $('.yourslider_value').html(sliderVals[ui.values[0]]); else $('.yourslider_value').html('Text when no filters are selected'); }, stop: function () { reloadContent(); }, create: function() { if (sliderValue == 0) $('.yourslider_value').html('Text when no filters are selected'); } }); </script> {/if} This is a very basic slider example, just to give you an inspiration. I used it on one of my projects. You can improve/edit/modify it according to your needs upd: tested on PS 1.5.6.0.
  10. Thanks for your reply. I am sure this is a useful educative information. But I used another approach, without overriding controller: public function getOrderShippingCost($params) { ... //error is defined as public variable $this->carrierError = $ret['errormsg']; if (no errors found) return $ret['total']; else return false; // when false is returned, carrier is not displayed, but warning message is displayed using hookDisplayHeader } public function hookDisplayHeader($params) { if (isset($this->carrierError) && Tools::getValue('controller') == 'order' && Tools::getValue('step') == '2') { //running JS do display a warning message that carrier may be available if you fix the wrong field ... } }
  11. Hello, I am working on a carrier module. Delivery price is dynamically fetched from remote server. After that price is included in order details using getOrderShippingCost() method in modulename.php. So, when I have all required fields filled correctly, everything works fine, price is calculated properly. But if there is an error in any field, for example zipcode is not found, price is just set to 0. Instead of having 0 I would like to insert a note about what field is wrong and block carrier, but not hide it. I can identify what field is wrong from response of remote server, but how do I display this information on shipping step of order process? At the moment just I use return false if there is an error. So carrier is just not shown. PS 1.5.4.1 upd Here is the basic code scheme I am using right now: public function getOrderShippingCost($params) { ... if (no errors found) return $ret['total']; else return false; // instead of return false I would need something like // Tools::displayError('Error text'), or trigger a JS event }
  12. Thanks for your reply, but it doesn't alway work the way I need. I have only one module using that hook. No matter, whether this module is enabled or disabled, Hook::getModulesFromHook(Hook::getIdByName("MyHook")) != null always returns true. However I found another way to check whether this hook is used or not. And it works just the way I need: {assign var='nameOfTheHook' value={hook h='nameOfTheHook'[spam-filter] {if $nameOfTheHook} {$nameOfTheHook} {else} smth else {/if}
  13. almost like that: if there is any module attached to this hook { display hook } else{ display something else }
  14. There is a very nice and handy way to add new hooks to Prestashop 1.5 templates: {hook h='nameOfTheHook'} But how can we check whether this hook is used or not? I need something like: {if $nameOfTheHook}{hook h='nameOfTheHook'}{/if} or {if !empty($nameOfTheHook)} {hook h='nameOfTheHook'} {else} Is that possible at all?
×
×
  • Create New...

Important Information

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