Work with the cart in the billing.phtml - magento

inside the checkout onepage billing.phtml I have to do several checks and even remove or add stuff to the cart.
But I don't seem to find how to do that
how can I change the cart from within an template?
Thanks,
Joe

I would recommend that you don't apply these logic changes in the phtml. You should try to work with the Shipping or Payment method PHP code, either by extending Magento's core methods or writing your own. There are numerous tutorials on the Magento wiki or other blogs on how to achieve this.
By editing the phtml directly, you run the risk of breaking when Magento releases patches or upgrades, and it is bad practice in general.

From that file you can use $this->getQuote() to get a Mage_Sales_Model_Quote object. Methods you might find useful on that object are getAllItems(), addItem() and removeItem().

Related

Different checkout pages based on product category in Magento

I am new to Magento .So please forgive me if I am asking something silly.
I am working on a Magento shop where I have a requirement that when I select some product in certain category say X, then I am redirected to one page checkout where I have default shipping method and do not want any payment method. i.e. Skip shipping and payment method step in chekout.
Whereas if I click some other categories then I get redirected to onepage checkout with shipping and payment option.
So basically what I need in form of code is -
if(category==X)
then Checkout without Shipping and payment method
else
Checkout with Shipping and Payment options.
As far as I have explored the magento structure , it is far too complex then other CMS. I am not able to even find files where i have to make changes in code. Anybody out there who can guide me for right approach toward the solution? Or is there any extension which fulfills such requirement?
Thanks in advance.
First, create the new payment method for the category (and shipping method if you need that too).
http://www.magentocommerce.com/wiki/5_-_modules_and_development/payment/create-payment-method-module
http://www.magentocommerce.com/wiki/5_-_modules_and_development/shipping/create-shipping-method-module
Then I would probably extend the controller, though you probably could also use an observer.
Extend magento core controller (Checkout/OnepageController)
Keep in mind that the customer may have products from another category in their cart, and what to do in that case.

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 I insert a phpBB Forum into a Magento CMS Static Page or Block?

I'm sure there is a much simpler solution for what I am trying to do here, but I am running out of ideas. Essentially I need to create a phpBB forum what exists within my Magento install so that the header and footer from my Magento store are always visible.
The thought is to use a CMS static page for the forum and then style it accordingly. Is there a way to accomplish what I want to do without significant modification? Or, do I just create a one off .phtml file that calls my header, footer and forum? Am I on the right page or am I over/under thinking this?
You'll need to get around Magento's bootstrap (/index.php), because phpBB won't function if Magento is intercepting every URL.
There's also the issue of Magento and phpBB not sharing authentication systems, so users have to log into one, neither, or both. That's not a great UX if you ask me, but solving that problem is a very complicated issue.
Other than that you shouldn't have many problems.

How to overload magento CartController

Im trying to overload my CartCotroller so create folder structure like my CartController in the local:
app/code/local/Mage/Checkout/controllers/CartController.php
My question is, does magento execute this Controller and ignore the one whose in the core?
Cause what im trying to do is, i want to add an condition when the customer post a coupon code without changing my form method value. Is it possible?
Yes, Magento will execute the controller placed in app/code/local instead of the core file. An even better way to implement new code or extend the core is to create your own module. So you'd have all your custom code in one place and it's maintanable should you update Magento.
Smashing Magazine gives a nice basic roundup on how to accomplish this. http://coding.smashingmagazine.com/2012/03/01/basics-creating-magento-module/

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