1

Here's what i want to accomplish. I'm making a lot of changes to the Multishipping functionality in magento and i want to be able to calculate the shipping rates - prices for each website.

Meaning, i have 2 websites.

Buying 2 items from website A and 1 item from website B.

I've made it so that the items are split into different addresses. Now we've made it into the screen where you have to select shipping methods. But the carriers that are being displayed are only from the website that i'm currently running on.

The carriers are being retrieved from

/**
 *
 * magento\module-quote\Model\Quote\Address.php
 *
 * Retrieve all grouped shipping rates
 * 
 * @return array
 */
public function getGroupedAllShippingRates()
{
    $rates = [];
    foreach ($this->getShippingRatesCollection() as $rate) {
        if (!$rate->isDeleted() && $this->_carrierFactory->get($rate->getCarrier())) {
            if (!isset($rates[$rate->getCarrier()])) {
                $rates[$rate->getCarrier()] = [];
            }

            $rates[$rate->getCarrier()][] = $rate;
            $rates[$rate->getCarrier()][0]->carrier_sort_order = $this->_carrierFactory->get(
                $rate->getCarrier()
            )->getSortOrder();
        }
    }
    uasort($rates, [$this, '_sortRates']);

    return $rates;
}

I've tried adding changing the store in the quote and the address but when i pick a store outside from the website i'm on i get Store not found.

Is there any way to calculate the shipping rates and carriers based on a different website that i'm currently on ?

enter image description here

UPDATED ANSWER Ended up using the Webmatrix Rates extension but made some modifications on it to match my needs.

  • I am new in Magento 2 does two website means two different stores under same website (same domain) – inrsaurabh Apr 18 '17 at 17:17
  • Each store may or may not have a different domain. Meaning 2 different websites, both with 1 store in them and 2 views. Attaching screen above – LefterisL Apr 18 '17 at 17:21
  • Even a tip in Magento 1 would help – LefterisL Apr 18 '17 at 17:24
  • thanks brother , i never thought about this . This question is interesting at least for me . I hope some one can answer . But still i am confused how i can access other websites store data (is there any inbuilt functionality in Magento 2 to access different Magento websites) or you first make a connection to other database then programmatically trying to do this ? Sorry if i asking stupid questions. I can only upvote this question. – inrsaurabh Apr 18 '17 at 17:27
  • All the websites are within the same Magento installation ( 1 database ). – LefterisL Apr 18 '17 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.