Magento : Converting currency before sending data to Google Checkout - magento

I have a magento site with base currency in USD and Google Checkout in GBP.
Google Checkout: The currency used in
the cart must match the currency of
the seller account. You supplied a
cart with USD and the seller account
is associated with GBP.
Is there a way in magento to convert the amount to GBP before sending to Google Checkout ?
i guess a module could be written to achieve this, but any other workaround ?

Okay, this is far too late, but I hope someone will find this useful.
I don't know how your system works and which version of Magento you are using, but in 1.5 (the one that I am using) in the module GoogleCheckout, look for Model/Api/Xml/Abstract.php, this is base Model for the others models in the GoogleCheckout XML API and it has a method called getCurrency();
public function getCurrency()
{
if (!$this->hasData('currency')) {
$this->setData('currency', Mage::app()->getStore()->getBaseCurrencyCode());
//$this->setData('currency', $this->getLocale()=='en_US' ? 'USD' : 'GBP');
}
return $this->getData('currency');
}
Since it is not good idea to override Abstract class in PHP according to this you will need to copy this class to the local folder and change the method getCurrency() so it transforms the currency to GBP.

Related

magento product specific zip code checking

I am using magento 1.8.1
I am using zip code Check Delivery Details, like to check if delivery service is available at the client area or not and this is general.
this is working fine.
But now I want to do this product specific like some product are avaialble to some are with different delivery details for eg, xxx product is available to 111111 zip code in 6 days, to 222222 zip code in 2 days , 33333 delivery not available etc.
I want such product specific delivery detail checking.
Can anyone help me to know if such extension is available or not.
or any specific coding for this.
You need to create your own shipping module to inform whether the product is available for delivery or not.
Check How to create custom shipping module http://excellencemagentoblog.com/magento-create-custom-shipping-method
Then in function
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
//check your product shipping availability based on your conditions.
// set all the shipping parameter if product shipping is available.
// or set error message to display user
}
for any queries reply back.
Thank you

Restrict countries for shipping in magento

I have multi store website in magento. In one of my website I want to restrict the countries that I can make shipping. But the payment can be received from anywhere of the world. I have tried
system --> configuration --> web --> general
And
system --> configuration --> shipping method --> specify country
but the problem is that in checkout page, I want to show all countries name in the dropdown list of billing information and I want to show only a specific country, eg: India in the dropdown list of shipping information. Is there any way to do so? Any help would be great full... Thank you.
From Class : abstract class
Mage_Checkout_Block_Onepage_Abstract
public function getCountryHtmlSelect($type)
$select = $this->getLayout()->createBlock('core/html_select')
->setName($type.'[country_id]')
->setId($type.':country_id')
->setTitle(Mage::helper('checkout')->__('Country'))
->setClass('validate-select')
->setValue($countryId)
->setOptions($this->getCountryOptions());
So setOptions($this->getCountryOptions() is responsible for that drop down list of shipping countries.
Here you place is $type is equal to shipping then call $this->getShippingCountryOptions()
follow this by writing your own code for this function refering to function getCountryOptions() code.
Note : Do not touch core files. This is just a guideline.

Welcome email to include discount code for subscribers

The environment is Magento 1.7.
Basically what I want to achieve is when users subscribes to the newsletter, the system automatically include a discount code in their welcome email. This discount code is for one time use for per account.
Searched around and found a tutorial which is best suit my requirement. Based on my understanding on that tutorial, we need to fetch some values out of the module configuration and user the helper to send an email with a coupon code.
On top of the codes I've made some amendments:
1)
in the file
app\code\core\Mage\Newsletter\controllers\SubscriberController.php
before
$this->_redirectReferer() in newAction()
insert
$helper = Mage::helper(‘subscribereward’);
$promo_value = Mage::getStoreConfig(‘subscribereward/promocode/dollarvalue’);
$promo_min = Mage::getStoreConfig(‘subscribereward/promocode/minpurchase’);
$helper->addPromoCode($email, $promo_value, $promo_min);
2)
in the file
app/code/community/Dg/Pricerulesextended/etc/config.xml
replace
Pricerulesextended/Observer
with
Dg_Pricerulesextended_Model_Observer
I've followed the steps but still can't get it working. Anybody care to shed a light?
Aheadworks has an extension called Follow Up Email, and it does exactly that. Ive set it up for clients where when a customer signs up (or a number of actions) it sends a welcome email with a randomly generated coupon (or standard one).
Also what you could do is just make a coupon code and add it to a welcome email template. Just make a new transactional email and add the coupon to the template. No custom coding required at all.

