I've installed a plugin that enables a custom shipping method into my store (calculates shipping method with my postal service).
It works with any product, except those with recurring profile enabled.
I found this link http://www.magentocommerce.com/knowledge-base/entry/working-with-recurring-profiles/Magento-Knowledge-Base-Working-with-Recurring-Profiles saying:
... For products with recurring profiles, the customer can only choose
between the fixed-price shipping methods (flat, table or free) when
checking out. ...
Why there is this rule? How can I make my custom shipping method work with recurring profile products?
I've tried these plugins and both doesn't work.
https://github.com/pedro-teixeira/correios
https://github.com/willstorm/correios
Which files should I look at to edit to solve this?
To solve this you need to basically change your shipping method class in order to add this:
class Namespace_Shipping_Model_Carrier_Customrate
extends Mage_Shipping_Model_Carrier_Abstract
implements Mage_Shipping_Model_Carrier_Interface
{
protected $_code = 'my_customrate';
protected $_isFixed = true; // << THIS ONE
...
}
Related
PRESTASHOP : I'm working on a prestashoo module and I need to make the shipping list dynamic
Is there any hook to update the shipping price ?
Yes, and the right hook is extraCarrier.
It adds a new carrier to the shop and is fully configurable.
See this link for an example of usage:
https://github.com/uab-balticode/dpd-shipping-module-prestashop-lt/blob/53679ab5935965d95950fb3dc99a18c0c995697d/balticode_dpd_courier/balticode_dpd_courier.php
Or even better you can copy from official carriers modules, like the TNT Express one:
https://github.com/PrestaShop/tntcarrier/blob/675d9e8866f675968cc46eaec73d4202278d90a1/tntcarrier.php
From the source of this modules you must look for $this->registerHook('extraCarrier') in install function to regiser your hook (remember to reinstall your module after the hook insertion in your code)
and for the function definition of public function hookextraCarrier($params) where all the magic happens
Also note how the class of the module must extend CarrierModule:
class TntCarrier extends CarrierModule
You can also read the official prestashop documentation about the argument:
http://doc.prestashop.com/display/PS16/Creating+a+carrier+module
I sell two services in my Magento store. I've disabled cart and multi-page checkout. I want to sell only one service at a time. Means I want to accomplish, if customer tries to add both services to cart so the previous service should be removed.
How can I accomplish this? I've been searching this from last 5 hours.
in the file
app/code/core/Mage/Sales/Model/Quote.php
there is a method public function addProduct($product, $request = null);
you should only add $this->removeAllItems(); to be the first line in the method, like:
public function addProduct(Mage_Catalog_Model_Product $product, $request = null)
{
$this->removeAllItems(); // new code
....
}
of course, it's better idea to be overridden in the local pool.
I created custom shipping method for magento. And this method needed only for orders created programmatically from others modules.
Question: How i can to hide this method from checkout form without disabling this method in store settings?
I assume the other modules will use your shipping method from admin context; so you could do something like this:
update your collectRates method like this:
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!Mage::app()->getStore()->isAdmin())) {
return false;
}
// rest of your code
This way, you should be able to have the shipping method active but only usable in admin context.
I have setup the free shipping for specific product categories in magento by refering this blog post http://www.regularjen.com/archives/2010/06/11/free-shipping-on-a-single-item-in-magento/ . And its working fine. Now the issue is , Magento showing both free shipping & other shipping charges in shiiping reuslt.
How can i remove the those result ?
One solution might be to override the getShippingRates() method which you can find in the Mage_Checkout_Block_Onepage_Shipping_Method_Available class.
public function getShippingRates()
{
parent::getShippingRates();
if (isset($this->_rates['freeshipping'])) {
$this->_rates = array('freeshipping' => $this->_rates['freeshipping']);
}
return $this->_rates;
}
PROBLEM:
While in backend o cron task (ex. in a custom product feed generator running on user request or on a cron event), and generally out of frontend, the Mage_Catalog_Model_Product's method getFinalPrice() returns product's base price, not taking in account, for example, Magento Catalog Price Rules applicable to that product.
This means that prices exported in the generated feed are not the same as show in Magento frontend, which can easily become a problem.
So, how to obtain product's final price as show in frontend?
The SOLUTION stated by the person who asked the question only works on Admin site if you add this line towards the top:
Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_FRONTEND,Mage_Core_Model_App_Area::PART_EVENTS);
This loads the Frontend Event which takes in account of the Catalog Price Rules defined on Admin site.
Hope it helps someone in the future.
SOLUTION
Use a helper class, with the following method defined:
class My_Package_Helper_Price extends Mage_Core_Helper_Abstract {
private $_init_rule = false;
private function initRuleData($product) {
if ($this->_init_rule || empty($product)) return $this;
$productStore = Mage::getModel('core/store')->load($product->getStoreId());
if (!empty($productStore)) {
Mage::register('rule_data', new Varien_Object(array(
'store_id' => $product->getStoreId(),
'website_id' => $productStore->getWebsiteId(),
'customer_group_id' => 0, // NOT_LOGGED_IN
)));
$this->_init_rule = true;
}
return $this;
}
public function getProductFinalPrice($product) {
$this->initRuleData($product);
return $product->getFinalPrice();
}
}
Then, you can use:
Mage::helper('my_package/price')->getProductFinalPrice($product);
where $product is a loaded instance of Mage_Catalog_Model_Product class.