0

I want to add a class to a page when the order total reaches a certain level.

1 Answer 1

1

I came up with this piece of code, which seems to work:

function class_price_preprocess_html(&$variables){
  global $user;
  $order = commerce_cart_order_load($user->uid);
  if ($order) {
    $wrapper = entity_metadata_wrapper('commerce_order', $order);
    $line_items = $wrapper->commerce_line_items;
    $total = commerce_line_items_total($line_items);
    if($total['amount']>5000){
        $variables['classes_array'][] = "class-pr";          
    }
  }
}

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.