Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
5be879d
Issue #2923656 by czigor, kiwimind, opdavies, utement: Unable to use …
Nov 24, 2017
0472e91
Issue #2925745 by ptmkenny: Commerce Payment credit card errors canno…
Nov 24, 2017
080e26f
Issue #2926518 by alexpott: AdjustmentItemList::getAdjustments() can …
Nov 28, 2017
eca0e04
Issue #2924930 by alexpott: Support #title_display on commerce_price …
Nov 28, 2017
d5b83ab
Issue #2926563 by alexpott: Adjustment label is required but not on t…
Nov 28, 2017
4d9b905
Issue #2923388 by alexpott: Add #ajax support to the commerce_price f…
Nov 28, 2017
979a4df
Issue #2891770 by bojanz, Baik Ho: ProductVariationSkuConstraintValid…
Nov 30, 2017
4ce7390
Issue #2926542 by alexpott, sorabh.v6: Adjustments added via Adjustme…
Nov 30, 2017
654bf3d
Issue #2922811 by bradjones1, bojanz: Deprecate BundleFieldDefinition…
bradjones1 Dec 2, 2017
108faa5
Issue #2921303 by joachim, bojanz: 'Great Britain' in tax rates list …
bojanz Dec 2, 2017
f526dbe
Issue 2889607: Create a views argument default plugin to extract a Pr…
thomascys Dec 2, 2017
0e6d50a
Fix the Travis build failure caused by Symfony 4.0
bojanz Dec 3, 2017
2b54f6d
Issue #2926000 by joachim, bojanz: Deprecate CommercePluginEntityForm…
bojanz Dec 3, 2017
70ab01e
Issue #2866638 by chrisrockwell, nicola85, subhojit777, bojanz, suman…
Dec 3, 2017
59a6f5d
Issue #2928972 by bojanz: Add PaymentGatewayBase::toMinorUnits()
bojanz Dec 6, 2017
c7c387c
Issue #2922381 by Rob C: Unable to export the 'online' store entity f…
robincee Nov 13, 2017
1688ed6
Issue #2882378 by Rob C, mglaman, zenimagine: Cannot access edit rout…
robincee Dec 8, 2017
631ee7d
Issue #2848183 by mglaman, agoradesign, vasike: TimestampEventSubscri…
vasike Dec 8, 2017
b0f013f
Issue #2922147 by mglaman, GoZ: Delete a coupon does not delete coupo…
GoZOo Dec 9, 2017
7af1dd8
Issue #2860840 by mglaman, mgoncalves, Sarahphp1, durum, sorabh.v6, p…
Dec 11, 2017
4194826
Issue #2930502 by joachim: add a helper method Payment::isCompleted()
joachim-n Dec 14, 2017
e6deea1
Issue #2921896 by ryross, bojanz: Coupon field autofills with address…
Dec 15, 2017
4691303
Issue #2923337 by flocondetoile: Quick edit error when rendering comm…
Dec 15, 2017
cb3d04b
Issue #2926563 by alexpott, sorabh.v6, harings_rob, bojanz: Adjustmen…
Dec 19, 2017
e83802a
Issue #2931920 by bojanz: CreditCard::detectType() mismatch between r…
bojanz Dec 19, 2017
725c574
Issue #2932197 by rszrama, joachim, bojanz: Expand the comments for P…
Dec 20, 2017
a28da92
Issue #2932158 by rynnnner, bojanz: Regression in PaymentMethodAddFor…
Dec 21, 2017
05ac550
Issue #2920544 by Lukas von Blarer: Swiss tax rates change on 01/01/2018
Dec 28, 2017
2f051d5
Issue #2933375: TaxRate::getPercentage() doesn't assume end dates are…
bojanz Dec 28, 2017
8c6a11d
Issue #2935523 by ritzz: entity-meta__title class is a string not an …
Jan 10, 2018
cfc6b8b
Issue #2934672 by joachim: product title field should be configurable…
joachim-n Jan 10, 2018
0e5a3fb
Issue #2884083 by mglaman, bradjones1: Product variant pages generate…
Jan 10, 2018
a69bb37
Issue #2924736 by bojanz: Allow bundle config entities to be locked
Jan 12, 2018
eb71ee2
Issue #2936869: Expand adjustment type labels, add singular_label and…
bojanz Jan 15, 2018
604f1fa
Issue #2936705 by edwardaa: Remove legacy fieldable attribute
Jan 15, 2018
5b14399
Issue #2915167 by MegaChriz, jp.stacey, bojanz: Add a commerce_produc…
Jan 15, 2018
e60673b
Issue #2932776 by mistermoper, dhwani.addweb: Prefix all dependencies…
Jan 17, 2018
5d8ea6a
Issue #2937523 by bojanz: Clean up EntityAccessControlHandler usage
bojanz Jan 17, 2018
e7a7ea7
Issue #2937039 by bojanz: Cannot use BundleFieldDefinition; the name …
bojanz Jan 18, 2018
9ffca6f
Issue #2930209 by alexpott: Random fail in PaymentMethodStorageTest
Jan 18, 2018
4cb9e25
Issue #2936982 by bojanz: Expand OrderNumberSubscriber docs with a be…
bojanz Jan 18, 2018
6a220e8
Issue #2909308 by alexpott: CouponRedemptionPaneTest fails
Jan 29, 2018
612abd6
Issue #2922450 by joachim, bojanz: The cart should always show tax fo…
bojanz Feb 6, 2018
ed774b5
Issue #2939048 by EclipseGc: Required order item fields will fail val…
Feb 6, 2018
9097999
Issue #2871569 by bucefal91, bojanz: OrderTotalSummary and OrderItemT…
Feb 6, 2018
40c724a
Issue #2867430 by bmcclure, vasike, bojanz, finne: Add empty text to …
vasike Feb 6, 2018
97b538b
Issue #2929994 by GoZ, bojanz: Clarify OrderRefreshInterface::refresh…
GoZOo Feb 8, 2018
034b3a9
Issue #2943525 by bojanz, edurenye: Clean up PriceCalculatedFormatter
Feb 9, 2018
d006d19
Issue #2805549 by lisastreeter, edurenye, mglaman, flocondetoile, boj…
Jan 18, 2018
b55440f
Issue #2943621 by bojanz: Add arithmetic methods to Adjustment
bojanz Feb 9, 2018
7d068d5
Issue #2943585 by bojanz: Use a value object for the result returned …
bojanz Feb 9, 2018
7d71e14
Issue #2943767 by agoradesign, pazhyn: README still contains beta notice
Feb 10, 2018
e4f01cf
Issue #2943187 by jafacakes2011: Check payment method for existing bi…
Feb 10, 2018
8eb2d44
Issue #2939331 by facine, bojanz: PaymentMethod defines a bogus canon…
Feb 10, 2018
77b25bf
Issue #2939331 followup: Fix tests by removing the unused payment_met…
bojanz Feb 10, 2018
b40230f
Issue #2914176 by agoradesign: Improve TimestampEventSubscriber's dep…
Feb 10, 2018
046ff05
Issue #2903544 by Lendude: \Drupal\commerce_order\Plugin\views\area\O…
Feb 10, 2018
2d5cd0a
Issue #2908419 by edwardaa: Allow for a payment gateway object when c…
Feb 10, 2018
d87e374
Issue #2901324 by jsacksick, bojanz, edurenye: Make the $store argume…
Feb 11, 2018
2b266e7
Issue #2943961: Create a AdjustmentTransformer service for combining/…
bojanz Feb 11, 2018
3b20e5c
Issue #2944082 by bojanz: Provide a fallback singular_label/plural_la…
bojanz Feb 12, 2018
de2a698
Issue #2928828 by mortona2k, bojanz: Order-level adjustment rounding …
bojanz Feb 12, 2018
3692645
Issue #2926559 by bojanz, rszrama, lisastreeter: Apply order promotio…
bojanz Feb 12, 2018
1838bc9
Issue #2910190 by sorabh.v6, casey, harings_rob, bojanz: PriceTwigExt…
bojanz Feb 12, 2018
6c48440
Issue #2946655 by agoradesign: _commerce_entity_theme_suggestions() n…
Feb 22, 2018
5be779d
Issue #2946659 by agoradesign: ProductForm is trying to attach an non…
Feb 22, 2018
9fcd817
Issue #2944954 by robin.ingelbrecht: AddToCartForm submit handler nee…
Feb 22, 2018
0b1f41c
Issue #2947365 by agoradesign: PromotionStorage::loadAvailable is usi…
Feb 23, 2018
1db38f5
Issue #2917372 by osab, andypost, joachim, mglaman: incorrect use of …
Feb 25, 2018
92891ba
Issue #2940592 by mglaman, huzooka, bojanz: Inconsistent view mode of…
Feb 26, 2018
4285fc9
Issue #2941834 by mglaman, Lukas von Blarer: Add to cart form doesn't…
Feb 27, 2018
8b7cc9b
Issue #2948027 by lisastreeter: Make the Promotion End Date Widget a …
Feb 27, 2018
a06dd01
Issue #2923337 followup: Fix regression that broke theme suggestions …
bojanz Mar 4, 2018
2726f7d
Issue #2902882 by lisastreeter, bojanz, mglaman: Allow for bulk creat…
Mar 7, 2018
c531ab3
Issue #2950745 by bojanz: Require Drupal 8.5.x
bojanz Mar 7, 2018
ee61791
Issue #2950813 by bojanz: Replace drupal_set_message() with the Messe…
bojanz Mar 7, 2018
4829744
Issue #2952530 by bojanz: Replace drupal_set_message() in checkout panes
bojanz Mar 13, 2018
dd2b53a
Issue #2882905 by Hubbs, mglaman: Add unique identifier for stored pa…
Mar 13, 2018
845eb28
Issue #2950989 by ctrlADel, mglaman, bojanz: Don't call toUrl() on un…
Mar 14, 2018
3641d2e
Issue #2945286 by agoradesign, mglaman, bojanz: The "access overview"…
Mar 14, 2018
445f106
Issue #2856583 by mglaman, nikathone, jonnyeom, bojanz, chrisrockwell…
Mar 14, 2018
936de53
Issue #2927114 by sorabh.v6, mglaman, bojanz, heddn: Rework the "no p…
Mar 15, 2018
2e6f969
Issue #2952849 by Lendude: Random test fail in Drupal\Tests\commerce_…
Mar 16, 2018
0be0468
Issue #2707721 by drugan, mglaman, skek, AndreaMaggi, ransomweaver: I…
Mar 16, 2018
8d3f5b7
Issue #2953865 by alianov: Move PaymentMethodAccessCheck to a differe…
Mar 17, 2018
26996a5
Revert "Issue #2707721 by drugan, mglaman, skek, AndreaMaggi, ransomw…
bojanz Mar 17, 2018
6353a0d
Issue #2953599 by agoradesign: Wrong return type in DocBlock for getP…
Mar 17, 2018
05042bc
Issue #2949406 by alianov, bojanz, Kate Heinlein: Make CountryReposit…
Mar 17, 2018
8d7728d
Issue #2953843 by quietone: Make product body field translatable
Mar 20, 2018
e27d48d
Issue #2861983 by trigdog, joe1987uk, drugan, shabana.navas, sorabh.v…
bojanz Mar 21, 2018
8062c3f
Issue #2954572 by karlos007: Update composer.json to indicate the min…
Mar 21, 2018
ee6aa05
Issue #2953937 by agoradesign: Clean up PriceCalculatedFormatter vari…
Mar 21, 2018
fb6167f
Issue #2954205 by abramm: Missing $order_item->getTotalPrice() return…
Mar 21, 2018
fd9826a
Issue #2944402 by bojanz, agoradesign, tce: Cart totals are not updat…
bojanz Mar 22, 2018
0054dd4
Issue #2897813 by waspper, bojanz: Remove the 'access cart' permissio…
bojanz Mar 22, 2018
26bb76f
Issue #2951181 by joachim, bojanz: QuantityWidget allows "0" as a val…
bojanz Mar 22, 2018
def442d
Issue #2955241: Plugin label 'order item table' should be in sentence…
bojanz Mar 22, 2018
ec32a7b
Issue #2882374 by xSDx, Lendude, drugan, bojanz: Views filters are br…
Mar 22, 2018
c80b602
Issue #2900772 by FatherShawn, abramm, bojanz: The payment method ent…
Mar 22, 2018
ac5cb9b
Issue #2853277 by lisastreeter: Populate OrderItem backreference to O…
Mar 22, 2018
afd53f6
Issue #2865324 by Dom., bojanz: Make the commerce_order_item "created…
Mar 22, 2018
9276e9a
Issue #2707721 by mglaman, drugan, skek, AndreaMaggi, ransomweaver, n…
Mar 24, 2018
8565b2f
Issue #2808813: New user account should own previous guest checkout o…
steveoliver Sep 29, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ env:

