Request Sample for Magento with Yes / No Attribute

Salams All

Currently we are redoing Website and they are using Magento ( :D) for their catalog

They sell mainly lovely nice Attars, Fragrances and Bakhoors as well as other stuff like Bakhoor Holders etc

So…On their website they wanted to offer the option for Customers to Order Samples of Certain Fragrances which they then ship out to customer

HOWEVER these samples were not applicable for all products for example Bakhoor Holders its a physical holder and you can’t really have samples for that lol!

Anyway Used the ParadoxLabs Request Sample Plugin which works a treat (Link here btw ) Big thanks for a lovely plugin

but this required a bit of small customisation from ourside to achieve what we wanted


Ok Step one

We Create attributes from Magento Backend

> Admin > catalog > Manage Attributes > Create new attribute

Attribute code: samplerequest

Scope: store view

Default Value: YES

Unique Value: NO

Catalog Input Type for Store Owner: YES / NO

Values Required: YES

Leave the rest upto you or as it is


Manage Label Option Tab: Request Sample link?  (Or you can put down whatever you want meaningful to you)

Then Save

Then Catalog > Attributes > Manage Attributes Set

Choose Default Set

Unassigned Attributes you find samplerequest there simply drag it across to under General or wherever you want to put it

reload your cache and you will now find that there is a new field which says “Request Sample link” and a drop down either Yes or no

Now We Browse the template file

Edit default.phtml (Or whatever template file you want

Then we add this Code right at the bottom

<?php if ($_product->getAttributeText(‘samplerequest’) == “Yes”): ?>
<p class=”availability in-stock”><a href=”<?php echo Mage::getBaseUrl(); ?>requestsample/?id=<?php echo $_product->getId() ?>”>Request a Sample</a></p>
<?php endif; ?>

The Bit in Orange is the code provided by the Plugin and the one above we did ourselves

So basically what this code says is that if “samplerequest” is set to YES then run the code in orange which is basically the request sample link and if set to no then display nothing


hope this helps 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s