Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Success.phtml - Check If Customers First Order
 
imaginationx
Jr. Member
 
Total Posts:  6
Joined:  2009-05-13
 

Hello,

We are looking to display a custom coupon code on checkout success only if it is the customers first order. Is there a way to determine whether its the customers first order in success.phtml?

What we are looking to do is:

If Customer First Order Then
Show Coupon Code
Else
Show Nothing
End

We can handle the Coupon Code part, just need some help with determining if its the first order for this customer.

Thanks in advance, and your help is very appreciated.
JB

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

Try in success.phtml

<?php
$count 
Mage::getResourceModel('sales/order_collection')
    ->
addFieldToSelect('entity_id')
    ->
addFieldToFilter('customer_id'Mage::getSingleton('customer/session')->getCustomer()->getId())
    ->
count();
?>
<?php 
if ($count==1): ?>
You coupon code is <?php 
echo $couponCode?>
<?php 
endif; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
imaginationx
Jr. Member
 
Total Posts:  6
Joined:  2009-05-13
 

Thank you very much, I will give this a try and update the thread.

I really appreciate your help.

JB

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top