Programmatically add shipping cost to the quote
I have the following code and I have searched and searched and can not find the answer. Everything I find on these forums tell me to do what I have already done but the shipping cost will just not save on the quote.
Here is how I call the quote,
$quote = Mage::getModel('sales/quote')->load($QID);
I then add all my items and customer details etc and then I add the shipping details like so,
$delCost = 10 //// I set this as a variable
$delTitle = 'MY CUSTOM TITLE' //// I set this as a variable
$quote->getShippingAddress()->setShippingDescription($delTitle); /// THIS IS WORKING
$quote->getShippingAddress()->setShippingAmount($delCost);
$quote->getShippingAddress()->setBaseShippingAmount($delCost);
$quote->getShippingAddress()->setData('price',$delCost);
$quote->getShippingAddress()->setRate($delCost);
$quote->getShippingAddress()->setCost($delCost);
$quote->getShippingAddress()->setCountry('GB');
$quote->save();
When I retrieve the quote I can see it has saved the shipping description but it doesn't save the cost .
This is stand alone code that I am using where I create a quote programmatically for a point of sale system I am creating. Any help would be most appreciated as I have followed every tutorial I can find and I know its probably something simple I am missing.
magento-1.9
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have the following code and I have searched and searched and can not find the answer. Everything I find on these forums tell me to do what I have already done but the shipping cost will just not save on the quote.
Here is how I call the quote,
$quote = Mage::getModel('sales/quote')->load($QID);
I then add all my items and customer details etc and then I add the shipping details like so,
$delCost = 10 //// I set this as a variable
$delTitle = 'MY CUSTOM TITLE' //// I set this as a variable
$quote->getShippingAddress()->setShippingDescription($delTitle); /// THIS IS WORKING
$quote->getShippingAddress()->setShippingAmount($delCost);
$quote->getShippingAddress()->setBaseShippingAmount($delCost);
$quote->getShippingAddress()->setData('price',$delCost);
$quote->getShippingAddress()->setRate($delCost);
$quote->getShippingAddress()->setCost($delCost);
$quote->getShippingAddress()->setCountry('GB');
$quote->save();
When I retrieve the quote I can see it has saved the shipping description but it doesn't save the cost .
This is stand alone code that I am using where I create a quote programmatically for a point of sale system I am creating. Any help would be most appreciated as I have followed every tutorial I can find and I know its probably something simple I am missing.
magento-1.9
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have the following code and I have searched and searched and can not find the answer. Everything I find on these forums tell me to do what I have already done but the shipping cost will just not save on the quote.
Here is how I call the quote,
$quote = Mage::getModel('sales/quote')->load($QID);
I then add all my items and customer details etc and then I add the shipping details like so,
$delCost = 10 //// I set this as a variable
$delTitle = 'MY CUSTOM TITLE' //// I set this as a variable
$quote->getShippingAddress()->setShippingDescription($delTitle); /// THIS IS WORKING
$quote->getShippingAddress()->setShippingAmount($delCost);
$quote->getShippingAddress()->setBaseShippingAmount($delCost);
$quote->getShippingAddress()->setData('price',$delCost);
$quote->getShippingAddress()->setRate($delCost);
$quote->getShippingAddress()->setCost($delCost);
$quote->getShippingAddress()->setCountry('GB');
$quote->save();
When I retrieve the quote I can see it has saved the shipping description but it doesn't save the cost .
This is stand alone code that I am using where I create a quote programmatically for a point of sale system I am creating. Any help would be most appreciated as I have followed every tutorial I can find and I know its probably something simple I am missing.
magento-1.9
I have the following code and I have searched and searched and can not find the answer. Everything I find on these forums tell me to do what I have already done but the shipping cost will just not save on the quote.
Here is how I call the quote,
$quote = Mage::getModel('sales/quote')->load($QID);
I then add all my items and customer details etc and then I add the shipping details like so,
$delCost = 10 //// I set this as a variable
$delTitle = 'MY CUSTOM TITLE' //// I set this as a variable
$quote->getShippingAddress()->setShippingDescription($delTitle); /// THIS IS WORKING
$quote->getShippingAddress()->setShippingAmount($delCost);
$quote->getShippingAddress()->setBaseShippingAmount($delCost);
$quote->getShippingAddress()->setData('price',$delCost);
$quote->getShippingAddress()->setRate($delCost);
$quote->getShippingAddress()->setCost($delCost);
$quote->getShippingAddress()->setCountry('GB');
$quote->save();
When I retrieve the quote I can see it has saved the shipping description but it doesn't save the cost .
This is stand alone code that I am using where I create a quote programmatically for a point of sale system I am creating. Any help would be most appreciated as I have followed every tutorial I can find and I know its probably something simple I am missing.
magento-1.9
magento-1.9
edited Aug 6 '18 at 12:48
Teja Bhagavan Kollepara
2,94841847
2,94841847
asked Nov 23 '16 at 23:50
Barry ConnollyBarry Connolly
234414
234414
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
It may be that you have to add the shipping method as well. I've used the following code for free shipping before which works. You may need to add in your extra bits.
$quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('freeshipping_freeshipping');
$quote->collectTotals();
$quote->save();
Just giving it a try think you may be right
– Barry Connolly
Nov 24 '16 at 22:01
add a comment |
You can add shipping cost to the quote programmatically by creating a new module for shipping follow below reference link.
https://inchoo.net/magento/custom-shipping-method-in-magento/
edit a function mentioned in the above link:
_getStandardRate()
$delCost = 10
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod('large');
$rate->setMethodTitle('Standard delivery');
$rate->setPrice($delCost);
$rate->setCost($delCost);
return $rate;
And set your price in the setPrice(your price )
and setCost
functions
Also set this new shipping method on the quote.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f147249%2fprogrammatically-add-shipping-cost-to-the-quote%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It may be that you have to add the shipping method as well. I've used the following code for free shipping before which works. You may need to add in your extra bits.
$quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('freeshipping_freeshipping');
$quote->collectTotals();
$quote->save();
Just giving it a try think you may be right
– Barry Connolly
Nov 24 '16 at 22:01
add a comment |
It may be that you have to add the shipping method as well. I've used the following code for free shipping before which works. You may need to add in your extra bits.
$quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('freeshipping_freeshipping');
$quote->collectTotals();
$quote->save();
Just giving it a try think you may be right
– Barry Connolly
Nov 24 '16 at 22:01
add a comment |
It may be that you have to add the shipping method as well. I've used the following code for free shipping before which works. You may need to add in your extra bits.
$quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('freeshipping_freeshipping');
$quote->collectTotals();
$quote->save();
It may be that you have to add the shipping method as well. I've used the following code for free shipping before which works. You may need to add in your extra bits.
$quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('freeshipping_freeshipping');
$quote->collectTotals();
$quote->save();
edited Aug 6 '18 at 12:47
Teja Bhagavan Kollepara
2,94841847
2,94841847
answered Nov 24 '16 at 9:10
PaulPaul
1,10411325
1,10411325
Just giving it a try think you may be right
– Barry Connolly
Nov 24 '16 at 22:01
add a comment |
Just giving it a try think you may be right
– Barry Connolly
Nov 24 '16 at 22:01
Just giving it a try think you may be right
– Barry Connolly
Nov 24 '16 at 22:01
Just giving it a try think you may be right
– Barry Connolly
Nov 24 '16 at 22:01
add a comment |
You can add shipping cost to the quote programmatically by creating a new module for shipping follow below reference link.
https://inchoo.net/magento/custom-shipping-method-in-magento/
edit a function mentioned in the above link:
_getStandardRate()
$delCost = 10
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod('large');
$rate->setMethodTitle('Standard delivery');
$rate->setPrice($delCost);
$rate->setCost($delCost);
return $rate;
And set your price in the setPrice(your price )
and setCost
functions
Also set this new shipping method on the quote.
add a comment |
You can add shipping cost to the quote programmatically by creating a new module for shipping follow below reference link.
https://inchoo.net/magento/custom-shipping-method-in-magento/
edit a function mentioned in the above link:
_getStandardRate()
$delCost = 10
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod('large');
$rate->setMethodTitle('Standard delivery');
$rate->setPrice($delCost);
$rate->setCost($delCost);
return $rate;
And set your price in the setPrice(your price )
and setCost
functions
Also set this new shipping method on the quote.
add a comment |
You can add shipping cost to the quote programmatically by creating a new module for shipping follow below reference link.
https://inchoo.net/magento/custom-shipping-method-in-magento/
edit a function mentioned in the above link:
_getStandardRate()
$delCost = 10
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod('large');
$rate->setMethodTitle('Standard delivery');
$rate->setPrice($delCost);
$rate->setCost($delCost);
return $rate;
And set your price in the setPrice(your price )
and setCost
functions
Also set this new shipping method on the quote.
You can add shipping cost to the quote programmatically by creating a new module for shipping follow below reference link.
https://inchoo.net/magento/custom-shipping-method-in-magento/
edit a function mentioned in the above link:
_getStandardRate()
$delCost = 10
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod('large');
$rate->setMethodTitle('Standard delivery');
$rate->setPrice($delCost);
$rate->setCost($delCost);
return $rate;
And set your price in the setPrice(your price )
and setCost
functions
Also set this new shipping method on the quote.
edited Dec 21 '18 at 8:46
Ashish Viradiya
558420
558420
answered Aug 6 '18 at 11:53
Mohd ZahidMohd Zahid
325
325
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f147249%2fprogrammatically-add-shipping-cost-to-the-quote%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown