Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 15
Edit the shipping price on an order? 
 
wjcstp
Jr. Member
 
Total Posts:  30
Joined:  2008-11-11
 

Thanks, szotyi, that’s super helpful. For the site i’m working on, only certain products need special quotes, so i think i’ll make an alternate shipping method to handle them (tagging them with a flat rate price might lead to confusion), but this will save me a lot of time.

The main thing i can’t see now is the best way to complete the order. The customer will need to approve the quote, so it would be ideal if the order could be stored as a quote in the shopping cart, then the customer completes the checkout after seeing the quote, but there’s no way to see a quote on the admin side without making it an order. As it is, the order would have to be fully completed but left pending (card not charged), and approval would have to be done by email. Usable, but not as friendly as it could be.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sktung
Jr. Member
 
Total Posts:  15
Joined:  2008-09-25
 

Szotyi,

Great solution! Any idea how to do a similar function for entering a custom tax amount? We dropship many products and are unavailable to calculate taxes accurately until everything runs through the warehouse.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

I am having a problem with this fix regarding these lines:

$address->setShippingAmount(str_replace("custom-shipping","",$method));
$address->setBaseShippingAmount($rate->getPrice());

In Magento, our customers are being charged the correct amount on orders. In our payment gateway, I can see that we are actually charging them a different amount. We are charging them the price if the first shipping option is selected. Apparently, Authorize.net looks at the base grand total.

I believe the simple fix for this is to change the above code to this:

$address->setShippingAmount(str_replace("custom-shipping","",$method));
$address->setBaseShippingAmount(str_replace("custom-shipping","",$method));
 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

This works very well for me, thank you.  cool smile In my case I only need the custom shipping rate for phone orders, so there is no need to cancel an existing order.

Just for the hell of it, I decided to spruce up the form a bit so it looks more “Magento like”.  The html may or may not be proper, but it looks good and works for me.  I’ve attached a screenshot of what it looks like.  To do this, you’ll want to place this code after the second <?php endforeach; ?>, which should be on line 62.  I prefer to have the custom shipping form be after all other shipping methods, but you can place it wherever you like.  I also changed “12345” to “custom-shipping”, so the other code should be changed accordingly if you do the same.

<dt><br/><hr/><br/></dt>
<
dd>
    <
p><strong><?php echo $this->__('Custom Shipping Rate:'); ?></strong>&nbsp;&nbsp;<input id="custom-shipment-method" type="text" style="width: 100px;" />&nbsp;&nbsp;<button id="custom-shipping-button" type="button" class="scalable " onclick="order.setShippingMethod('custom-shipping'+document.getElementById('custom-shipment-method').value)"><span>Save</span></button></p>
    <
ul class="messages">
        <
li class="notice-msg"><?php echo $this->__('Note: This will override any shipping method selected above.'); ?></li>
    </
ul>
</
dd>

Edit:  Looks like the code is wrapping to more than one line.  Everything between <p> and </p> should be on one line and the same with the <li> and </li>

Image Attachments
custom-shipping.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

I’m trying to extend this further by allowing a custom title to be added in addition to a custom rate.  In my case I have “Ground Shipping - 3 to 7 days” as the title.  Right now that is the only method available for customers who order online.  But anyone who calls can have the items shipped by whatever means they are willing to pay for.  I would like to allow the sales people to be able to type whatever they want to match the actual shipping method, such as “Overnight”.  There is a function called “setShippingDescription()” that I can use within Shipping.php to set the title to whatever I want.  That’s great, but I can’t figure out how to pull information from a form to use within that function.

Szotyi’s solution uses the javascript function setShippingMethod() to set the custom shipping rate.  But there is no equivalent javascript function for the description.  I have an idea that might work, but I’m not quite there yet.  I will post my findings as soon as I have something.

 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

Ignore this method.  Please use this instead.

I have it figured out now.  Much thanks to szotyi for getting this started.  grin

1. /app/design/adminhtml/default/default/template/sales/order/create/shipping/method/form.phtml

After the second <?php endforeach; ?> (should be line 62)
Insert this:

<dt><br/><hr/><br/></dt>
        <
dd>
            <
p><strong><?php echo $this->__('Custom Shipping Rate:'); ?></strong>&nbsp;&nbsp;<input id="custom-shipment-rate" type="text" style="width: 100px;" /></p>
            <
p><strong><?php echo $this->__('Title:'); ?></strong>&nbsp;&nbsp;<input id="custom-shipment-title" type="text" style="width: 200px;" />&nbsp;&nbsp;<button id="custom-shipping-button" type="button" class="scalable " onclick="order.setShippingMethod('custom-shipping-rate'+document.getElementById('custom-shipment-rate').value+':custom-shipping-title'+document.getElementById('custom-shipment-title').value)"><span>Save</span></button></p>
            <
ul class="messages">
                <
li class="notice-msg"><?php echo $this->__('Note: This will override any shipping method selected above.'); ?></li>
            </
ul>
        </
dd>

2. /app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php

Find this:

