Jump to content

Plexy89

Members
  • Posts

    13
  • Joined

  • Last visited

Profile Information

  • First Name
    Robert
  • Last Name
    Eliasson

Plexy89's Achievements

  1. Hi, I'd like to implement an override which is just like this one described here: http://nemops.com/lowest-price-prestashop-product-list/#.XXj6XCgzbqY Basically I would like to show the lowest custom price (As low as / from XXX), but I have no idea how to implement this in 1.7.6. Anyone who could help? I can't find any module for it either. Thanks, Robert
  2. Hi Community, I'm currently working on a test case where we will hire a carrier which ships out products within a 100km radius with different rates. I have a list of all zip codes and the shipping fee, so what I would like to do is to: Create e.g. 5 different carriers (with different fees) Show 1 out of those 5 carriers in checkout depending on their zip code Has anyone implemented a solution like this? I'm thinking of overriding the function getAvailableCarrierList, could anyone point me in the right direction or confirm I'm looking at the right one? Many thanks! Robert
  3. Thanks a lot! However, when looking at this I realize it's way over my head. Is there anyone out there who has done this or can help me out? Thanks in advance!
  4. Thanks for the reply rocky. Any idea which one to override for the "New products" tab on home? That's the only one I've got problems with right now.
  5. Hi guys, I am overriding CategoryControllerCore with a functionality which shows the "Lowest price" on the product list - e.g. if having quantity discounts. However, this override does not seem to cover the homenewproducts module - even if this one is using the product-list. And I can't get my head around it. Anyone who can help me out? Here's the CategoryController override I use. Thanks a lot in advance! class CategoryController extends CategoryControllerCore { public function initContent() { parent::initContent(); if($this->cat_products) { $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0); $id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_); $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'); $id_currency = (int)$this->context->cookie->id_currency; $id_shop = $this->context->shop->id; foreach ($this->cat_products as $key => $product) { $prices_array = array(); /* For each product, grab quantity discounts */ $quantity_discounts = SpecificPrice::getQuantityDiscounts($product['id_product'], $id_shop, $id_currency, $id_country, $id_group, null, true); /* Process quantity discounts to get the real price */ if ($quantity_discounts) { foreach ($quantity_discounts as $qkey => $discount) { if (!(float)$discount['reduction']) $price = $discount['price']; else { if ($discount['reduction_type'] == 'percentage') { $price = $product['price_without_reduction'] - ($product['price_without_reduction'] * $discount['reduction']); } else { $price = $product['price_without_reduction'] - $discount['reduction']; } } $prices_array[] = $price; } $this->cat_products[$key]['price'] = min($prices_array); $this->cat_products[$key]['qt_disc'] = true; } // end if quantity discounts $this->context->smarty->assign('products', $this->cat_products); } } } }
  6. Finally got it to work myself - sharing the code in case anyone (which I doubt ) need it. Also created a new table (shop_postnummer) which holds the Zip numbers that should be allowed to order this specific product ID. class Address extends AddressCore { protected static function getPostcodeByAddress($id_address) { $row = Db::getInstance()->getRow(' SELECT `postcode` FROM '._DB_PREFIX_.'address a WHERE a.`id_address` = '.(int)($id_address)); return $row['postcode']; } public static function getZoneById($id_address) { $postcode = self::getPostcodeByAddress($id_address); global $cookie ; $db = new mysqli(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_); $result = $db->query("SELECT b.id_product as id FROM "._DB_PREFIX_."cart a, "._DB_PREFIX_."cart_product b WHERE a.id_cart = " . (int) $cookie->id_cart . " AND a.id_cart = b.id_cart"); if($result){ while ($row = $result->fetch_object()){ $ProductIDsArray[] = $row->id; } $result->close(); } else { $ProductIDsArray[] = NULL; } $mysqli = new mysqli(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_); if ($result = $mysqli->query("SELECT * FROM "._DB_PREFIX_."postnummer where postnummer = '".$postcode."' limit 1 ")) { if($result->num_rows > 0) { $WithinRange = 1; } else { $WithinRange = 0; } } if ($WithinRange === 1) { return 1; } else { if(in_array(9, $ProductIDsArray)) { return 10; } else { return 1; } } } }
  7. Hi there, Sorry for not being clear enough - I'll try to explain better. I want the product ID's from the cart and then check if it's a specific ID (e.g. ID 987). IF ID 987 is in the cart and the customer has postal number 51252 he will be able to check out. (return 1) IF ID 987 is in the cart and the customer has postal number 11111 he won't be able to check out (return 10) IF ID 987 is NOT in the cart the customer will be able to check out no matter which postal number. (return 1) I hope this code is self-explanatory, what I want to do with this code is to replace $ProductIDs with the customer's current cart content. class Address extends AddressCore { protected static function getPostcodeByAddress($id_address) { $row = Db::getInstance()->getRow(' SELECT `postcode` FROM '._DB_PREFIX_.'address a WHERE a.`id_address` = '.(int)($id_address)); return $row['postcode']; } public static function getZoneById($id_address) { $postcode = self::getPostcodeByAddress($id_address); $ProductIDs = array(1,23,111,95,987); if (in_array($postcode, Array(51252))) { return 1; } else { if(in_array(987, $ProductIDs)) { return 10; } else { return 1; } } } }
  8. Hi there, I need a very product specific modification where a specific product ID can only be delivered to a specific range of postal codes. I've managed to override AddressCore to specify the postal codes which should be allowed and that works fine, but I need to be able to get the list of products in the cart in there as well - as it's only one product that can only be delivered to a specific range of postal codes. Here's my code this far. Many thanks in advance! class Address extends AddressCore { protected static function getPostcodeByAddress($id_address) { $row = Db::getInstance()->getRow(' SELECT `postcode` FROM '._DB_PREFIX_.'address a WHERE a.`id_address` = '.(int)($id_address)); return $row['postcode']; } public static function getZoneById($id_address) { $postcode = self::getPostcodeByAddress($id_address); $products = $params['cart']->getProducts(true); if (in_array($postcode, Array(51252)) ) //The ZIP codes which will be allowed. To do: Add in && Cart Product ID == XXX return 1; else return 10; //This doesn't exist so it will block the customer from ordering if it doesn't have a ZIP in the above range. } }
  9. Hi guys, I am overriding CategoryControllerCore with a functionality which shows the "Lowest price" on the product list - e.g. if having quantity discounts. However, this override does not seem to cover the homenewproducts module - even if this one is using the product-list. And I can't get my head around it. Anyone who can help me out? Here's the CategoryController override I use. Thanks a lot in advance! class CategoryController extends CategoryControllerCore { public function initContent() { parent::initContent(); if($this->cat_products) { $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0); $id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_); $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'); $id_currency = (int)$this->context->cookie->id_currency; $id_shop = $this->context->shop->id; foreach ($this->cat_products as $key => $product) { $prices_array = array(); /* For each product, grab quantity discounts */ $quantity_discounts = SpecificPrice::getQuantityDiscounts($product['id_product'], $id_shop, $id_currency, $id_country, $id_group, null, true); /* Process quantity discounts to get the real price */ if ($quantity_discounts) { foreach ($quantity_discounts as $qkey => $discount) { if (!(float)$discount['reduction']) $price = $discount['price']; else { if ($discount['reduction_type'] == 'percentage') { $price = $product['price_without_reduction'] - ($product['price_without_reduction'] * $discount['reduction']); } else { $price = $product['price_without_reduction'] - $discount['reduction']; } } $prices_array[] = $price; } $this->cat_products[$key]['price'] = min($prices_array); $this->cat_products[$key]['qt_disc'] = true; } // end if quantity discounts $this->context->smarty->assign('products', $this->cat_products); } } } }
×
×
  • Create New...