Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Shipping module - Offline and Online Hybrid

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 04-22-2016, 07:15 AM
 
xgarb xgarb is online now
 

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
  #2  
Old 04-25-2016, 08:35 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Shipping module - Offline and Online Hybrid

In this case findMarkupsByProcessor() is the method that filters rates by weight, amount, etc. It returns only the rates that match the order.

The actual filter logic happens there:
\XLite\Model\Repo\Shipping\Markup::addMarkupCondit ion()
It adds MySQL conditions that drop non-matching rates from the result.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:02 PM.

   

 
X-Cart forums © 2001-2020