kreativi Posted April 30, 2011 Share Posted April 30, 2011 Finally I have done adding a URL field in product page. I was looking for it so that I can setup my affiliate shop easily and in the same time can enjoy all other prestashop features.I have modified a tutorial by Kerm a little more for the purpose. Check the steps below.In AdminProducts.php add following: '.$this->l('Affiliate URL:').' <input size="55" type="text" name="affurl" value="'.htmlentities($this->getFieldValue($obj, 'affurl'), ENT_COMPAT, 'UTF-8').'" style="width: 130px; margin-right: 44px;" /> '.$this->l('Enter Your Affiliate URL including http://').' in classes/product.php add following: /** @var string affurl */ public $affurl; where public function getFields() add: $fields['affurl'] = psql($this->affurl); In your theme product.tpl add: {if not $product->affurl==0}affurl|escape:'htmlall':'UTF-8'}" target="_blank" id="buy-now">{l s=''}{/if} In your theme css/product.css add: #buy-now { background: #f1f2f4 url(../img/button.jpg) repeat-x top left; font-size: 1.1em; color: #374853; margin-bottom: 1.5em; display: block; width: 200px; height: 50px; } In phpmyadmin, add new field in ps_product table, with name affurl with this parameters:Type: varchar(255), utf8_general_ci, NULL Yes, default NULLDesign button.jpg and upload it in your theme's image folder.I will update a link to website soon with working model of above tutorial. Link to comment Share on other sites More sharing options...
kreativi Posted May 1, 2011 Author Share Posted May 1, 2011 I am using PrestaShop 1.4.0.17 Link to comment Share on other sites More sharing options...
ChrisLNZ Posted May 1, 2011 Share Posted May 1, 2011 Thanks - useful share for all of us Link to comment Share on other sites More sharing options...
kreativi Posted May 14, 2011 Author Share Posted May 14, 2011 A little update:In your theme product.tpl add following {if not $product->affurl==0}affurl|escape:'htmlall':'UTF-8'}" target="_blank" id="buy-now">{l s=''}{/if} Link to comment Share on other sites More sharing options...
ishi Posted June 13, 2011 Share Posted June 13, 2011 Thanks for this. Exactly what I've been needing.I can't get the link to work correctly tho. I changed the code on product.tpl to: {if not $product->affurl==0}{l s='Buy Now'}{/if} Now it is a link but goes to my home page instead of the affiliate URL.You can see it in action here: http://ishigardens.com/product.php?id_product=1Any advice appreciated! Link to comment Share on other sites More sharing options...
kreativi Posted June 13, 2011 Author Share Posted June 13, 2011 Hi Ishi,There was a little mistake in in code for product.tplChange href to following; href="{$product->affurl|escape:'htmlall':'UTF-8'}" You can find this code working in following link. I hope this will work.http://www.dacarautos.com/car-care/18-meguiar-complete-car-care-kit.html Link to comment Share on other sites More sharing options...
ishi Posted June 13, 2011 Share Posted June 13, 2011 Perfect! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now