I have created my own shipping module, but problem is that collectRates function is called when user comes to shipping method step and then these prices are just shown to user. But in my case I have to use webservice to get price, and there are some options user can choose in shipping method step screen, which will affect shipping price. Price itself is calculated on other server.
So how I can set shipping price via ajax in shipping method step?
I found working solution myself. I call shipping.save() JavaScript function to update shipping methods page, then collectRates (php) function in my own shipping module is called and everything works correctly.
shipping.save();
Related
My website is using WooCommerce (Version 6.0.1) without shipping extensions as all physical products will be picked up locally or shipped within only one region, but now I want to add an e-ticket product, no shipping required, using this event ticket plugin (Version 1.1.1; Pro Version Version 1.0.7).
I created a product category named Events for the tickets and hid all shipping options for this category using this method
I have found here, and although it's working perfectly in hiding the shipping options, when I checkout I can't proceed and instead will get the following message:
No shipping method has been selected. Please double check your address, or contact us if you need any help
I'm currently setting local pickup as the only shipping option for tickets by using the aforementioned code then setting the shipping id to display:none in Additional CSS, but that isn't really what I want, especially since it will also hide the shipping options for physical products.
I have read through lots of posts here but they either only hide some of the shipping options or they just suggest the use of extensions. It'd be great if I don't have to buy a WooCommerce extension to manage shipping per product. Is there's anyway to add/eddit another function in functions.php or WooCommerce plugin file to do that? Or some way to use that line of CSS conditionally? As far as I know, CCS doesn't have if statements, and I am not sure how I can do that in php. Any help on how to disable shipping for a particular product/category so that no shipping option needs to be be selected or on how to hide shipping method on Cart and Checkout page for a particular product/category should be much appreciated, thank you.
I am looking for a way to programmatically send a specific shipping method to the bottom of the list of methods displayed on my Woocommerce store's cart page.
The method in question is the Woocommerce local pickup method. It's currently defaulting to either the top of the list, or near it (depending on the particular methods offered for the products in the cart). The other shipping methods are being pulled from 3rd party plug-ins, so woocommerce is defaulting local pickup's precedence higher than those methods.
I thought about splicing the shipping $rates array at the occurrence of the pickup method and reordering that way, but I am not sure if that's the most efficient way of doing it. I am very new to Woocommerce and PHP.
Ideally I just want the "local pickup" method to always be at the bottom of the list.
by default magento ( and this module ) show the shipping methods available only after the shipping form is filled..
but I need to show the methods on page load, before shipping infos.
Is this possible? How?
I have try so many code, but i can't implement this.
Last one, but i don't know where to put this.
$shippingAddress = $this->getQuote()->getShippingAddress();
$shippingAddress->setCountryId('UK')->setShippingMethod('matrixrate_matrixrate')-save();
I don't think it's possible to get all the shipping methods before filling in the shipping details.
In theory the shipping methods depend on the shipping details.
So even if you all the shipping methods you will get wrong prices.
And this is bad for business.
If the customer sees for example at first: Some shipping method: 5$, then he fills in his shipping address and sees: Some shipping method: 15$ there is a big chance he will stop the checkout.
But I wrote this answer so I can recommend you not to use the IWD checkout extension. Here is why.
To summarize what I answered for that question:
the extension sends your data to their servers.
if their server is offline, your checkout will probably stop working.
I am trying to change the view of shipping method in checkout page, this is what I have now:
I want to remove radio button and show free shipping if its free, otherwise I want to show flat rate, its decided by the total purchase amount.
But I am not able to find the page where I can change this. I found some files related to shipping:
/app/design/frontend/base/default/template/checkout/onepage/shipping.phtml
/app/design/frontend/base/default/template/checkout/onepage/shipping_method.phtml
but shipping method content is not coming from these files.
The available methods are rendered in /app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml
Look around line 34:
foreach ($_shippingRateGroups as $code => $_rates):
You can add your condition below that line to show free shipping or flat rate.
Edit:
Alternatively, you can override Mage_Checkout_Block_Onepage_Shipping_Method_Available::getShippingRates() method so that shipping method of your choice is displayed.
I am trying to create a custom (pickship) shipping method for magento 1.7.x.x following the instructions in this this blog after creating the shipping module. I would like to be able to change shipping cost based on the user's choice of shipping option.
Preparation:
1.) Created a form block for custom (pickship) shipping method
2.) Create a store name (can be any text) dropdown/select element with three values: store1, store2, store3.
3.) The default shipping price is set via the shipping configuration at $1.00 (just for testing purposes).
Current Status:
1.) After the required process, when I reach the selection of shipping method in the single-page checkout, I see a select element with three options and the shipping price set to the default price.
Target:
I would like the shipping cost to be updated to $10.00 if the user selects the first option, $20.00 if the user selects the second option.
My attempt:
After a few hours of googling, I made some changes in the observer model:
NameSpace_ModuleName_Model_Observer extends Varien_Object {
public function saveShippingMethod($observer) {
$request = $evt->getRequest();
$quote = $evt->getQuote();
$pickship = $request->getParam('shipping_pickship', false);
$rates = $quote->getShippingAddress()->getShippingRatesCollection();
$rate = $rates->getFirstItem();
if($pickship['select_element'] == 1) {
$rate->setPrice(10);
} elseif($pickship['select_element'] == 2) {
$rate->setPrice(20);
}
//Mage::log($rate->getPrice());
}
Question:
Am I using the right observer/method for this task? It only works for one step – once I click 'Continue' to place the order, it resets to the default price. My way of setting the delivery price may be wrong. Can you put me on the right track or suggest a solution?
If you want to code your tailored solution, you can find a nice tutorial here: Custom shipping method in Magento
Basically you should not use observers, instead you should define in your module a custom carrier with two shipping methods.
In your model, use function getAllowedMethods() to declare your shipping methods, then in function collectRates() give the rate for each shipping method.
If your main goal is to provide multiple shipping methods with different pricing, and can trust a third party module, you might try the free MatrixRate from WebShopApps
http://www.magentocommerce.com/magento-connect/webshopapps-matrixrate-1-multiple-table-rates-extension.html
There are other modules for this, but this is which I tried, and it works as I expected.