Программный вывод количества товаров в корзине Drupal Commerce


14:42, 21/03/2018
uid);

    if ($cc_order) {
    $wrapper = entity_metadata_wrapper('commerce_order', $cc_order);
    $cc_line_items = $wrapper->commerce_line_items;
    $cc_quantity = commerce_line_items_quantity($cc_line_items, commerce_product_line_item_types());

    $cc_total = commerce_line_items_total($cc_line_items);

    // Get currency code
    $cc_currency = commerce_currency_load($cc_total['currency_code']);
    $cc_currency = $cc_currency['symbol'];

    // Format total summ
    $cc_total = substr($cc_total['amount'], 0, -2);
    $cc_total = number_format($cc_total, 0, ',', ' ');
    }

    $cc_items_in_cart = format_plural($cc_quantity, '1 item', '@count items');
?>







Комментарии