I am new in magento. I want to have terms and condition checkbox on cart page where proceed to checkout button is there. I have enabled terms and condition but it is on the last of the all process. So, can we have in starting or in cart page.
Terms and Conditions on Checkout Page – Magento Guide
cartcheckout
Best Answer
If you're new to Magento, this answer likely will not make sense. So either get an experienced Magento developer on this or start brushing up. With that, here's what you can try.
Prerequisites
Ensure that you have defined terms in Magento under
Sales > Terms and conditions
Ensure that you have terms enabled inSystem Configuration > Sales > Checkout > Checkout Options > Enable Terms and Conditions
And please note, these instructions may vary greatly depending on your version of Magento/checkout extension in use, and where you actually want to display the agreements. This will show you how to work it out on a stock CE installation.
How Agreements are Rendered
See
app/design/frontend/base/default/layout/checkout.xml
:The middle line tells Magento that the layout on the review step will contain a
checkout/agreements
block namedcheckout.onepage.agreements
. It also sets up the template there.So when the checkout reaches the review step, this file comes into play.
app/design/frontend/base/default/template/checkout/onepage/review/info.phtml
:And that 2nd line is asking to render the block we defined in the layout XML above.
How to Require Agreements at Checkout Step 1
If you've followed me so far, then you can infer to start by moving/copying the layout XML block node (
checkout.onepage.agreements
) into another area (called a 'layout handle') of the same file. Find the layout handlecheckout_onepage_index
, and get to its child block namedcheckout.onepage.billing
or whatever block you want to display the agreements. Extend it by adding that agreements XML, so that it looks like this:Now we're ready to call and render that block from within the billing step's template. Open that up, get to the place where you want the agreements to appear, and add this line:
If you clear your cache and get to the checkout, you should see the agreements appear. That handles rendering, now we have to tie that into validation.
How to Validate Agreements
Because this is normally done at the end of the checkout, we can figure out how it works by examing the checkout's main controller:
app/code/core/Mage/Checkout/controllers/OnepageController.php::saveOrderAction
:You will essentially copy this condition into the top of the
saveBillingAction
method, like so:Notice a key difference here. The
$result['error_messages']
was changed to$result['message']
. This is done because, unfortunately for the stock checkout, its JavaScript is inconsistent in implementation. So while the order review step will check forerror_messages
, the billing step looks formessages
on the result.Now that you've displayed your agreements, and wired them up to the controller, you should be able to test this step out. If you don't check the agreements, and continue to the next step, you would get an alert box that says, "Please agree to all the terms and conditions before placing the order."
A long-winded answer, but also very necessary if you have no idea where to begin. Hopefully this helps.