Magento Flat Rate Shipping only if chart is over a certain amount - magento

In Magento 1.7, is there any way to show Flat Rate Shipping only if chart is over a certain amount?
By rule the only option seems to be free shipping, but my goal is to have Flat Rate if sub total in chart is xx (if sub total is lower, normal rates will be used).

Not by default. It's easy to extend the flat rate shipping carrier method though to do this. Simply create a new module, extend the flat rate shipping system.xml so that there is a new option for minimum cart price (this will allow you to configure it through admin). Extend the following class Mage_Shipping_Model_Carrier_Flatrate and override the collectRates method to check the cart total vs the admin config value. Return false if the cart value is not enough and it will not show up as an option, otherwise it will return the cost set in the admin.
Edit: Something like the following would do it. Extend the class, don't mod the core!
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
// Get The Minimum Order Value From Admin Config & Compare To Cart Subtotal (Base Prices)
if (!$this->getConfigFlag('minimum_order') || $request->getBaseSubtotalInclTax() < $this->getConfigFlag('minimum_order')) {
return false;
} else {
return parent::collectRates($request);
}
}

Related

Magento Cart Rule BUG - Wrongly applied when "less than" and configurable product

I just found out that Magento seems to have a bug since 1.8 relating to cart rules.
let's say we have some configurable products and want to add a "discount" for a specific product if the qty is less then 50. In my case it a surcharge not a discount (you can easily add negative discount so it'll get surcharge by changing two files see http://php.quicoto.com/extra-fee-shopping-cart-price-rules-magento/).
so what does magento do?
1) checks if rule is valid for that product
2) if not it checks if it is a configurable product, then takes the first simple product, and check the rule against that.
in this case true cause qty is less then 50 ( cause this simple product is not even in cart.... )
extending the rule by a "less then 50 and more then 1" didn't worked.
$product = $object->getProduct();
if (!($product instanceof Mage_Catalog_Model_Product)) {
$product = Mage::getModel('catalog/product')->load($object->getProductId());
}
// here, everythign correct. $valid is false cause item is less then x times in cart..
$valid = parent::validate($object);
// this part makes no sense, cause he's checking on a child which is not in cart.
/** /
if (!$valid && $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
$children = $object->getChildren();
$valid = $children && $this->validate($children[0]);
}/**/
this small snippet is related to it, and in my eyes it doesn't make any sense. why the rule should be checked against the first product of a configurable one? why randomly check the rule against some other product?
does anyone has an idea about that?
my solution for now, just comment this line out ... ;-) and the rule get applied as it should.
greets
felix
here's an image about the rule in magento backend
Looks like $object is instance of Mage_Sales_Quote_Item. If so, it explains why rule is being checked against first child - because it is the only child of configurable product in cart. It can't be more than one child of particular configurable product item in the cart at the same time

Magento - Free shipping as default option

We are using two shipping options. If under $50 than add $4.95 and free shipping when more than $50. Magento is only using the $4.95 also when the cart total amount it over $50. How to set the free shipping method as default?
as you can see there is also no option in our template to select the shipping method.
For this you need to enable two shipping method from admin panel.
Enable Free Shipping and Set Minimum Order Amount to $50
Enable Flat Rate Shipping method and set Price to 4.95
By this way Flat Rate shipping method always visible in the checkout and Free shipping method come when Order amount is minimum $50.
As when Free shipping method enable, we need to remove Flat Rate shipping method. For this you need to follow this process:
Copy Flatrate Carrier Model From Core pool to local pool.
From: app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php
To: app/code/local/Mage/Shipping/Model/Carrier/Flatrate.php
In the collectRates function add the below lines:
if ($request->getBaseSubtotalInclTax() >= Mage::getStoreConfig('carriers/freeshipping/free_shipping_subtotal')) {
return false;
}
After these lines:
if (!$this->getConfigFlag('active')) {
return false;
}
In the admin set your Shipping Method Rate to default 4.95 and in your shipping model (e.g Mage_Shipping_Model_Carrier_Flatrate) method collectRates, add a condition to check for the cart total:
if ($request->getBaseSubtotalInclTax() >= 50)
{
$method->setPrice(0.00);
$method->setCost(0.00);
$method->setCarrierTitle('Free Shipping');
}

Add additional product price with mangento base product price

I want to add additional price with product(simple) price, I am trying to do this with the help of custom attributes. I add a custom attribute "Margin Price" and I want to add up this custom attribute value (margin price) with the base price of the product in the template file.
I am updating all product price after each 5 minutes by cron job, thats why I think I have to do add margin price with base product price by this way.
I added it successfully in product list page and in product view page, but have problem with how to add this margin price with base price in the cart and onepage checkout?
Here is the code on the product list page and same for the product detail page which works fine for me in magento 1.6.x.
$regularPrice = number_format($_product->getFinalPrice(), 2);
//echo $regularPrice = $this->getPriceHtml($_product, true
$priceWithoutComma = str_replace(",", "",$regularPrice);
settype($priceWithoutComma, "float");
$marPrice = $_product->getMarginPrice();
settype($marPrice, "integer");
$finalPrice = $priceWithoutComma + $marPrice;
echo $finalPrice.Mage::app()->getLocale()->currency(Mage::app()->getStore()->
getCurrentCurrencyCode())->getSymbol();
I am doing this right way or I have to changes the whole process?
Looks like you might need to consider a different approach. The reason being that echoing the price from a template file does not modify the price of the item in any way. It simply outputs a calculation.
You'll need to learn a bit about event listeners for this one to work.
Here's a blog post of mine on how to do this.

How to access to the discount price in Magento?

I'm trying to rewrite a template for the cart.
I need to retrieve the discount amount but I was not able to find where.
Ie If my coupon code gives me $10 discount I want to retrieve 10, if I have a discount of 5% I want to retrieve 5 if the total price is $100.
Thank you.
you can debug your object by printing it out and observing what values it contains
print_r($this->getQuote()->getData());
I used the following code to access discount price. I was accessing the details of last order in a phtml file. For the last order if there was a discount coupon used then I used following code to access the Discount Amount.
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order=Mage::getModel('sales/order')->loadByIncrementID($lastOrderId);
if($lastOrderId) //If order was placed then only display coupon code
{
$coupon=$order->getCouponCode();
echo "<b>Discount coupon used during order:</b>".$coupon;
$disAmount=$order->getDiscountAmount();
echo "<br/>Discount Amount: ".$disAmount;
}

Magento: Fixed shipping cost BELOW certain basket price

How can I set the shipping cost for Magento for all baskets that are below a certain point. For example, all baskets under £5 have fixed shipping of £1.99.
I think this is what you are looking for, unless I have the wrong thing. It seems to be called Table Rate Shipping.
the only way i've managed to get it working is to add an extra case statement in my shipping module.
$result = Mage::getModel('shipping/rate_result');
...
} else if ($request->getPackageValue() < 6) {
$price = '1.99';
...

Resources