# The environment to use, supported are: drupal-7, drupal-8
- DRUPAL_TI_ENVIRONMENT="drupal-8"
- DRUPAL_TI_CORE_BRANCH="8.4.x"
- DRUPAL_TI_CORE_BRANCH="8.5.x"

# Drupal specific variables.
- DRUPAL_TI_DB="drupal_travis_db"
Expand All @@ -51,8 +51,8 @@ env:
- DRUPAL_TI_WEBSERVER_PORT="8080"

# Simpletest specific commandline arguments, the DRUPAL_TI_SIMPLETEST_GROUP is appended at the end.
- DRUPAL_TI_SIMPLETEST_ARGS="--verbose --color --concurrency 20 --url $DRUPAL_TI_WEBSERVER_URL:$DRUPAL_TI_WEBSERVER_PORT --types Simpletest,PHPUnit-Unit,PHPUnit-Kernel,PHPUnit-Functional"
- DRUPAL_TI_SIMPLETEST_JS_ARGS="--verbose --color --concurrency 1 --url $DRUPAL_TI_WEBSERVER_URL:$DRUPAL_TI_WEBSERVER_PORT --types PHPUnit-FunctionalJavascript"
- DRUPAL_TI_SIMPLETEST_ARGS="--verbose --color --concurrency 20 --url $DRUPAL_TI_WEBSERVER_URL:$DRUPAL_TI_WEBSERVER_PORT --types Simpletest,PHPUnit-Unit,PHPUnit-Kernel,PHPUnit-Functional --suppress-deprecations"
- DRUPAL_TI_SIMPLETEST_JS_ARGS="--verbose --color --concurrency 1 --url $DRUPAL_TI_WEBSERVER_URL:$DRUPAL_TI_WEBSERVER_PORT --types PHPUnit-FunctionalJavascript --suppress-deprecations"

