Commit b60c05db authored by Sardis's avatar Sardis Committed by das-peter

Issue #2755871 by Sardis, Valentine94: Fix coding standarts

parent 1ea032ee
This diff is collapsed.
<?php
/**
* @file Contains updade hooks for the commerce_shipping module.
* @file
* Contains update hooks for the commerce_shipping module.
*/
/**
* Implements hook_schema().
*/
......@@ -41,7 +41,7 @@ function commerce_shipping_update_7000(&$sandbox) {
}
/**
* Add default profile reference field on order if needed
* Add default profile reference field on order if needed.
*/
function commerce_shipping_update_7001(&$sandbox) {
$profile_types = commerce_shipping_commerce_customer_profile_type_info();
......@@ -51,8 +51,7 @@ function commerce_shipping_update_7001(&$sandbox) {
}
/**
* Remove all old shipping rules and convert plugin type shipping rules to use
* the new naming convention.
* Tweak shipping rules to use the new naming convention.
*/
function commerce_shipping_update_7002(&$sandbox) {
$rules = rules_config_load_multiple(FALSE);
......@@ -86,7 +85,8 @@ function commerce_shipping_update_7002(&$sandbox) {
}
}
// Rules doesn't provide any APIs to change the elementName of rule actions, so we modify them directly in the database.
// Rules doesn't provide any APIs to change the elementName of rule actions,
// so we modify them directly in the database.
$result = db_select('rules_config', 'r')
->fields('r', array('data', 'id'))
->condition('r.name', $rules_actions_to_rename, 'IN')
......@@ -96,7 +96,7 @@ function commerce_shipping_update_7002(&$sandbox) {
preg_match('/(\d+):"commerce_shipping_enable_plugin-/', $row->data, $matches);
if (!empty($matches[1])) {
$replace = $matches[1] - 7;
$data = preg_replace('/\d+(:"commerce_shipping_enable_)plugin-/', $replace . '$1' , $row->data);
$data = preg_replace('/\d+(:"commerce_shipping_enable_)plugin-/', $replace . '$1', $row->data);
db_update('rules_config')
->fields(array('data' => $row->data))
->condition('id', $row->id)
......@@ -108,39 +108,41 @@ function commerce_shipping_update_7002(&$sandbox) {
}
/**
* Rename the shipping_method field on the shipping line item to commerce_shipping_method.
* This should actually never be run on 2.x but is here for reference.
* Rename the shipping_method field on the shipping line item.
*/
function commerce_shipping_update_7003(&$sandbox) {
// This should actually never be run on 2.x but is here for reference.
/*
commerce_shipping_line_item_configuration(array('type' => 'shipping'));
foreach (commerce_line_item_load_multiple(FALSE, array('type' => 'shipping')) as $line_item) {
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$line_item_wrapper->commerce_shipping_method = $line_item_wrapper->shipping_method->value();
$line_item_wrapper->save();
}
field_delete_field('shipping_method');
commerce_shipping_line_item_configuration(array('type' => 'shipping'));
foreach (commerce_line_item_load_multiple(FALSE, array('type' => 'shipping')) as $line_item) {
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$line_item_wrapper->commerce_shipping_method = $line_item_wrapper->shipping_method->value();
$line_item_wrapper->save();
}
field_delete_field('shipping_method');
*/
}
/**
* Install the shipping rate cache table for Shipping 2.x if necessary.
* This should actually never be run on 2.x but is here for reference.
*/
function commerce_shipping_update_7004($sandbox) {
// This should actually never be run on 2.x but is here for reference.
/*
if (!db_table_exists('cache_commerce_shipping_rates')) {
$table = drupal_get_schema_unprocessed('system', 'cache');
$table['description'] = 'Cache table for the temporary storage of base calculated shipping rates for orders.';
$table['fields']['cid']['description'] = 'Primary Key: Order ID and shipping method the rates are for.';
db_create_table('cache_commerce_shipping_rates', $table);
return t('Created shipping rate cache table for Shipping 2.x.');
}
return t('Skipped creating the shipping rate cache table; it already exists.');
if (!db_table_exists('cache_commerce_shipping_rates')) {
$table = drupal_get_schema_unprocessed('system', 'cache');
$table['description'] = 'Cache table for the temporary storage of base calculated shipping rates for orders.';
$table['fields']['cid']['description'] = 'Primary Key: Order ID and shipping method the rates are for.';
db_create_table('cache_commerce_shipping_rates', $table);
return t('Created shipping rate cache table for Shipping 2.x.');
}
return t('Skipped creating the shipping rate cache table; it already exists.');
*/
}
/**
* Upgrade from Commerce Shipping 1.x.
*
* Upgrade from Commerce Shipping 1.x by renaming the commerce_shipping_method
* field on the shipping line item type to commerce_shipping_service and
* converting price components on shipping line items to the generic Shipping
......
This diff is collapsed.
......@@ -5,6 +5,7 @@
* Rules integration for shipping.
*
* @addtogroup rules
*
* @{
*/
......@@ -27,7 +28,8 @@ function commerce_shipping_rules_event_info() {
'access callback' => 'commerce_order_rules_access',
);
// Include the Line Item module's Rules integration to reuse its access callback.
// Include the Line Item module's Rules integration to reuse
// its access callback.
module_load_include('inc', 'commerce_line_item', 'commerce_line_item.rules');
$events['commerce_shipping_calculate_rate'] = array(
......@@ -88,9 +90,9 @@ function commerce_shipping_service_rules_options_list() {
/**
* Checks an order for the existence of a shipping line item.
*
* @param $order
* @param object $order
* The order to check for a shipping line item.
* @param $service
* @param string $service
* The machine-name of a particular shipping service to search for; if '-any-'
* the condition returns TRUE for any found shipping line item.
*/
......@@ -204,7 +206,6 @@ function commerce_shipping_rate_apply($order, $service_name = NULL) {
$service_name = key($order->shipping_rates);
}
// Delete any existing shipping line items from the order.
commerce_shipping_delete_shipping_line_items($order, TRUE);
......
......@@ -5,17 +5,16 @@
* Default rules configurations for Shipping.
*/
/**
* Implements hook_default_rules_configuration().
*/
function commerce_shipping_default_rules_configuration() {
$rules = array();
// When an order's status is updating to "Shopping cart" from any other status,
// its shipping line items will be deleted. This captures any cart contents
// change via Add to Cart forms / the Shopping cart Views form. It also happens
// when the customer cancels out of the checkout form.
// When an order's status is updating to "Shopping cart" from any other
// status, its shipping line items will be deleted. This captures any
// cart contents change via Add to Cart forms / the Shopping cart Views form.
// It also happens when the customer cancels out of the checkout form.
$rule = rules_reaction_rule();
$rule->label = t('Delete shipping line items on shopping cart updates');
......@@ -73,9 +72,9 @@ function commerce_shipping_default_rules_configuration() {
$rule
->event('commerce_shipping_collect_rates')
->action('commerce_shipping_method_collect_rates', array(
'shipping_method_name' => $name,
'commerce_order:select' => 'commerce-order',
));
'shipping_method_name' => $name,
'commerce_order:select' => 'commerce-order',
));
$rules['commerce_shipping_method_' . $name] = $rule;
}
......
......@@ -212,7 +212,6 @@ function commerce_shipping_ui_help($path, $arg) {
}
}
/**
* Implements hook_menu_local_tasks_alter().
*/
......
......@@ -5,7 +5,6 @@
* Callback functions for the shipping module's checkout panes.
*/
/**
* Checkout pane callback: returns the shipping service pane's settings form.
*/
......@@ -141,7 +140,8 @@ function commerce_shipping_pane_checkout_form($form, &$form_state, $checkout_pan
$message = t('No valid shipping rates found for your order, and we require shipping service selection to complete checkout.') . '<br /><strong>' . t('Please verify you have supplied all required information or contact us to resolve the issue.') . '</strong>';
}
else {
// If live shipping rate recalculation is required, check if we can show shipping options.
// If live shipping rate recalculation is required, check if we can show
// shipping options.
if (commerce_shipping_recalculate_services($form, NULL, TRUE) && empty($form_state['recalculate'])) {
$message = t('Please supply all of the required information requested above to reveal your shipping options.');
}
......@@ -160,7 +160,9 @@ function commerce_shipping_pane_checkout_form($form, &$form_state, $checkout_pan
}
/**
* Ajax callback: Returns the shipping details form elements that match the
* Ajax callback.
*
* Returns the shipping details form elements that match the
* currently selected shipping service.
*/
function commerce_shipping_pane_service_details_refresh($form, $form_state) {
......@@ -196,7 +198,8 @@ function commerce_shipping_recalculate_services_validate($form, &$form_state) {
$form_state['rebuild'] = TRUE;
}
// Store the validation result so that it can be examined in the submit handler.
// Store the validation result so that it can be examined
// in the submit handler.
$form_state['recalculate'] = $recalculate;
return TRUE;
......@@ -225,7 +228,8 @@ function commerce_shipping_recalculate_services_submit($form, &$form_state) {
// If this pane is actually present in the form...
if (!empty($form[$pane_id])) {
// If the profile copy button has been checked for this customer profile...
// If the profile copy button has been checked for this
// customer profile...
if (!empty($form_state['values'][$pane_id]['commerce_customer_profile_copy'])) {
$source_id = 'customer_profile_' . variable_get('commerce_' . $pane_id . '_profile_copy_source', '');
$info = array('commerce_customer_profile', $type, $pane_id);
......@@ -247,8 +251,8 @@ function commerce_shipping_recalculate_services_submit($form, &$form_state) {
$profile = $wrapper->{$source_field_name}->value();
}
elseif (!empty($form_state['order']->data['profiles'][$source_id])) {
// Otherwise fallback to the customer profile referenced in the order
// data array.
// Otherwise fallback to the customer profile referenced
// in the order data array.
$profile = commerce_customer_profile_load($form_state['order']->data['profiles'][$source_id]);
}
......@@ -336,9 +340,9 @@ function commerce_shipping_pane_checkout_form_validate($form, &$form_state, $che
if ($callback = commerce_shipping_service_callback($shipping_service, 'details_form_validate')) {
$result = $callback($pane_form['service_details'], $pane_values['service_details'], $shipping_service, $order, array($checkout_pane['pane_id'], 'service_details'));
// To prevent payment method validation routines from having to return TRUE
// explicitly, only return FALSE if it was specifically returned. Otherwise
// default to TRUE.
// To prevent payment method validation routines from having to return
// TRUE explicitly, only return FALSE if it was specifically returned.
// Otherwise default to TRUE.
return $result === FALSE ? FALSE : TRUE;
}
}
......@@ -400,7 +404,9 @@ function commerce_shipping_pane_checkout_form_submit($form, &$form_state, $check
}
/**
* Checkout pane callback: show the selected shipping service on the review pane.
* Checkout pane callback.
*
* Show the selected shipping service on the review pane.
*/
function commerce_shipping_pane_review($form, $form_state, $checkout_pane, $order) {
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
......
......@@ -57,7 +57,7 @@ function commerce_shipping_ui_overview($type, $method = NULL) {
array(
'data' => $empty_text,
'colspan' => 2,
)
),
);
}
......@@ -67,7 +67,7 @@ function commerce_shipping_ui_overview($type, $method = NULL) {
/**
* Builds an overview of a shipping method for display to an administrator.
*
* @param $variables
* @param array $variables
* An array of variables used to generate the display; by default includes the
* shipping_method key with a value of the shipping method info array.
*
......@@ -87,7 +87,7 @@ function theme_shipping_method_admin_overview($variables) {
/**
* Builds an overview of a shipping service for display to an administrator.
*
* @param $variables
* @param array $variables
* An array of variables used to generate the display; by default includes the
* shipping_service key with a value of the shipping service info array.
*
......@@ -112,7 +112,11 @@ function commerce_shipping_ui_rate_calculation_rules() {
$content['enabled']['title']['#markup'] = '<h3>' . t('Enabled shipping rate calculation rules') . '</h3>';
$conditions = array('event' => 'commerce_shipping_calculate_rate', 'plugin' => 'reaction rule', 'active' => TRUE);
$conditions = array(
'event' => 'commerce_shipping_calculate_rate',
'plugin' => 'reaction rule',
'active' => TRUE,
);
$content['enabled']['rules'] = RulesPluginUI::overviewTable($conditions, $options);
$content['enabled']['rules']['#empty'] = t('There are no active shipping rate calculation rules.');
......
......@@ -5,9 +5,8 @@
* Defines Views integration for Commerce Shipping.
*/
/**
* Implements hook_views_data_alter()
* Implements hook_views_data_alter().
*/
function commerce_shipping_views_data_alter(&$data) {
// Add a relationship to the order table to join to a representative shipping
......
......@@ -6,14 +6,15 @@
*/
class commerce_shipping_handler_relationship_shipping_line_item_representative extends views_handler_relationship {
function label() {
public function label() {
if (!isset($this->options['label'])) {
return $this->ui_name();
}
return $this->options['label'];
}
function query() {
public function query() {
// Get the JOIN type from the relationship settings.
$join_type = empty($this->options['required']) ? 'LEFT' : 'INNER';
......@@ -40,4 +41,5 @@ class commerce_shipping_handler_relationship_shipping_line_item_representative e
$alias = 'commerce_order_shipping_line_item_representiative';
$this->alias = $this->query->add_relationship($alias, $join, 'commerce_line_item', $this->relationship);
}
}
......@@ -5,7 +5,6 @@
* Defines an example shipping method for testing and development.
*/
/**
* Implements hook_commerce_shipping_method_info().
*/
......@@ -44,7 +43,9 @@ function commerce_shipping_example_commerce_shipping_service_info() {
}
/**
* Shipping service callback: returns a base price array for a shipping service
* Shipping service callback.
*
* Returns a base price array for a shipping service
* calculated for the given order.
*/
function commerce_shipping_example_service_rate($shipping_service, $order) {
......@@ -100,7 +101,9 @@ function commerce_shipping_example_service_details_form_validate($details_form,
}
/**
* Shipping service callback: increases the shipping line item's unit price if
* Shipping service callback.
*
* Increases the shipping line item's unit price if
* express delivery was selected.
*/
function commerce_shipping_example_service_details_form_submit($details_form, $details_values, $line_item) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment