0

Category Page → price font color blue for Simple Products, for the configurable → color red

1 Answer 1

2

Magento add classes to the body tag. Use these classes to format the price. An example for the product detail page:

.price-box {
  color: blue;
}
.product-configurable .price-box,
.page-product-configurable .price-box {
  color: red;
}

Do you know, how to add custom css to your project?

This will only work for product detail pages. But this will not work for category pages. If you need the color code on the category page too, you have to add classes on overriding templates.

If you want to use css, you can overwrite the vendor/magento/module-catalog/view/frontend/templates/product/list.phtml file in your custom theme. Copy the file to app/{Vendor}/{theme}/Magento_Catalog/templates/product/list.phtml and add a class to the li element.

<li class="<?php echo $_product->getTypeId() === 'configurable' ? 'product-configurable'; ?> item product product-item" ... >

If you added the class to the li element, you can use the css code above.

2
  • thanks, its working Commented May 11, 2022 at 6:38
  • Happy to help, and welcome to magento stackexchange. If this answer solved your issue, please mark it as accepted. thanks. Commented May 12, 2022 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.