# === Behat specific variables.
# This is relative to $TRAVIS_BUILD_DIR
Expand Down Expand Up @@ -107,8 +107,6 @@ before_install:
- composer global require "hirak/prestissimo:^0.3"
- composer global require "lionsad/drupal_ti:dev-master#396d11d200005eb68491d24170da0a98ae7f51b3"
- composer global require "squizlabs/php_codesniffer:2.*"
- composer global require "drupal/coder:8.2.*"
- phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer
- drupal-ti before_install

install:
Expand All @@ -118,6 +116,9 @@ install:
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs
- export PATH=$PWD/travis-phantomjs:$PATH
- phantomjs --version
# Installed after Drush to prevent Composer conflicts around symfony/yaml.
- composer global require "drupal/coder:8.2.*"
- phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer

before_script:
- drupal-ti --include ".travis-before-script.sh"
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Drupal Commerce
Drupal Commerce is the leading flexible eCommerce solution for Drupal,
powering over 60,000 online stores of all sizes.

Note: 8.x-2.x is in beta. It is already usable for production websites
and upgrades between versions are supported. Bugs are still expected.
Please report bugs in the [issue queue](https://www.drupal.org/project/issues/commerce?version=8.x).

[Documentation](http://docs.drupalcommerce.org)
Expand Down
2 changes: 1 addition & 1 deletion commerce.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ dependencies:
- datetime
- inline_entity_form
- views
- system (>=8.4.0)
- system (>=8.5.0)
1 change: 0 additions & 1 deletion commerce.module
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function _commerce_entity_theme_suggestions($entity_type_id, array $variables) {
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');

$suggestions = [];
$suggestions[] = $original;
$suggestions[] = $original . '__' . $sanitized_view_mode;
$suggestions[] = $original . '__' . $entity->bundle();
$suggestions[] = $original . '__' . $entity->bundle() . '__' . $sanitized_view_mode;
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"homepage": "http://drupal.org/project/commerce",
"license": "GPL-2.0+",
"require": {
"drupal/core": "~8.4",
"drupal/core": "~8.5",
"drupal/address": "~1.0",
"drupal/entity": "~1.0",
"drupal/entity": "^1.0-beta3",
"drupal/entity_reference_revisions": "~1.0",
"drupal/inline_entity_form": "~1.0",
"drupal/profile": "~1.0",
Expand Down
3 changes: 3 additions & 0 deletions config/schema/commerce.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ commerce_config_entity_bundle:
orderby: value
sequence:
type: string
locked:
type: boolean
label: 'Locked'

commerce_condition:
type: mapping
Expand Down
4 changes: 1 addition & 3 deletions modules/cart/commerce_cart.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ description: 'Implements the shopping cart system and add to cart features.'
package: Commerce
core: 8.x
dependencies:
- commerce
- commerce:commerce
- commerce:commerce_order
- commerce:commerce_price
- commerce:commerce_product
- views
config_devel:
install:
- core.entity_form_mode.commerce_order_item.add_to_cart
Expand Down
17 changes: 0 additions & 17 deletions modules/cart/commerce_cart.install

This file was deleted.

29 changes: 0 additions & 29 deletions modules/cart/commerce_cart.module
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\views\Form\ViewsForm;

/**
* Implements hook_menu_links_discovered_alter().
Expand Down Expand Up @@ -215,34 +214,6 @@ function commerce_cart_form_commerce_order_type_form_alter(array &$form, FormSta
$form['actions']['submit']['#submit'][] = 'commerce_cart_order_type_form_submit';
}

/**
* Implements hook_form_alter().
*/
function commerce_cart_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_state->getFormObject() instanceof ViewsForm) {
/** @var \Drupal\views\ViewExecutable $view */
$view = reset($form_state->getBuildInfo()['args']);
if ($view->storage->get('tag') == 'commerce_cart_form' && !empty($view->result)) {
$form['actions']['submit']['#submit'] = array_merge($form['#submit'], ['commerce_cart_order_item_views_form_submit']);
$form['actions']['submit']['#order_id'] = $view->argument['order_id']->value[0];
}
}
}

/**
* Form submission handler for 'views_form_commerce_cart_form_'.
*/
function commerce_cart_order_item_views_form_submit($form, FormStateInterface $form_state) {
if (!$form_state->has('quantity_updated')) {
return;
}
$order_id = $form_state->getTriggeringElement()['#order_id'];
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = \Drupal::entityTypeManager()->getStorage('commerce_order')->load($order_id);
$order->save();
drupal_set_message(t('Your shopping cart has been updated.'));
}

/**
* Form submission handler for 'commerce_order_type_form'.
*/
Expand Down
3 changes: 0 additions & 3 deletions modules/cart/commerce_cart.permissions.yml

This file was deleted.

2 changes: 1 addition & 1 deletion modules/cart/commerce_cart.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ commerce_cart.page:
_controller: '\Drupal\commerce_cart\Controller\CartController::cartPage'
_title: 'Shopping cart'
requirements:
_permission: 'access cart'
_access: 'TRUE'
4 changes: 2 additions & 2 deletions modules/cart/commerce_cart.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:

commerce_cart.cart_provider:
class: Drupal\commerce_cart\CartProvider
arguments: ['@entity_type.manager', '@current_user', '@commerce_cart.cart_session']
arguments: ['@entity_type.manager', '@commerce_store.current_store', '@current_user', '@commerce_cart.cart_session']

commerce_cart.cart_manager:
class: Drupal\commerce_cart\CartManager
Expand All @@ -23,7 +23,7 @@ services:

commerce_cart.cart_subscriber:
class: Drupal\commerce_cart\EventSubscriber\CartEventSubscriber
arguments: ['@string_translation']
arguments: ['@messenger', '@string_translation']
tags:
- { name: event_subscriber }

Expand Down
1 change: 1 addition & 0 deletions modules/cart/src/CartManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function addOrderItem(OrderInterface $cart, OrderItemInterface $order_ite
$saved_order_item = $matching_order_item;
}
else {
$order_item->set('order_id', $cart->id());
$order_item->save();
$cart->addItem($order_item);
$saved_order_item = $order_item;
Expand Down
21 changes: 17 additions & 4 deletions modules/cart/src/CartProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\commerce_cart\Exception\DuplicateCartException;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_store\CurrentStoreInterface;
use Drupal\commerce_store\Entity\StoreInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountInterface;
Expand All @@ -20,6 +21,13 @@ class CartProvider implements CartProviderInterface {
*/
protected $orderStorage;

/**
* The current store.
*
* @var \Drupal\commerce_store\CurrentStoreInterface
*/
protected $currentStore;

/**
* The current user.
*
Expand Down Expand Up @@ -57,21 +65,25 @@ class CartProvider implements CartProviderInterface {
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\commerce_store\CurrentStoreInterface $current_store
* The current store.
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current user.
* @param \Drupal\commerce_cart\CartSessionInterface $cart_session
* The cart session.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, AccountInterface $current_user, CartSessionInterface $cart_session) {
public function __construct(EntityTypeManagerInterface $entity_type_manager, CurrentStoreInterface $current_store, AccountInterface $current_user, CartSessionInterface $cart_session) {
$this->orderStorage = $entity_type_manager->getStorage('commerce_order');
$this->currentStore = $current_store;
$this->currentUser = $current_user;
$this->cartSession = $cart_session;
}

/**
* {@inheritdoc}
*/
public function createCart($order_type, StoreInterface $store, AccountInterface $account = NULL) {
public function createCart($order_type, StoreInterface $store = NULL, AccountInterface $account = NULL) {
$store = $store ?: $this->currentStore->getStore();
$account = $account ?: $this->currentUser;
$uid = $account->id();
$store_id = $store->id();
Expand Down Expand Up @@ -124,7 +136,7 @@ public function finalizeCart(OrderInterface $cart, $save_cart = TRUE) {
/**
* {@inheritdoc}
*/
public function getCart($order_type, StoreInterface $store, AccountInterface $account = NULL) {
public function getCart($order_type, StoreInterface $store = NULL, AccountInterface $account = NULL) {
$cart = NULL;
$cart_id = $this->getCartId($order_type, $store, $account);
if ($cart_id) {
Expand All @@ -137,10 +149,11 @@ public function getCart($order_type, StoreInterface $store, AccountInterface $ac
/**
* {@inheritdoc}
*/
public function getCartId($order_type, StoreInterface $store, AccountInterface $account = NULL) {
public function getCartId($order_type, StoreInterface $store = NULL, AccountInterface $account = NULL) {
$cart_id = NULL;
$cart_data = $this->loadCartData($account);
if ($cart_data) {
$store = $store ?: $this->currentStore->getStore();
$search = [
'type' => $order_type,
'store_id' => $store->id(),
Expand Down
12 changes: 6 additions & 6 deletions modules/cart/src/CartProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface CartProviderInterface {
* @param string $order_type
* The order type ID.
* @param \Drupal\commerce_store\Entity\StoreInterface $store
* The store.
* The store. If empty, the current store is assumed.
* @param \Drupal\Core\Session\AccountInterface $account
* The user. If empty, the current user is assumed.
*
Expand All @@ -29,7 +29,7 @@ interface CartProviderInterface {
* @throws \Drupal\commerce_cart\Exception\DuplicateCartException
* When a cart with the given criteria already exists.
*/
public function createCart($order_type, StoreInterface $store, AccountInterface $account = NULL);
public function createCart($order_type, StoreInterface $store = NULL, AccountInterface $account = NULL);

/**
* Finalizes the given cart order.
Expand All @@ -51,29 +51,29 @@ public function finalizeCart(OrderInterface $cart, $save_cart = TRUE);
* @param string $order_type
* The order type ID.
* @param \Drupal\commerce_store\Entity\StoreInterface $store
* The store.
* The store. If empty, the current store is assumed.
* @param \Drupal\Core\Session\AccountInterface $account
* The user. If empty, the current user is assumed.
*
* @return \Drupal\commerce_order\Entity\OrderInterface|null
* The cart order, or NULL if none found.
*/
public function getCart($order_type, StoreInterface $store, AccountInterface $account = NULL);
public function getCart($order_type, StoreInterface $store = NULL, AccountInterface $account = NULL);

/**
* Gets the cart order ID for the given store and user.
*
* @param string $order_type
* The order type ID.
* @param \Drupal\commerce_store\Entity\StoreInterface $store
* The store.
* The store. If empty, the current store is assumed.
* @param \Drupal\Core\Session\AccountInterface $account
* The user. If empty, the current user is assumed.
*
* @return int|null
* The cart order ID, or NULL if none found.
*/
public function getCartId($order_type, StoreInterface $store, AccountInterface $account = NULL);
public function getCartId($order_type, StoreInterface $store = NULL, AccountInterface $account = NULL);

/**
* Gets all cart orders for the given user.
Expand Down
22 changes: 16 additions & 6 deletions modules/cart/src/EventSubscriber/CartEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,35 @@

namespace Drupal\commerce_cart\EventSubscriber;

use Drupal\Core\Messenger\MessengerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\commerce_cart\Event\CartEntityAddEvent;
use Drupal\commerce_cart\Event\CartEvents;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;

class CartEventSubscriber implements EventSubscriberInterface {

use StringTranslationTrait;

/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;

/**
* Constructs a new CartEventSubscriber object.
*
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation.
*/
public function __construct(TranslationInterface $string_translation) {
public function __construct(MessengerInterface $messenger, TranslationInterface $string_translation) {
$this->messenger = $messenger;
$this->stringTranslation = $string_translation;
}

Expand All @@ -40,10 +51,9 @@ public static function getSubscribedEvents() {
* The add to cart event.
*/
public function displayAddToCartMessage(CartEntityAddEvent $event) {
$purchased_entity = $event->getEntity();
drupal_set_message($this->t('@entity added to @cart-link.', [
'@entity' => $purchased_entity->label(),
'@cart-link' => Link::createFromRoute($this->t('your cart', [], ['context' => 'cart link']), 'commerce_cart.page')->toString(),
$this->messenger->addMessage($this->t('@entity added to <a href=":url">your cart</a>.', [
'@entity' => $event->getEntity()->label(),
':url' => Url::fromRoute('commerce_cart.page')->toString(),
]));
}

Expand Down
2 changes: 1 addition & 1 deletion modules/cart/src/Form/AddToCartForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
if (!$cart) {
$cart = $this->cartProvider->createCart($order_type_id, $store);
}
$this->cartManager->addOrderItem($cart, $order_item, $form_state->get(['settings', 'combine']));
$this->entity = $this->cartManager->addOrderItem($cart, $order_item, $form_state->get(['settings', 'combine']));
// Other submit handlers might need the cart ID.
$form_state->set('cart_id', $cart->id());
}
Expand Down
Loading