if ($method{
            
foreach ($address->getAllShippingRates() as $rate{
                
if ($rate->getCode()==$method{
                    $amountPrice 
$address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
                    
$address->setShippingAmount($amountPrice);
                    
$address->setBaseShippingAmount($rate->getPrice());
                    
$address->setShippingDescription($rate->getCarrierTitle().' - '.$rate->getMethodTitle());
                    break;
                
}
            }
        }

And after that insert:

if (substr($method020)=="custom-shipping-rate"{
        $method2
="flatrate_flatrate";
        list(
$customShippingRate$customShippingDescription) = explode(":"$method);
        foreach (
$address->getAllShippingRates() as $rate{
                
if ($rate->getCode()==$method2{
                    $amountPrice 
$address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
                    
$address->setShippingAmount(str_replace("custom-shipping-rate","",$customShippingRate));
                    
$address->setBaseShippingAmount(str_replace("custom-shipping-rate","",$customShippingRate));
                    
$address->setShippingDescription(str_replace("custom-shipping-title","",$customShippingDescription));
                    break;
                
}
            }
        }

Note that if you are using table rate shipping instead of flat rate, then change $method2="flatrate_flatrate"; to $method2="tablerate_bestway";

If you are using the AuctionMaid MatrixRate extension, then use $method2="matrixrate_0"; instead.

If you need help finding out the code to use for your specific shipping method, read this.

You can check the attached pic to see what this looks like.  Notice how I put in a custom shipping title of FedEx Priority Overnight, and that will show up on the customers end as well.  Now you can label the shipping method to match exactly what you are using for that order.

Also keep in mind that it’s best to make a copy of the admin template and edit that instead.  If you do a search you should be able to find instructions on how to do that.  Also, instead of editing this file directly: /app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php I would make a copy of it and place it in /app/code/local/Mage/Sales/Model/Quote/Address/Total/Shipping.php so it doesn’t get overwritten when you do an upgrade.

Image Attachments
custom-shipping-with-title.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

I’m not sure why the code keeps wrapping, but if you just select it and do a copy/paste, it should be fine.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jonpday
Member
 
Avatar
Total Posts:  44
Joined:  2008-07-20
Adelaide, Australia
 

@ i960 - you rock.  that’s a fantastic contribution to Magento, thanks!

One question I have.  imagine that I want to be able to update the shipping cost after the submission of the order, but I want the customer to give me an indication if they want the fastest or cheapest shipping option, how would you do that?

One idea would be to customise one of the shipping methods that has multiple options (e.g. DHL with Express, Second Day, Ground, etc) and have $method2 in your code snippet point to the customised method, but that’s a fair bit of work. 

any other ideas?

JD

 
Magento Community Magento Community
Magento Community
Magento Community
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 

I’m just looking for a way to be able to edit the price of an existing shipping price (aka edit an invoice), or when creating a new order.  I only want it editable on the admin side, as the actual store uses USPS right now.  Is there a way I can do this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tandylacker
Sr. Member
 
Total Posts:  207
Joined:  2009-01-07
 
DavePit.com - 20 May 2009 06:00 AM

I’m just looking for a way to be able to edit the price of an existing shipping price (aka edit an invoice), or when creating a new order.  I only want it editable on the admin side, as the actual store uses USPS right now.  Is there a way I can do this?

Yes, but I have no idea how to… smile

I am currently seeking a solution for this by hiring a Magento developer to create a fix.  The idea is that in the Shipping Method section of the Create New Order page there should be a check box with text area for naming a custom shipping type such as ‘freight shipping’ or expedited shipping’ and then another text area to enter a value that will appear on the invoice as a price. 

I have been told it can definitely be done.  You can contact the developer of the Auctionmaid shipping extension--she knows how to accomplish this.

 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 
tandylacker - 20 May 2009 01:37 PM

Yes, but I have no idea how to… smile

I am currently seeking a solution for this by hiring a Magento developer to create a fix.  The idea is that in the Shipping Method section of the Create New Order page there should be a check box with text area for naming a custom shipping type such as ‘freight shipping’ or expedited shipping’ and then another text area to enter a value that will appear on the invoice as a price. 

I have been told it can definitely be done.  You can contact the developer of the Auctionmaid shipping extension--she knows how to accomplish this.

If I am understanding you correctly, then the modification I posted above should do exactly that.  No need to hire a developer.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tandylacker
Sr. Member
 
Total Posts:  207
Joined:  2009-01-07
 
i960 - 20 May 2009 01:47 PM

tandylacker - 20 May 2009 01:37 PM


If I am understanding you correctly, then the modification I posted above should do exactly that.  No need to hire a developer.

Yes, I don’t know what happened there… I had too many pages going… For whatever reason I found your solution above about 5 minutes after finding the post directly above…

eh…

Thanks for creating that though, that is definitely what I will use.  Good work!

 
Magento Community Magento Community
Magento Community
Magento Community
 
tandylacker
Sr. Member
 
Total Posts:  207
Joined:  2009-01-07
 

I am having an issue getting this to work…

I added the code, everything appeared.  I added a custom rate for an order with title and pressed save.  The new rate did not add to the total, but did allow me to place the order without even choosing a shipping method.  As if it had a method chosen, but the value didn’t appear.  Anyways, the custom price never showed up on the total…

I’m using the Auctionmaid shipping extension rather than flat rate or table rate.  I imagine this is my issue… What would I write instead of the two options that you offered on the shipping.php file?

 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 
tandylacker - 21 May 2009 01:25 PM

I’m using the Auctionmaid shipping extension rather than flat rate or table rate.  I imagine this is my issue… What would I write instead of the two options that you offered on the shipping.php file?

That I am not sure… I haven’t used that extension.  I probably should figure it out though because I’m considering that extension and I need to test it.

BTW, I didn’t completely write this modification, I just made some changes to what was already posted in the thread by szotyi.  Just trying to give credit where credit is due.

 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

Ok, I haven’t tested this yet, but you would use “matrixrate_0”.  However, that depends on how many shipping methods you have set up.  For instance, if you had a rate for ground shipping, and a rate for overnight and you allow your customers to select between them, then you would have both “matrixrate_0” and “matrixrate_1”.  I will try testing it, but I believe it should work by just overriding “matrixrate_0” and not worrying about what else is there.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 15