Magento: how to get the price of a product with catalog rules applied

I'm developing a script (external to Magento, not a module) which aims to output a text list of all available products, their prices and some other attributes. However, catalog price rules don't seem to be applied to product prices. If I use any of the following:
$_product->getPrice()
$_product->getFinalPrice()
I get the normal price (without rules being applied).
If I use:
$_product->getSpecialPrice()
I get null unless the product actually has a special price inserted in the product itself (i.e. if special price is not related with catalog rules).
I also tried
Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice())
as suggested in the answer given by Fabian Blechschmidt, but interestingly it returns the normal price only if the product is affected by any catalog rule, returning null otherwise.
There was a similar question in StackOverflow and Magento Forums some time ago, but the provided answer (which is to insert the code bellow) doesn't work for me (returned prices remain the same).
Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_FRONTEND,Mage_Core_Model_App_Area::PART_EVENTS);
Does anybody have an idea of how to achieve this?
I'm using Magento 1.6.2.0.
Thanks in advance.
Thanks to you, I found a new site:
http://www.catgento.com/magento-useful-functions-cheatsheet/
And they mentioned:
Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice())
HTH
As catalog price rules heavily depend on time, store and visiting customer, you need to set those parameters when you want to retrieve the product final price with it's price rules applied.
So, in your case, make sure that provided product is passed with the desired store and customer group id, which can be set as:
Mage::getModel('catalogrule/rule')->calcProductPriceRule($product->setStoreId('STORE_ID')->setCustomerGroupId('CUSTOMER_GROUP_ID'),$product->getPrice())
I discovered the problem. The discounted prices display Ok in the store frontend. The problem was that I was developing a script "external" to Magento (thus not a Magento module), something like:
<?php
set_time_limit(0);
ignore_user_abort();
error_reporting(E_ALL^E_NOTICE);
header("Content-Type: text/plain; charset=utf-8");
require_once "app/Mage.php";
// Get default store code
$default_store = Mage::app()->getStore();
...
For everything to work properly it seems that one must follow the proper Magento bootstrap, and develop everything as a module. My script was so simple that I thought it wouldn't be necessary to code a complete module. In other words, everything in Magento should really be a module.
Concluding, using the module approach, all the methods work as expected:
$_product->getPrice()
$_product->getFinalPrice()
$_product->getSpecialPrice()
Thank you all for your input.
This helped me in this issue: http://www.magentocommerce.com/boards/viewthread/176883/
. Jernej's solution seems plausible, but it does not handle rules that Overwrite other rules by using 'stop processing' and therefore can apply more than one rule.
$original_price = $_product->getPrice();
$store_id = 1; // Use the default store
$discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
Mage::app()->getLocale()->storeTimeStamp($store_id),
Mage::app()->getStore($store_id)->getWebsiteId(),
Mage::getSingleton('customer/session')->getCustomerGroupId(),
$_product->getId());
// if the product isn't discounted then default back to the original price
if ($discounted_price===false) {
$discounted_price=$original_price;
}

Magento: don't send tax to paypal/don't show tax in paypal emails

I'm using magento 1.7, and one of the payment options is Paypal (UK) express checkout.
The problem is that I don't want paypal to send out emails with any tax breakdown on, is there a more straightforward way of solving this (at the Magento or Paypal end) rather than hacking the core module to pass sub+tax as sub and 0 as tax?
I can see that a lot of the fields are mapped in Model/Api/Nvp.php, but can't immediately see where I'd modify these values.
As far as I investigated, there is no easy configurable way to prevent taxes to be submitted to Paypal.
But indeed there is a core hack if you don't mind that only the total amount is submitted (no line items, no taxes).
Go to System/Config/Paypal and set Transfer Cart Line Items to No.
In your code go to function _validate() in class Mage_Paypal_Model_Cart.
At the end of this function add the following lines:
$this->_areItemsValid = false;
$this->_areTotalsValid = false;
Of course it is nicer to to rewrite this class in your app/code/local folder.

Resources