In uc_ajax_cart_preprocess_uc_ajax_cart_block_content() of uc_ajax_cart.theme.inc, it is possible to have the function return by enabling uc_discounts or uc_discount_alt and having no discounts:

if ($discount_total) {
  return
}

If this branch executes, then $vars['items'] does not get set among other things, causing the template to use the cart item stdClass objects as arrays which causes a fatal PHP error. Attached patch resolves the problems.

Also, although not directly related to this issue, please consider using a different index in $vars than one that already exists (perhaps something like 'display_items' or 'ajax_cart_items') to avoid situations like this in the future. An empty array would cause an empty cart to be displayed, but a fatal error like this one stops the site from functioning entirely on certain pages.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stewart.adam’s picture

Status: Active » Needs review
FileSize
786 bytes

Patch attached, switching status to needs review.

stewart.adam’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.