Magento create personal coupon to newsletter - magento

With Magento version 1.7, how can I auto generate a personal 10% discount coupon for each newsletter receiver that can only be used once by that specific account/user?

Here is an idea. Actually 2 of them.
The quick one.
Create a coupon with your desired rules, set the number of uses to 1 per customer and unlimited for general usage and hard code the coupon code in the newsletter email.
Estimated time: 30 minutes including tests. Risk: minimum.
The slow but clean one:
Create an observer on the newsletter_subscriber_save_before or newsletter_subscriber_save_after that checks if the customer subscribes and if so, it creates a coupon with your desired settings. See this for creating coupons by code.
Then rewrite the method Mage_Newsletter_Model_Subscriber::sendConfirmationSuccessEmail so you can pass that code as a parameter to the e-mail template.
Something like this:
$email->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
$this->getEmail(),
$this->getName(),
array('subscriber'=>$this, 'coupon_code'=>THE COUPON GENERATED IN THE EVENT)
);
Then modify the newsletter subscription e-mail template to include this:
Your coupon code is: {{var coupon_code}}
Estimate 4h-8h. Risk: "not that minimum".
I would take the first approach.

Use personal discount extension http://www.magalter.com/personal-discount.html to generate 10% discount coupon. You will be able to choose customers who can use this coupon.

Related

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.

Show payment method discount rule on magento product page

I want to display the discounted price the client can have depending on the payment method he chooses directly on the product page.
Basically, what I need is a way to get the shopping cart rules that apply for payment methods. So then I could use it to build a table of payment methods X discounts like this:
Cash: $90 (10% discount)
CC: $100 (Full price)
Transfer: $100 (Full price)
So far I couldn't find a way to access the shopping cart rules. Any insights?
UPDATE:
For those wondering, I've found a way to get the shopping cart rules. Pretty simple actually:
$model = Mage::getModel('salesrule/rule')
->getCollection();
With this information I can loop through the rules and find the ones that apply to payment methods.
$conditions = unserialize($item['conditions_serialized']);
But I realized that this way is too much work and can get complex if rules are complex. I decided to get the rules that I want by ID and get the discount value, since it won't change all the time.
If you know how to make Magento calculate everything for me, like me asking "If a user chose this payment method, besides everything else (user group, catalog discounts, etc) what would be the final price?".
$model = Mage::getModel('salesrule/rule')
->getCollection();
foreach($model as $item){
// check, do whatever and get discount
}

Magento: Auto Add Gift Certificate to Cart Every $X Amount

We have a website that we are trying add a gift certificate to the cart for every $100 someone spends (i.e. a customer gets a $10 gift certificate for every $100 they spend). We are currently using Magento 1.6.1 and Unirgy Gift Cerificate to do our gift certificate system. Does anyone have a better solution or a way to use our current system to do what we want?
I have looked into a whole bunch of Add to Cart extensions, but all of them don't seem to allow me to add a gift certificate to the cart.
the extension is paid so I cannot help you much here but: If you know how the gift card is added to cart (check extension code to find out) you could try adding observer using 'checkout_cart_product_add_after' event. On how to add events, check here:
http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method
In the observer method, check how much $$$ the cart does have by getting quote e.g:
$quote = Mage::getSingleton('checkout/type_onepage')->getQuote();
and gathering grand total (getGrandTotal metod I guess)
and add as many coupons as you would like ($total/100 = $gifcard_amount) and then reuse the code by using
for ($i=0;$i<$giftcard_amount;$i++){
//giftcard add logic
}
Hope this will get you started.

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.

Display Percentage or Amount of discount for catalog price rule in Magento

I'm struggling to figure out how to display the percentage or the amount of discount that is applied to a product in Magento via the Catalog Price Rules.
For example: I want the price to be displayed in the front-end as follows: [old-price] [special-price] [discount info] where [old-price] has a css strike through.
The [old-price] and [special-price] is available by default through the tax helper. I've tried using the CatalogRule model, but I have no way to load it with a product id as the load function expects an entity id and from what I can tell, there aren't any other useful methods to load by product ID. I've var dumped (as well as using get_class_methods) just about everything that I found in the price.phtml file (apart from $this of course), but nothing helps.
I could just use a simple calculation to work out the discount percentage or amount, but I have no way of knowing whether the catalog rule is based on a percentage, or fixed amount.
I hope this all makes sense?Thanks for the help.Rémy
I do agree Magento makes this kind of thing a bit too hard. I wanted to display the description of the coupon code next to the entered coupon code. I suspect my code will be able to help you on your way. I put this code at the top in the template checkout/cart/coupon.phtml:
<?php
$c = Mage::getResourceModel('salesrule/rule_collection');
$c->addBindParam('coupon_code', $this->getCouponCode());
$c->getSelect()->where("coupon_code is null or coupon_code='' or coupon_code=:coupon_code");
foreach ($c->getItems() as $item) {
$coupon_description = $item->getDescription();
}
?>
So you can see $coupon_description now holds the description of the Shopping Cart Price Rule as long as the user specified a coupon code. You can add more properties from the coupon this way.

Resources