Samra Posted September 30, 2020 Share Posted September 30, 2020 Hello everyone, I have two groups of products and I use the same order form template to display the products.When I want to apply a particular CSS for the product name in specific product group I get the custom CSS applied in both product names of the group's products. What I want to achieve is : when I want to add custom CSS for the product name in gid=1 don't want it to be applied in gid=2 Thank you for help 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 1, 2020 Share Posted October 1, 2020 On 30/09/2020 at 14:05, Samra said: What I want to achieve is : when I want to add custom CSS for the product name in gid=1 don't want it to be applied in gid=2 if you're not going to do this using different orderform templates for each product group, then you'll likely have to use a hook to add your custom css code into the header/footer that triggers when gid=1 is in the URL. 1 Quote Link to comment Share on other sites More sharing options...
Samra Posted October 1, 2020 Author Share Posted October 1, 2020 (edited) 45 minutes ago, brian! said: if you're not going to do this using different orderform templates for each product group, then you'll likely have to use a hook to add your custom css code into the header/footer that triggers when gid=1 is in the URL. Please can you help me with the hook to add custom CSS for products in particular group ? I'm good with CSS but 00 with PHP 😞 Edited October 1, 2020 by Samra 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 2, 2020 Share Posted October 2, 2020 <?php # Premium Comparison Cart CSS Hook # Written by brian! function premium_comparison_cart_css_styling_hook($vars) { $validgroups = array(1); if ($vars['templatefile'] == 'products' && $vars['carttpl'] == 'premium_comparison' && in_array($vars['gid'],$validgroups)) { return '<style>h4 {background-color: #666 !important;}'; } } add_hook("ClientAreaFooterOutput",1,"premium_comparison_cart_css_styling_hook"); $validgroups is a list of applicable groups (if it's only gid=1, then it only needs to contain 1) if you had multiple individual product groups all using different styling, then you could just use if / elseif gid = x statements rather than in_array, with each returning different CSS based on your conditions. 1 Quote Link to comment Share on other sites More sharing options...
Samra Posted October 2, 2020 Author Share Posted October 2, 2020 4 hours ago, brian! said: <?php # Premium Comparison Cart CSS Hook # Written by brian! function premium_comparison_cart_css_styling_hook($vars) { $validgroups = array(1); if ($vars['templatefile'] == 'products' && $vars['carttpl'] == 'premium_comparison' && in_array($vars['gid'],$validgroups)) { return '<style>h4 {background-color: #666 !important;}'; } } add_hook("ClientAreaFooterOutput",1,"premium_comparison_cart_css_styling_hook"); $validgroups is a list of applicable groups (if it's only gid=1, then it only needs to contain 1) if you had multiple individual product groups all using different styling, then you could just use if / elseif gid = x statements rather than in_array, with each returning different CSS based on your conditions. Thank you very much great man. God bless you. Please do you think doing this with only CSS is good ? I mean clone the order form template with another name and change the IDs and class in style.css and premiumc.css and products.tpl 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 3, 2020 Share Posted October 3, 2020 21 hours ago, Samra said: Please do you think doing this with only CSS is good ? I mean clone the order form template with another name and change the IDs and class in style.css and premiumc.css and products.tpl if you're purely making CSS changes and not needing to change the template code / layout, then changing the CSS via a hook will be fine. 1 Quote Link to comment Share on other sites More sharing options...
Samra Posted October 5, 2020 Author Share Posted October 5, 2020 On 10/3/2020 at 6:00 PM, brian! said: if you're purely making CSS changes and not needing to change the template code / layout, then changing the CSS via a hook will be fine. Thank you Brian. unfortunately hook need advanced PHP developer like you. when I walk through this help community I found 99,99% of hook written by you. Thank you very much for all what you do with your heart to help other free. without you many users would have given up using WHMCS Thank you again and may god bless you 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.