Commerce v1 Upgrades v1.1

Most upgrades are automatically applied, but sometimes you may need to update custom templates, or configuration, to take advantage of new features or improvements. Those changes are discussed here.

Commerce v1.1 introduces new features and developer tools/utilities, but also cleans up legacy code that was marked as deprecated before v1.0.

v1.1 also bumps the minimum PHP version to 7.1 as a hard requirement, we've incorporated PHP 7.1 features in this release that will break on earlier versions of PHP. When upgrading, the installer will stop automatically if you run a too old version of PHP.

Items marked [Technical] only affect module developers. Other items may require action on implementations.

New infinite stock

It's now possible to set a product to have infinite stock. To use this in your product templates, see the product stock documentation.

New Stripe Card Gateway

We've added a new Stripe - Card gateway. If you're using the pre-1.1 version of the Stripe gateway (now renamed to Stripe - Legacy), you'll want to consider switching to take advantage of the new SCA-ready Payment Intents integration. We'll keep the legacy gateway around until at least v1.3.

[Technical] Twig abstracted into new View classes

To avoid future breaking changes, we've deprecated direct access to Twig (previously via $commerce->twig/$commerce->loadTwig()) and have implemented a new ViewInterface/TwigView. You can learn more about how to use the ViewInterface in the documentation.

To access the new View class, use $commerce->view(). On the resulting object, you can use render($template, $placeholders), renderString($stringTemplate, $placeholders) and addTemplatesPath($absolutePath) methods.

Modules that add custom loaders to Twig should rewrite to addTemplatesPath and any code that renders twig templates should refactor to the new render and renderString methods. We will keep the legacy $twig variable around until at least v1.3 to give you timeto migrate.

The modmore\Commerce\Pricing\Renderer\TwigRenderer class accepts either a \Twig\Environment or a ViewInterface instance for now; support for \Twig\Environment will be removed in v1.3.

[Technical] New Payment Gateway implementations

In v1.1 we've incorporated a brand new way of building payment gateways. The pre-1.1 based exclusively on Omnipay still works, and will continue to work for the time being, but new gateways should be based on the new classes and interfaces.

[Technical] Removed deprecated/defunct code

If you're using any of the constants, methods, variables, or classes detailed below, your code may break and cause a fatal error or warning (depending on context) when upgrading to v1.1.

Most of these deprecations date back to v0.8-v0.10 and were originally planned for removal in 1.0.

