On my Drupal 6 / Ubercart 2.9 cart website, I have the need to modify the CSS of the checkout page when a certain product is in the cart. For instance, if the customer is ordering red flowers, the background would change to a red flower background image. Is this possible via CSS? If not, any other ideas on how it can be done?



I have two ideas:

1) render the code of the article in the class attribute of the cart div. you can do that "intercepting" the render function in your template.php file.

2) using jquery

  • Do you have an example of the jquery method that you can point me towards?
    – hockey2112
    Dec 20 '12 at 21:37
  • Also, what about passing a value in the URL? Is that a possible method of providing the ability to customize the CSS for that page based on whether that parameter is passed in the URL? If so, how would that be accomplished?
    – hockey2112
    Dec 20 '12 at 22:21
  • 1
    JQUERY: I opened an ubercart cart and saw that -unfortunally- there wasn't an id of the product mentioned in the html <tr>. But there was the href (yourdomain/catalog/section/productname). So you can solve with this line of code in your script head tag: $(document).ready(function () { if ($("a['yourdomain/catalog/section/productname']")) { $("#cart-form-pane").css('background','red') } }); Dec 21 '12 at 8:12
  • URL: instead of url, you can intercept the cart render function in yourthemename/template.php file, in order to append a class to the <div id='cart-form-pane'> tag. But I can't help you there...maybe this post could be useful: www.ubercart.org/forum/development/3868/nifty_products_tutorial_part_1 Dec 21 '12 at 8:15
  • 1
    Looks like the Jquery Update (drupal.org/project/jquery_update) module was causing the issue. I disabled that module, and the jquery method now works fine on that other live site.
    – hockey2112
    Jan 3 '13 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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