Add to Cart Button on CMS Page in Magento EE 1.13 - magento

I am trying to create a landing page for our company which runs on Magento Enterprise Edition 1.13. We use CMS pages for our landing pages and in the past we have been able to create custom add-to-cart buttons directly on the CMS page. It was very simple in fact, we would create a button and send the button to this URL endpoint:
<button class="button btn-cart" title="Add to Cart" onclick="setLocation('/n/magento/checkout/cart/add/product/644/qty/1')" type="button"><span><span>Add to Cart</span></span></button>
It was nice and simple and allowed us to really engage our visitors with awesome landing pages and the ability to add products to cart without leaving this highly optimized page.
You can read a StackOverflow post about the OLD way to do it here: Placing "Add to cart" button on homepage in Magento
However, this no longer works in Magento EE 1.13 according to Magento themselves.
I contacted our Magento support and explained to me that the syntax had changed, now requiring you to put your security hash in the URL. This seemed like a security concern to me, so I questioned it. I was then responded to stating that the security flaw was added to prevent developers from using this anymore without compromising their site. Essentially they are discouraging use of this. They said:
My developer indicated that the ability to add a product to the cart via a direct URL wasn't an intended functionality in Magento, and so the addition of the form_key value was meant to prevent its further use with the upgrade to 1.13.
So my question for all of you, is that if somoene wanted to create add-to-cart buttons on a CMS page, in order to add products without needing to send someone to a product page (where they would no longer be on our optimized landing page), how would I go about doing this?
Is there a way in Magento 1.13 to add a product to cart with a custom button that could be placed in custom HTML within a CMS page? Can this be done with a static block or widget? We really relied on this feature and are now questioning the purpose of Magento EE's $18K a year pricetag with this feature taken away. Please help, thanks!

You'll want to include the formkey block, and then use JavaScript to pull the value from the <input /> tag that is generated and add it to your link URLs, AJAX, etc.
{{block type="core/template" name="formkey" template="core/formkey.phtml"}}

This will work in 1.13:
<button onclick="location.href ='{{config path="web/unsecure/base_url"}}/checkout/cart/add?product=1&qty=1'">Add To Cart</button>

