Jump to content

fransjaeger

Members
  • Posts

    164
  • Joined

  • Last visited

1 Follower

Profile Information

  • Location
    Denmark
  • Activity
    User/Merchant

Recent Profile Visitors

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

fransjaeger's Achievements

Newbie

Newbie (1/14)

42

Reputation

3

Community Answers

  1. I did it this way: File: /override/controllers/front/PageNotFoundController.php Code: class PageNotFoundController extends PageNotFoundControllerCore { public function initContent() { parent::initContent(); header('HTTP/1.1 301 Moved Permanently'); Tools::redirect('index.php'); } } Dont forget to delete cache/your class_index.php file after you put file in override folder. A new file will automatically be generated next time you visit site
  2. Hi. I have exactly the same wish. I think I can find a way to do this, are You still looking for this?
  3. Hi Naoto Did You find a user friendly way to fix this? I made a simple hack using javascript. But its not as good as i would like it to be. I want the exact same as you do.
  4. I have been trying to find a solution and maybe I came up with a solution good for both customer and shop owner Just on soldout (if product is allowed to sell on soldout) warn customer at checkout that this order is a "we'll ship it when we got it" order. for that reason we give a bit discount, but only if customer accept that order might be cancelled and we will inform customer with a daily status update by email. I allready have a smart automatic order handling system (which I build myself), which can send the daily mail untill its back in stock in right amount, then it can send a message that product is now in stock (in right amount) and we'll send it asap. and then order is treated like all other orders (automatically off course ) How do you like this ?
  5. Hi i spent some days trying to get GA tracking working on 1.6.0.9 after much debugging i found out that the reason i didnt have any transactions was that i made a small mistake in a override i override OrderConfirmationController::initContent() i use to public function initContent() { parent::initContent(); $this->context->smarty->assign(array( 'is_guest' => $this->context->customer->is_guest, 'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn() )); .... } and now I changed to public function initContent() { FrontController::initContent(); $this->context->smarty->assign(array( 'is_guest' => $this->context->customer->is_guest, 'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn() )); .... } $this->displayOrderConfirmation() should only be triggered once and ganalytics module was triggered twice. the second time sending back no value. hence nothing happened. Conclusion - be carefull when overriding to do it correctly https://github.com/PrestaShop/ganalytics/issues/88 I also experienced som problems with this module when I turned on minify and compress and move JS to bottom. but i managed to fix them as well.
  6. I think I might have found the bug after spending many hours envestigating PS 1.6.0.9 replaced "break;" with "continue;" I made contrib here I made this override override/classes/stock/StockManager.php <?php /* * override Michael Hjulskov */ class StockManager extends StockManagerCore { public function removeProduct($id_product, $id_product_attribute = null, Warehouse $warehouse, $quantity, $id_stock_mvt_reason, $is_usable = true, $id_order = null) { $return = array(); if (!Validate::isLoadedObject($warehouse) || !$quantity || !$id_product) return $return; if (!StockMvtReason::exists($id_stock_mvt_reason)) $id_stock_mvt_reason = Configuration::get('PS_STOCK_MVT_DEC_REASON_DEFAULT'); $context = Context::getContext(); // Special case of a pack if (Pack::isPack((int)$id_product)) { // Gets items $products_pack = Pack::getItems((int)$id_product, (int)Configuration::get('PS_LANG_DEFAULT')); // Foreach item foreach ($products_pack as $product_pack) { $pack_id_product_attribute = Product::getDefaultAttribute($product_pack->id, 1); if ($product_pack->advanced_stock_management == 1) $this->removeProduct($product_pack->id, $pack_id_product_attribute, $warehouse, $product_pack->pack_quantity * $quantity, $id_stock_mvt_reason, $is_usable, $id_order); } } else { // gets total quantities in stock for the current product $physical_quantity_in_stock = (int)$this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), false); $usable_quantity_in_stock = (int)$this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), true); // check quantity if we want to decrement unusable quantity if (!$is_usable){ $quantity_in_stock = $physical_quantity_in_stock - $usable_quantity_in_stock; } else { $quantity_in_stock = $usable_quantity_in_stock; } // checks if it's possible to remove the given quantity if ($quantity_in_stock < $quantity) return $return; $stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id); $stock_collection->getAll(); // check if the collection is loaded if (count($stock_collection) <= 0) return $return; $stock_history_qty_available = array(); $mvt_params = array(); $stock_params = array(); $quantity_to_decrement_by_stock = array(); $global_quantity_to_decrement = $quantity; // switch on MANAGEMENT_TYPE switch ($warehouse->management_type) { // case CUMP mode case 'WA': // There is one and only one stock for a given product in a warehouse in this mode $stock = $stock_collection->current(); $mvt_params = array( 'id_stock' => $stock->id, 'physical_quantity' => $quantity, 'id_stock_mvt_reason' => $id_stock_mvt_reason, 'id_order' => $id_order, 'price_te' => $stock->price_te, 'last_wa' => $stock->price_te, 'current_wa' => $stock->price_te, 'id_employee' => $context->employee->id, 'employee_firstname' => $context->employee->firstname, 'employee_lastname' => $context->employee->lastname, 'sign' => -1 ); $stock_params = array( 'physical_quantity' => ($stock->physical_quantity - $quantity), 'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $quantity) : $stock->usable_quantity) ); // saves stock in warehouse $stock->hydrate($stock_params); $stock->update(); // saves stock mvt $stock_mvt = new StockMvt(); $stock_mvt->hydrate($mvt_params); $stock_mvt->save(); $return[$stock->id]['quantity'] = $quantity; $return[$stock->id]['price_te'] = $stock->price_te; break; case 'LIFO': case 'FIFO': // for each stock, parse its mvts history to calculate the quantities left for each positive mvt, // according to the instant available quantities for this stock foreach ($stock_collection as $stock) { $left_quantity_to_check = $stock->physical_quantity; if ($left_quantity_to_check <= 0) continue; $resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->query(' SELECT sm.`id_stock_mvt`, sm.`date_add`, sm.`physical_quantity`, IF ((sm2.`physical_quantity` is null), sm.`physical_quantity`, (sm.`physical_quantity` - SUM(sm2.`physical_quantity`))) as qty FROM `'._DB_PREFIX_.'stock_mvt` sm LEFT JOIN `'._DB_PREFIX_.'stock_mvt` sm2 ON sm2.`referer` = sm.`id_stock_mvt` WHERE sm.`sign` = 1 AND sm.`id_stock` = '.(int)$stock->id.' GROUP BY sm.`id_stock_mvt` ORDER BY sm.`date_add` DESC' ); while ($row = Db::getInstance()->nextRow($resource)) { // break - in FIFO mode, we have to retreive the oldest positive mvts for which there are left quantities if ($warehouse->management_type == 'FIFO') if ($row['qty'] == 0) continue; // Michael Hjulskov - here it was originally: break; // converts date to timestamp $date = new DateTime($row['date_add']); $timestamp = $date->format('U'); // history of the mvt $stock_history_qty_available[$timestamp] = array( 'id_stock' => $stock->id, 'id_stock_mvt' => (int)$row['id_stock_mvt'], 'qty' => (int)$row['qty'] ); // break - in LIFO mode, checks only the necessary history to handle the global quantity for the current stock if ($warehouse->management_type == 'LIFO') { $left_quantity_to_check -= (int)$row['physical_quantity']; if ($left_quantity_to_check <= 0) break; } } } if ($warehouse->management_type == 'LIFO') // orders stock history by timestamp to get newest history first krsort($stock_history_qty_available); else // orders stock history by timestamp to get oldest history first ksort($stock_history_qty_available); // checks each stock to manage the real quantity to decrement for each of them foreach ($stock_history_qty_available as $entry) { if ($entry['qty'] >= $global_quantity_to_decrement) { $quantity_to_decrement_by_stock[$entry['id_stock']][$entry['id_stock_mvt']] = $global_quantity_to_decrement; $global_quantity_to_decrement = 0; } else { $quantity_to_decrement_by_stock[$entry['id_stock']][$entry['id_stock_mvt']] = $entry['qty']; $global_quantity_to_decrement -= $entry['qty']; } if ($global_quantity_to_decrement <= 0) break; } // for each stock, decrements it and logs the mvts foreach ($stock_collection as $stock) { if (array_key_exists($stock->id, $quantity_to_decrement_by_stock) && is_array($quantity_to_decrement_by_stock[$stock->id])) { $total_quantity_for_current_stock = 0; foreach ($quantity_to_decrement_by_stock[$stock->id] as $id_mvt_referrer => $qte) { $mvt_params = array( 'id_stock' => $stock->id, 'physical_quantity' => $qte, 'id_stock_mvt_reason' => $id_stock_mvt_reason, 'id_order' => $id_order, 'price_te' => $stock->price_te, 'sign' => -1, 'referer' => $id_mvt_referrer, 'id_employee' => $context->employee->id ); // saves stock mvt $stock_mvt = new StockMvt(); $stock_mvt->hydrate($mvt_params); $stock_mvt->save(); $total_quantity_for_current_stock += $qte; } $stock_params = array( 'physical_quantity' => ($stock->physical_quantity - $total_quantity_for_current_stock), 'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $total_quantity_for_current_stock) : $stock->usable_quantity) ); $return[$stock->id]['quantity'] = $total_quantity_for_current_stock; $return[$stock->id]['price_te'] = $stock->price_te; // saves stock in warehouse $stock->hydrate($stock_params); $stock->update(); } } break; } } // if we remove a usable quantity, exec hook if ($is_usable) Hook::exec('actionProductCoverage', array( 'id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'warehouse' => $warehouse ) ); return $return; } }
  7. Hi I have seen some posts regarding double quantity on updating received products. Also see here: https://www.prestashop.com/forums/topic/316173-advanced-stock-man-and-supply-order-broken-in-16/ I might have an idea why this happens for some. Be aware if you override AdminSupplyOrdersController::postProcess() to end it with AdminController::postProcess(); in stead of parent::postProcess(); as that will prevent it from being loaded "twice" hope it helps
  8. It works for me THANX class Supplier extends SupplierCore { /** @var string Email */ public $email; public static $definition = array( 'table' => 'supplier', 'primary' => 'id_supplier', 'multilang' => true, 'fields' => array( 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), // added email to supplier 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => false, 'size' => 128), // END added email to supplier 'active' => array('type' => self::TYPE_BOOL), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), // Lang fields 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), ), ); public function __construct($id = null, $id_lang = null) { parent::__construct($id, $id_lang); } /** * Return email from supplier id * @param integer $id_supplier Supplier ID * @return string email */ public static function getEmailById($id_supplier) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `email` FROM `'._DB_PREFIX_.'supplier` WHERE `id_supplier` = '.(int)$id_supplier); } }
  9. I have simular need to merge two customers. (Sometimes customers do weird things...)
  10. Yes i still have this issue present on my 1.6.0.9 and gladly receive advise or instructions how i can fix. I also experience issue with adv stock management when adding new products to order, it messes up the quantity. Help is more than welcome
  11. Hi again this is how i do it, and this works with minifying JS and HTML and Moving JS/CSS to bottom. Im showing the scripts inline and not moving them or changing them, if i just do the data-keepinline="true" trick override/classes/Media.php Class Media extends MediaCore { public static function deferScript($matches) { if (!is_array($matches)) return false; $inline = ''; if (isset($matches[0])) $original = trim($matches[0]); if (isset($matches[1])) $inline = trim($matches[1]); // prestarocket // This is an inline script, add its content to inline scripts stack then remove it from content if (!empty($inline) && preg_match('/<\s*script(?!.*data-keepinline)[^>]*>/ims', $original) !== 0 && Media::$inline_script[] = $inline) return ''; //end prestarocket // This is an external script, if it already belongs to js_files then remove it from content preg_match('/src\s*=\s*["\']?([^"\']*)[^>]/ims', $original, $results); if (array_key_exists(1, $results)) { if (substr($results[1], 0, 2) == '//') { $protocol_link = Tools::getCurrentUrlProtocolPrefix(); $results[1] = $protocol_link.ltrim($results[1], '/'); } if (in_array($results[1], Context::getContext()->controller->js_files) || in_array($results[1], Media::$inline_script_src)) return ''; } // return original string because no match was found return $original; } public static function packJSinHTML($html_content) { if (strlen($html_content) > 0) { // This is an inline script, add its content to inline scripts stack then remove it from content if (preg_match('/<\s*script(?!.*data-keepinline)[^>]*>/ims', $html_content) == 0) return str_replace(array('>/* */', '/* */</script>'), array('>/* <![CDATA[ */', ' /* ]]> */</script>'), $html_content); return parent::packJSinHTML($html_content); } return false; } } Part of my footer.tpl <script data-keepinline="true" type='text/javascript'> var google_tag_params = { ecomm_prodid: '{$product->id}{if isset($combinations) && $combinations}-1{/if}-{$lang_iso}', ecomm_pagetype: 'product', ecomm_totalvalue: '{$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)|floatval}' } ; </script> to make ganalytics module work correctly I had to also edit that fil in modules/ganalytics/ganalytics.php private function _getGoogleAnalyticsTag($back_office = false) { // added a line -> ga(\'require\', \'displayfeatures\'); // added data-keepinline="true" /* original code return ' <script type="text/javascript"> (window.gaDevIds=window.gaDevIds||[]).push(\'d6YPbH\'); (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,\'script\',\'//www.google-analytics.com/analytics.js\',\'ga\'); ga(\'create\', \''.Tools::safeOutput(Configuration::get('GA_ACCOUNT_ID')).'\', \'auto\'); ga(\'require\', \'displayfeatures\'); ga(\'require\', \'ec\'); '.($back_office ? 'ga(\'set\', \'nonInteraction\', true);' : '').' </script>'; */ return ' <script type="text/javascript" data-keepinline="true"> (window.gaDevIds=window.gaDevIds||[]).push(\'d6YPbH\'); (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,\'script\',\'//www.google-analytics.com/analytics.js\',\'ga\'); ga(\'create\', \''.Tools::safeOutput(Configuration::get('GA_ACCOUNT_ID')).'\', \'auto\'); ga(\'require\', \'ec\'); '.($back_office ? 'ga(\'set\', \'nonInteraction\', true);' : '').' </script>'; }
  12. its called to override and you do it by creating the same file in the override folder (read about it in the docs) - and actually as you can see Im "extending" in a way so that if my scrpt dont do anything, it will just do as the parent (default) function normally do.
  13. I had simular issue with 1.6.0.9 and I dont know if this helps, but it solved some of my problems with force ssl https://github.com/PrestaShop/PrestaShop/pull/3705
×
×
  • Create New...