Jump to content

modif packagelist cart for choise specific warehouse


mohamed

Recommended Posts

classes/Cart.php around line 1619

prestashop 1.5.1 (overided)


Hello,

After change method select package list (restriction of other warehouse order)

i need know where i add code the declaration for 3 variable $warehouseregion, $warehousecity, $warehousesupplier

it's cartcontroller.php ? when i add menu the choise betwen variable $warehouseregion, $warehousecity, $warehousesupplier  page.tpl for choise

 

public function getPackageList($flush = false)
    {
        static $cache = false;
        if ($cache !== false && !$flush)
            return $cache;

        $product_list = $this->getProducts();
        // Step 1 : Get product informations (warehouse_list and carrier_list), count warehouse
        // Determine the best warehouse to determine the packages
        // For that we count the number of time we can use a warehouse for a specific delivery address
        $warehouse_count_by_address = array();
        $warehouse_carrier_list = array();

        $stock_management_active = Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT');

        foreach ($product_list as &$product)
        {
            if ((int)$product['id_address_delivery'] == 0)
                $product['id_address_delivery'] = (int)$this->id_address_delivery;

            if (!isset($warehouse_count_by_address[$product['id_address_delivery']]))
                $warehouse_count_by_address[$product['id_address_delivery']] = array();

            $product['warehouse_list'] = array();

            if ($stock_management_active &&
                ((int)$product['advanced_stock_management'] == 1 || Pack::usesAdvancedStockManagement((int)$product['id_product'])))
            {
                $warehouse_list = Warehouse::getProductWarehouseList($product['id_product'], $product['id_product_attribute'], $this->id_shop);
                if (count($warehouse_list) == 0)
                    $warehouse_list = Warehouse::getProductWarehouseList($product['id_product'], $product['id_product_attribute']);
                // Does the product is in stock ?
                // If yes, get only warehouse where the product is in stock

                $warehouse_in_stock = array();
                $manager = StockManagerFactory::getManager();

                foreach ($warehouse_list as $key => $warehouse)
                {
                    $product_real_quantities = $manager->getProductRealQuantities(
                        $product['id_product'],
                        $product['id_product_attribute'],
                        array($warehouse['id_warehouse']),
                        true
                    );

Part where i modife class cart.php

// Select Only id_warehouse   where (product_real_qte>0 AND (customer_codepostal = codepostal_warehouse_region OR city = warehouse_city OR frs = warehouse_frs ))                

if ($product_real_quantities > 0 || Pack::isPack((int)$product['id_product']) AND $warehouse['id_warehouse'] = '.$varregion.' OR $warehouse['id_warehouse'] = '.$varcity.'  OR $warehouse['id_warehouse'] = '.$varsupplier.')
                        $warehouse_in_stock[] = $warehouse;
                }

                if (!empty($warehouse_in_stock))
                {
                    $warehouse_list = $warehouse_in_stock;
                    $product['in_stock'] = true;
                }
                else
                    $product['in_stock'] = false;
            }
            else
            {
                //simulate default warehouse
                $warehouse_list = array(0);
                $product['in_stock'] = StockAvailable::getQuantityAvailableByProduct($product['id_product'], $product['id_product_attribute']) > 0;
            }

Edited by mohamed (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...