Removed deprecated event constants:

  • comAddress::EVENT_VALIDATE, use Commerce::EVENT_ADDRESS_VALIDATE
  • comOrder::EVENT_BEFORE_CALCULATE, use Commerce::EVENT_ORDER_BEFORE_CALCULATE
  • comOrder::EVENT_AFTER_CALCULATE, use Commerce::EVENT_ORDER_AFTER_CALCULATE
  • comOrder::EVENT_ITEM_ADDED, use Commerce::EVENT_ORDERITEM_ADDED
  • comOrder::EVENT_ITEM_UPDATED, use Commerce::EVENT_ORDERITEM_UPDATED
  • comOrder::EVENT_ITEM_REMOVED, use Commerce::EVENT_ORDERITEM_REMOVED
  • comOrder::EVENT_BEFORE_STATUS_CHANGE, use Commerce::EVENT_ORDER_BEFORE_STATUS_CHANGE
  • comOrder::EVENT_AFTER_STATUS_CHANGE, use Commerce::EVENT_ORDER_AFTER_STATUS_CHANGE
  • comOrder::EVENT_AFTER_PAYMENT_RECEIVED, use Commerce::EVENT_ORDER_PAYMENT_RECEIVED
  • comOrder::EVENT_GET_ORDER_ACTIONS, use Commerce::EVENT_ORDER_GET_ACTIONS, use Commerce::EVENT_DASHBOARD_ORDER_ACTIONS
  • comOrder::EVENT_CART_TO_PROCESSING_STATE, use Commerce::EVENT_STATE_CART_TO_PROCESSING
  • comOrder::EVENT_CART_TO_CANCELLED_STATE, use Commerce::EVENT_STATE_CART_TO_CANCELLED
  • comOrder::EVENT_PROCESSING_TO_COMPLETED_STATE, use Commerce::EVENT_STATE_PROCESSING_TO_COMPLETED
  • comOrder::EVENT_PROCESSING_TO_CANCELLED_STATE, use Commerce::EVENT_STATE_PROCESSING_TO_CANCELLED
  • comOrderAddress::EVENT_ADDED, use Commerce::EVENT_ORDER_ADDRESS_ADDED
  • comOrderItem::EVENT_BEFORE_CALCULATE, use Commerce::EVENT_ORDERITEM_BEFORE_CALCULATE
  • comOrderItem::EVENT_AFTER_CALCULATE, use Commerce::EVENT_ORDERITEM_AFTER_CALCULATE
  • Commerce::EVENT_ORDER_GET_ACTIONS, use Commerce::EVENT_DASHBOARD_ORDER_ACTIONS
  • Commerce::EVENT_DASHBOARD_GET_PAGES, use Commerce::EVENT_DASHBOARD_INIT_GENERATOR
  • modmore\Commerce\Admin\Generator::COLLECT_PAGES_EVENT, use Commerce::EVENT_DASHBOARD_GET_PAGES
  • modmore\Commerce\Admin\Generator::COLLECT_MENU_EVENT, use Commerce::EVENT_DASHBOARD_GET_MENU
  • modmore\Commerce\Admin\Page::EVENT_BEFORE_GENERATE, use Commerce::EVENT_DASHBOARD_PAGE_BEFORE_GENERATE
  • modmore\Commerce\Admin\Configuration\Checklist::EVENT_GET_CHECKS, use \Commerce::EVENT_DASHBOARD_CHECKLIST_GET_CHECKS
  • modmore\Commerce\Frontend\Checkout\Process::BEFORE_PROCESS_STEP, use \Commerce::EVENT_CHECKOUT_BEFORE_STEP
  • modmore\Commerce\Frontend\Checkout\Process::AFTER_PROCESS_STEP, use \Commerce::EVENT_CHECKOUT_AFTER_STEP
  • modmore\Commerce\Reports\ReportInterface::EVENT_GET_REPORTS, use \Commerce::EVENT_DASHBOARD_REPORTS_GET_REPORT
  • modmore\Commerce\Taxes\RateProvider::COLLECT_RATE_PROVIDERS = \Commerce::EVENT_DASHBOARD_GET_RATE_PROVIDERS

Removed deprecated methods/variables:

  • modmore\Commerce\Frontend\Steps\Shipping::getShipments - replaced by comOrder::getShipments
  • modmore\Commerce\Frontend\Steps\Shipping::getItemsByDeliveryType - replaced by comOrder::getShipments
  • comOrder::getItemsByDeliveryType() - replaced by comOrderShipment objects
  • comOrder::$_itemsByDeliveryType
  • comOrder::getShippingPrice() - replaced by comOrderShipment objects
  • comOrder::setShippingMethod($methodId) - replaced by a shipping method being set on the order shipment
  • comOrder::removeAddress($address) - simply remove the comOrderAddress record or use removeAddressType instead
  • comAddress::getTextSummary() - use Commerce::formatAddress
  • comOrderAddress::getAddress() - use the comOrderAddress information directly
  • comShippingMethodByWeight::getTotalOrderWeight($order) - use comOrderShipment->getWeight() instead
  • Commerce\Events\Address->getAddress() - use information from getOrderAddress() instead
  • Commerce\Events\Address->getAddressJoin() - use information from getOrderAddress() instead
  • Commerce\Events\AddressValidation::getOrder()
  • modmore\Commerce\Frontend\Checkout\Process::completeOrder - replaced by comOrder::triggerPaidStatusChange
  • modmore\Commerce\Modules\Discounts::loadPage() - replaced by initGenerator()

Removed classes:

  • modmore\Commerce\Frontend\Requirements\ShippingMethod - replaced with modmore\Commerce\Frontend\Requirements\ShipmentsWithMethod
  • modmore\Commerce\Frontend\Checkout\NoAccount, OnePage, and RequiresAccount, replaced by configuration on Standard checkout process

Other changes from cleaned up deprecated functionality:

  • Commerce\Events\AddressValidation constructor no longer accepts a comOrder
  • modmore\Commerce\Pricing\PriceType\Quantity no longer accepts [prices:[..]] instead of [..] serialised data
  • Checkout templates no longer have a shipping_method placeholder