There is a way to modify magento code to allow adding products to shopping cart without form key.
I will post the solution, but anyway I want to warn you that removing form key validation will enable CSRF attacks on your customers!
You need to edit app\code\core\Mage\Checkout\controllers\CartController.php
Find next piece of code:
public function addAction()
{
if (!$this->_validateFormKey()) {
$this->_goBack();
return;
}
Comment first 3 lines of this function:
public function addAction()
{
//if (!$this->_validateFormKey()) {
// $this->_goBack();
// return;
//}
Now it is possible to use static links.

Related

Adding 'terms and conditions' to Infusionsoft shopping cart

I want to get SagePay on my company's Infusionsoft shop. But, SagePay ask for a checkbox on the checkout to confirm that customers have read the terms and conditions. Totally understandable - but Infusionsoft do not support this option by default.
I am not using the API. Does anyone know a way, perhaps with Javascript, that I could create such an option and NOT let customers proceed to checkout without clicking 'accept'?
Thanks in advance,
Nicole
You should be able to add an onclick listener for the checkout button using something like this:
document.getElementById("idOfButton").onclick = function(e) {
//Look at value of checkbox
//If checked, don't do anything
//else e.stopPropagation
}
In your shopping cart theme you should be able to paste in html for the checkbox.

Magento Hooks - Will Magento allow me to do this?

I'm going to be starting a E-Commerce project and the client is interested in using Magento. In this project, when a customer adds something to the cart, I'll need to pull them out of the flow, where they'll proceed through a custom wizard-esque area.
They basically design a document using a drag and drop interface. After they finish, that document will be saved as a PDF, and I want them redirected to checkout
So my questions are
Does Magento have hooks available for after an item is added to the
cart ?
If I pull them away to this other section of the site (Wizard
portion), changes they make will potentially add costs to
their cart. Would I still have access to products, prices, and the
cart so that I can continue to modify their cart until they return
to checkout ?
Magento users Event-Observer pattern, where you can hook into virtually any action which is performed and execute your custom code,
Refer to below links,
http://inchoo.net/category/ecommerce/magento/events-observers/
https://gist.github.com/peterjaap/6973324
http://huztechbuzz.wordpress.com/2014/04/26/complete-list-of-all-events-in-magento/
http://www.nicksays.co.uk/magento-events-cheat-sheet-1-7/
So you have to figure out which event you can use and plugin your custom code.
As long as i remember all the cart info ( products/prices ) is stored in the $_SESSION. So you can get all the information from there you need, modify it via your so-called wizzard and udpate the session information after that!
Cheers! :)

Can Magento be used as a CMS to build a product catalog(not a store currently but maybe in the future)

I have to build a website for a mobile store. They want to list their products but don't want to start selling yet. I have done a lot of website with Joomla and Virtuemart.
This time I want to use Magento as they use Lightspeed a POS that offers integration with Magento community edition.
My question is can I simply use Magento as a CMS to only display products and a few static pages like about us etc. I went through stackoverflow and found that some members have recommended some good blog integrations for magento so that part is solved(Thanks :-) ).
I know I can use wordpress as a blog with magento.
I rephrase....Can I use it to simply display products!
If Yes then please let me know if I am doing it for the right reason.
the reason are:
Adding products and product information becomes very easy in a
shopping cart(But in a CMS like Joomla each page has to be literally "designed" or I will have to use CCK editor. It still
becomes difficult for the client to update products IMO)
It comes with built in plugins to show related/featured products
etc. with a click on a button or options in the backend while client
simply puts the appropriate tags(With a CMS have to use a plugin or
module in Joomla that has to be set to show in the particular pages)
Automatic display of images etc is easier in Magento in comparison
to a CMS like Joomla where I will have to use a plugin or a gallery
that is set to show inside an article
The buy/add to cart button can easily be disabled and a "more info"
button can be added that will send an email to the client. They get
the exact product code the customer is asking for(Doing that in
Joomla would require a lot of extra stuff like adding codes or use
an advanced contact form with a tag to be entered for each page)
Last but not the least when client is ready to go online it can
easily be converted
Does Magento have two display? One is simply a catalog and the other a store. I have seen that in some stores online(not necessarily using magento) I am assuming either they created a website with the products pages first and then added a store later.
But in many cases it looks like a part of the Shopping application.(i just can't seem to remember which one they were using now).
If Magento allows that then I think my problem is solved. I simply use the "catalog option" and when the client is ready for the store I simply pull the products using a extension from their POS software.
Thank you for taking the time to read/answer.
Using Magento as a catalog only without selling the items is pretty straightforward. The easiest thing to do is just to use the catalog category lists to list the products and just make sure the "order" button is not visible.
You can do this simply by removing it from the product detail template (and the list/grid template in case they have it).
Or you could (I think) set all products to 'out of stock' this will automatically remove the 'order' button.
If you want to be thorough you should edit the cartControllers's addAction to disable adding products to the cart.
If you are going to combine Magento with Wordpress, Fishpig has developed a plugin with which you can use shortcode within Wordpress blogposts or/and pages to display products.
More info about that can be found here: http://fishpig.co.uk/wordpress-integration/docs/shortcodes.html
System > Configuration > Advanced > Advanced
Disable the modules you don't want to use.
For example, if you wanted to use Magento as catalog only then disable sales module.
Hope this works for you!

How can I add custom fields in cms edit page (Admin Panel)?

I am facing an issue in Magento. I want to add some custom fields to Magento Admin Panel CMS Edit Page. I got a page while searching where it describes adding a custom field in CMS page: http://blog.flexishore.com/2011/08/add-custom-field-to-cms-page/ .
I have followed every step in this, but I am still getting an error Call to undefined function getLoad().
Can anyone here explain me how to add custom fields in CMS page?
You can try this article (http://www.atwix.com/magento/adding-custom-attribute-to-a-cms-page/) as well, it's more simple, maybe it will be helpful for you.
Also don't forget about cache, I recommend you disable it when you are testing your own modules.

How do I create a Magento module or widget that will appear on the shopping cart page?

I’m having a lot of trouble understanding how to create a module that will add an extra button to the shopping cart page. I found lots of info on payment modules and stand-a-lone page modules, but nothing for this.
I simply need to add a button underneath the regular “Checkout” button that can post item data to another website. I’ve created a module but can’t get Magento to recognize it and display the button on that spot. Any help would be greatly appreciated, even just sending me to an existing tutorial that I haven’t been able to find. Thanks.
A custom module is probably overkill for this. Module means a very specific thing in Magento. It's a mechanism for inserting custom code into Magento's standard operations. All you want to do is add a button to the cart page. Editing the file at
./base/default/template/checkout/cart.phtml
(substitute your theme/site name if not using base or default)
is the place you'll want to start looking. Just find the phtml file that corresponds to the place you want to insert your custom HTML and have at it.

Resources