Commerce

Delete all commerce orders and truncate tables


TRUNCATE commerce_customer_profile;
TRUNCATE commerce_customer_profile_revision;
TRUNCATE commerce_line_item;
TRUNCATE commerce_order;
TRUNCATE commerce_order_revision;
TRUNCATE commerce_payment_transaction;
TRUNCATE commerce_payment_transaction_revision;

TRUNCATE field_data_commerce_customer_address;
TRUNCATE field_data_commerce_customer_billing;
TRUNCATE field_data_commerce_customer_shipping;
TRUNCATE field_data_commerce_line_items;
TRUNCATE field_data_commerce_order_total;
TRUNCATE field_data_commerce_product;
TRUNCATE field_data_commerce_shipping_service;

Create a custom commerce checkout pane


/**
 * @module: 
 * Create a custom checkout pane for Drupal Commerce.
 */

/**
 * Implements hook_commerce_checkout_pane_info()
 */
function MY_MODULE_pane_commerce_checkout_pane_info() {
  $panes = array();
  // Custom checkout pane.
  $panes['CUSTOM_MODULE_PANE_NAME'] = array(
    'title' =--> t('Shipping service'),
    'page' => 'shipping',
    'weight' => 11,
    'base' => 'CUSTOM_MODULE_PANE_NAME_pane',
    'fieldset' => TRUE,
  );
  return $panes;
}

/**
 * Implements base_settings_form().
 */

Delete all commerce products

The commerce_product_delete_multiple function can be used to bulk delete products. Similar to other ENTITY_delete_multiple functions, an array of entity ids is passed as an argument.
Drupal_set_time_limit is used to override the default 30 seconds that a script is allowed to run.

Delete all commerce orders

The commerce_order_delete_multiple function can be used to bulk delete orders. Similar to other ENTITY_delete_multiple functions, an array of entity ids is passed as an argument.
Drupal_set_time_limit is used to override the default 30 seconds that a script is allowed to run.

Create a lightweight commerce cart block

We build a custom block and use hook_theme to render the cart data. Usually a view is made to create a custom shopping cart block. However, a custom block to render number of items and the total price of an order is more exciting to make and more performant than a view.

Subscribe to RSS - Commerce