Jump to content

Particular CCS Styling for product in gid=n


Samra

Recommended Posts

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 

 

css.png

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Samra
Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated