1

In the checkout, how can one add the customer's name to the credit card form? Is there a way to get the customer name int the checkout page?

What I would like to do is have the customer's name during the checkout process to use in the steps.

For instance:

  • Like, "Hello Joe, this is step 3"
  • "You still with us Joe this is step 4"
  • In the credit card form add their billing name with a little "x" to clear it if they want to use their uncles card.

How do I read the billing name to use it like this? The name appears in the progress bar so I thought that might work (as I don't show the bar).

It should be for all users, guests especially.

2 Answers 2

3

To get the customers name in the checkout and do something useful with it, get the name from the customers billingdata, which is saved in the quote. Mage::helper('checkout')->getQuote()->getBillingAddress()->getName()

The file you need is app/design/frontend/{YOUR_PACKAGE}/{YOUR_TEMPLATE}/template/payment/form/ccsave.phtml (you can copy it from app/design/frontend/rwd/default/template/payment/form/ccsave.phtml)

Add in the top of the file: (line 26)

$ccOwner = $this->getInfoData('cc_owner');
if (empty($ccOwner)) {
    // Update cc_owner from billing address
    $this->getMethod()
            ->getInfoInstance()
            ->setData('cc_owner', Mage::helper('checkout')->getQuote()->getBillingAddress()->getName());
}

To add the X to empty, add the next after the input field:

    <div class="input-box">
        <input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Name on Card')) ?>" class="input-text required-entry" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->escapeHtml($this->getInfoData('cc_owner')) ?>" />
        <a href="#" onclick="jQuery(this).prev().val(''); return false;" />X</a>
    </div>
2
  • This works great. Is there a way to get the X inside the field? Not a big deal though. Thank you
    – Freejoy
    Jan 17, 2016 at 16:06
  • I got the x in the input field just using css. thanks
    – Freejoy
    Jan 17, 2016 at 16:13
1

to get the current (logged in) customer details:

if (Mage::getSingleton('customer/session')->isLoggedIn()) {
   $customer = Mage::getSingleton('customer/session')->getCustomer();
}

The resulting object will contain all the customers details.

Not sure what you want to do with the sidebar....

2
  • Thanks, what I would like to do is have the customer's name during the checkout process to use in the steps also. Like, "Hello Joe, this is step 3", "You still with us Joe this is step 4" then when they get to the credit card form their billing name will be in the credit card form with a little "x" to clear it if they want to use their uncles card. Is there a way to capture the billing name to use like this? The name appears in the progress bar so I thought that might work (as I don't show the bar). Something like that. But for all users even guest especially to add to the card form.
    – Freejoy
    Jan 1, 2016 at 16:44
  • Tye information given is what you need. You need to adjust the relevant templates to insert the customer information into the form fields as default, or adjust relevant titiles of sections.
    – ProxiBlue
    Jan 2, 2016 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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