Get notified on stock unavailability - php

I am trying to create a "Notify me" feature if the stock is unavailable.
On search on admin panel, I could find only that a user should sign up / log in to get notified about the stock availability.
But I just want to let the user (a guest) enter only his/her email address to get notified.
How should I do this?
Please give suggestions..
EDIT:
I have got this link, which gives me a way to start.
Till now what I did is added the following code in my template file which is creating a url for redirect (thinking to do it in ajax way, to stop page refreshing).
<?php
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$base64 = strtr(base64_encode($actual_link), '+/=', '-_,');
$postUrl = "http://$_SERVER[HTTP_HOST]/efk/productalert/add/stock/product_id/" . $simpleProduct->getId() . "/uenc/". $base64;
?>
In the above code, efk is my project folder name.
After this, I have gone to productalert/add/stock controller method i.e stockAction() which is calling sign up / login form (I think so) using $model->save();.
How should I disable this save calling and add my own small overlay which holds a textbox to enter a email address?

Magento has "Notify me when product is back in stock" feature out of the box. It can be configured in admin panel: system / configuration / catalog / product alerts and product alerts run settings.
You're right, it works only for registred customers. To make it working for guest users some coding is required. I'd say you need to do the following steps:
Add email column to product_alert_stock table
Create new controller and action (believe me, it's better than you override existing one via config.xml) which extends Mage_ProductAlert_AddController::stockAction(). Your method will have to set guest's email to productalert/stock model.
Create subscription form and make sure it submits data to your new controller/action.
Update (override) Mage_ProductAlert_Model_Observer::_processStock() method to make it respect situations when "customer" has no ID but has email.
When you'll be testing, I suggest you to install SMTP Pro Email extension and mailcatcher to ease the testing process.

We have done this (http://www.alfresia.co.uk/sorrento-side-table.html/). Here we ended up creating a custom module as when we did this magento did not support any product alert system for the guest users (i do not know if this is supported now).
We first created a text box which would appear on product page where the product is out of stock. We were saving this info in one of our custom tables where we the schema was {id, email, product_sku, status} (status had three values Awaiting Stock, In Stock, and Already Notified).
We then wrote an observer which was hooked to cataloginventory_stock_item_save_after event, this helped us get the product sku which has been back in stock, and update all entries in our custom table with status In Stock and send a mail to the user.
This is how we did it, surely there will be a much cleaner way doing this.

You could have work with plugins. MagentoCommerce has loads of plugins/extensions which does the same
Free Version - http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription-1350.html

I too had similar requirement, and have installed 'http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription-1350.html' this plugin.
Well this plugin does the job, But they have override complete product view page template instead of simply adding a new block. By this your custom development on product view page development might get reflected on frontend.
Or else this plugin definitely does the job.

This http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription-1350.html plugin is really good but it breaks for configurable product types and it completely overrides the product controller which makes your system vulnerable to future upgrades. I think observers should be hooked to events where the product is back in stock and should update the users.

Related

Customization for Payment Gateway in opencart

So I am trying to set up a site on my localhost. I have selected 2 payment gateways from admin end
Online Payment (Free Shipping)
Cash On Delivery(Free Shipping/Flat COD Charge INR 50 )
Now I have customized all the rules for them. I only need one more rule.
I wish to have a functionality wherein I can enter some pincode/postcode values (through admin panel or maybe in some array in a javascript file or directly into the database, does not matter) of locations where second method is available)
Whenever someone presses continue before confirming order, the checkout form is validated so as to check from the form data if the value entered in post code matches the data (from any of the above methods) and if yes, only then they can continue or I wish to show an error message that
Following payment gateway is not available in your location
If you give me a hint on how to proceed with this, perhaps, I might be able to take it further. I am a bit or a starter in opencart so not much idea about how to proceed. I have sound knowledge of PHP, JQuery and Javascript although. So any and all help will be appreciated.
There are a few different extensions that already exist to do what you want - allow you to restrict shipping methods by various criteria. This one is my personal favorite: http://www.opencart.com/index.php?route=extension/extension/info&extension_id=1614
I managed it with JQuery for the time being. Edited the submit function in the cart.tpl file in catalog->view->theme->ancart (theme name) ->cart folder.
Used a plugin called "Zipcode COD" to enter zipcodes. Edited the response JQuery to hide and show payment options.
Lots of hard coding but does the trick. I will post the code if someone needs.

Send newsletters in email to subscribed users using magento

In magento I have:
created one template which I want to send to subscribed users.
Added that template in queue.
set cron job in magento.
I want to send newsletter template automatically to all subscribed users of store when admin added new products or new promotions using magento admin panel. How can I do that?
My Magento Version is 1.9.0.1
I was talking about the use of event-observer in magento. This is like a hook with the help of which you can insert your logic or code before or after some event occurs. For example
catalog_product_save_after
is the event which occurs after product is saved. You can learn more about it here.
You have to create a module that observe this event and there you have to implement your logic that is:
get the sku of the recently saved product and check it is already present or not(To check either the product is new or not.This should be check because the product can be edited too because while editing and saving also same event is observed), and then you can do rest i.e sending an email newsletter.
My explaination may seem confusing to you because you are new to this check that link and you will have your concept clear.
Hope this will help.
If you are simply wanting to add a link to the product into the newsletter then you can add a new newsletter template, then insert into this template using the cms widget "Catalog Product Link" you can add a link to a product. This is the same as adding a link to a product via a cms page or block.
If you are looking at sending a product list then I would suggest looking into how the widget "Catalog New Products List" works. You could extend this to take a list of product ids that need to be included in your list.

Prestashop 1.6 Automatically adding a customer to a group upon virtual product purchase

Using Prestashop 1.6 is there a way to automatically add a customer to a group when they purchase a virtual product?
Example: Virtual product is a membership. When they buy the product, I want them to be assigned to the Members group.
One way I was thinking of achieving this was to do the following:
Can the virtual product link that the customer receives in the email be a link to a PHP page that I create? I was thinking of writing a PHP page with an activate membership button that would insert them into the proper group via MySQL code.
I could not find a module to do this. I would like to avoid creating a module because then I would have to study module creation and I was hoping for an easier solution.
The highly recomended solution is a custom module that will assign the user when the payment is confirmed. It can be done with changes to the core file, but this is the worst solution, since after the next upgrade of PrestaShop those changes will be overriden. Module creation is not so hard, you just need to implement the hook "actionOrderStatusUpdate" and asign the order customer to previously selected customer group from the module configure page.

Magento Address Field not available in One Page Checkout

I have created couple of custom fields in Magento's customer addresses using a tutorial available here.
When a customer edits his/her address the fields are shown, when he is checking out through the one page checkout being logged in, the addresses appear as a drop down. In this case the address is hidden from the client using a display:none; style.
The problem is that the custom address attributes are not available but the regular attributes are available.
What I think is that when the customer is editing the address, the controller is customer and when he is on onepage the controller is checkout. There is some error or I am missing something so that the onepage controller fails to pull custom address fields.
What I have done:
I have overridden the billing.phtml file in
/app/design/frontend/base/default/template/checkout/onepage
The fields show up in the onepage checkout billing section. But when the system is loading a default address the fields values are not loaded like other values get loaded. For example, the phone number is loaded by calling the function
$this->getAddress()->getTelephone();
but when i call my custom field whose name is address_mobile like
$this->getAddress()->getAddressMobile();
The system can not pull the value, like it pulls for telephone. Below is the source code of how the field appears in hidden section.
The one step checkout does not look for any custom fields.
If you look in app / design / frontend / base / default / template / persistent / checkout / onepage / Billing.phtml
In this instance were looking at the billing address that can be changed you can also do the same for shipping if required.
What you will need to do is update the template file above ( Ideally moving it to your package under app design frontend ). This will be showing the new form fields on the checkout but it wont actually persist to the database. In order to save these values to the database you are going to need to override the OnePageController.php and the saveBilling / saveShipping methods to store your data.
If you need any more help on this let me know and I will look to find an example that you can use.

Is it possible to create a new product by class methods in virtuemart 2?

I have developed a virtual store using virtuemart 2.0.10 and I need the products in a given category have a different flow of purchase.
Is there a way, from the data of an existing product (with name, price, description, etc.) to create a new product with new id and sku, using an image located in a known directory? All done on the front end, as user interaction, using classes of MVC framework of virtuemart 2.
Needs to be done this way for the product to be added to cart separately, even though the same product base, each with its resized image, and when you click it to open the product details displaying a custom image.
If anyone know a way to do, please help! I looked at the classes responsible for registering products in virtuemart but do not know how to do safely from the front-end.
The first step (redirect user to component and create a custom image) is already done and working, the image is saved in directory and its url recorded in session
Take a look at the VirtuemartControllerProduct::CloneProduct function. It will point you down into the VirtueMartModelProduct::createClone function where the work actually goes down.

Categories