Advertisement
Guest User

Untitled

a guest
Jul 30th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. /**
  2. * Retrieve all grouped shipping rates
  3. *
  4. * @return array
  5. */
  6. public function getGroupedAllShippingRates()
  7. {
  8. $rates = array();
  9.  
  10. /* added code */
  11. $found = false;
  12. $collection = $this->getShippingRatesCollection();
  13. foreach ($collection as $rate) {
  14. if (!$rate->isDeleted() && $rate->getCarrierInstance()) {
  15. if ($rate->getCarrier() == "freeshipping" /*&& $rate->getMethod() == "freeshipping"*/) {
  16. $found = true;
  17. }
  18. }
  19.  
  20. }
  21.  
  22. foreach ($collection as $rate) {
  23. if (!$rate->isDeleted() && $rate->getCarrierInstance()) {
  24. if (!isset($rates[$rate->getCarrier()])) {
  25. $rates[$rate->getCarrier()] = array();
  26. }
  27.  
  28. /* added code */
  29. $storeId = $this->getQuote()->getStoreId();
  30. switch ($storeId) {
  31. case 1: // my store -> default store
  32. // any order that is not free shipping -> ignore
  33. if ($found && !($rate->getCarrier() == "freeshipping" /*&& $rate->getMethod() == "freeshipping"*/)) {
  34. continue 2;
  35. }
  36. break;
  37. }
  38.  
  39. $rates[$rate->getCarrier()][] = $rate;
  40. $rates[$rate->getCarrier()][0]->carrier_sort_order = $rate->getCarrierInstance()->getSortOrder();
  41. }
  42. }
  43. uasort($rates, array($this, '_sortRates'));
  44. return $rates;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement