View Single Post
  #1  
Old 04-22-2016, 07:15 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Shipping module - Offline and Online Hybrid

I'm working on a shipping module where part of the system is done using an online API and part using customer entered values.

The shipping API provides service codes for the available delivery services for a particular location and weight but not the prices. I'm entering in prices for each service manually.

The logic: In function performRequest for the shipping processor model...

1) Send the package details (collect address, delivery address, weight) to the API
2) An array is created of the returned service codes for the available services
3) Another array is created from the database for all x-cart admin enabled methods for the carrier
4) array_intersect is called on the two arrays to have service codes enabled and available

Now the bit I can't get working.. I need to get the shipping prices based on the service codes but also the weight of the item. Normally with the API systems this is calculated and price returned. For offline methods there is this code:

Code:
public function getRates($modifier, $ignoreCache = false) { $rates = array(); if ($modifier instanceof \XLite\Logic\Order\Modifier\Shipping) { // Find markups for all enabled offline shipping methods $markups = \XLite\Core\Database::getRepo('XLite\Model\Shipping\Markup') ->findMarkupsByProcessor($this->getProcessorId(), $modifier); if (!empty($markups)) { // Create shipping rates list foreach ($markups as $markup) { $rate = new \XLite\Model\Shipping\Rate(); $rate->setMethod($markup->getShippingMethod()); $rate->setBaseRate(self::PROCESSOR_DEFAULT_BASE_RATE); $rate->setMarkup($markup); $rate->setMarkupRate($markup->getMarkupValue()); $rates[] = $rate; } } } // Return shipping rates list return $rates; }

but I can't work out how to feed in my service codes and have values returned based on the weight of the item.
__________________
Core version: 5.5.xx
Reply With Quote