2

I am trying to figure out the best / safest way to add an option to Magento's checkout so users can define if they are agreeing the the business T&C's or the consumer/personal ones.

Ideally this would simply be in the form of a dropdown to choose which terms.

Then I wanted this to report to the order details in the back-end.

I have be looking around and I've found a few posts about adding custom field etc to Magento checkout however many are outdated and miss the back-end part.

Any help is greatly appreciated or a push in the right direction.

3

So, Magento allows you to add multiple T&C's, you can add Multiple to fulfill your needs.

If a customer uses the checkout for the first time, you do not know in which customer group it belongs. You can obviously check if the vat id field is filled and add a small change.

  • add two T&C's Customer and Bussiness admin / Sales / T & C
  • enable T & C admin / System / Configuration -> Sales/Checkout

Now the users needs to accept them both. Accept Terms and Conditions

Next up, setup automatic customer group assignment.

  • enable Automatic Assignment to Customer Group admin / System / Configuration -> Customer/Customer Configuration
  • Select a group for valid Taxvat ID

We will add some custom extra code in app/design/frontend/rwd/default/template/checkout/onepage/review/info.phtml

<div id="checkout-review-submit">
    <?php echo $this->getChildHtml('agreements') ?>

    <?php /** ADD THESE LINES **/ ?>
    <script type="text/javascript">
        (function($) {

            <?php /** Customer has business group id 2, 3(specify your own) ?? */ ?>
            var isBussiness = <?php echo in_array(Mage::helper('checkout')->getQuote()->getCustomerGroupId(), array(2, 3)) ? 'true' : 'false' ?>;

            $('#checkout-agreements ol.checkout-agreements > li:not(:first-child)').each(function(index, item){
                item = $(item);

                if (!isBussiness) {
                    // Hide
                    item.hide().find('input').attr('checked', true);
                }

            });
        })(window.jQuery);
    </script>

This way, customers will only see the first option and business users will have all the options.

Non business users will see only the first option. Non business customers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.