Request Sample for Magento with Yes / No Attribute

Request Sample for Magento with Yes / No Attribute

On a client  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 http://www.magentocommerce.com/magento-connect/paradoxlabs-requestsample.html ) 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
/public_html/store/app/design/frontend/default/themexxx/template/catalog/product/view/type/

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:)

Comments are closed.