Jump to content

Get Shipping in CartRule.php with Cart::ONLY_SHIPPING


Recommended Posts

I am trying to modify CartRule.php.  In order to get the amount I need, I really need to be able to get just the shipping amount.  So, I add the following line to just store it in a variable:

 

$cdtShip = $context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING);
 
As soon as I do this, I get a blank page.
 
No problems at all if I do this, however:
 
$cdtShip = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
 
Any idea why the Cart::ONLY_SHIPPING is causing problems?
 
 
Thank you very much in advance.
 
Link to comment
Share on other sites

A little more info.  I figured out how to turn debug on and I get the following when making that call:

 

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 523800 bytes) in /home/XXX/shop/classes/Cart.php on line 1913

 

Why is this call doing that?

Link to comment
Share on other sites

Try this:

In that method, do something like "if ONLY SHIPPING is requested"

 

die('here I am');

 

Try placing the die(); at the beginning, moving it down in the code when you see it works.

 

Of course, you might want to run a debug backtrace to be sure you are targeting the right method call from your cartrule call

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...