3

I am using Drupal 7, Ubercart, and Bootstrap. The default Add to cart button looks like this:

<button id="edit-submit-270" class="node-add-to-cart btn btn-success form-submit" value="Add to cart" name="op" type="submit">
  <span class="icon glyphicon glyphicon-plus" aria-hidden="true"></span>
  Add to cart
</button>

How can I change the <span> class from glyphicon-plus to glyphicon-shopping-cart?

2 Answers 2

0

Simple Solution is achieving it with simple Jquery line

$('span.icon.glyphicon.glyphicon-plus').removeClass('glyphicon-plus').addClass('glyphicon-shopping-cart');
0

Give it another class in your template.php file, and CSS does the rest

/**
 * @param $variables
*/
function yourtheme_preprocess_button(&$variables) {
  $variables['element']['#attributes']['class'] = array();
  $variables['element']['#attributes']['class'][] = 'btn';
  if (stristr($variables['element']['#value'], 'Add to cart') !== FALSE) {
    $variables['element']['#attributes']['class'][] = 'btn-cart';
  }
}

Your Answer

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

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