модулем не поделюсь, так как он узко заточен под мой сайт, и на простом коммерце работать не будет. под вашу задачу shipping + flat rate вполне подойдет
Тогда не подскажешь как сделать так, чтобы при Самомывозе (pickup) (как раз таки shipping + flat rate) пропадало поле Shipping information, и появлялся текст откуда забрать?
class CommerceShippingExample2 extends CommerceShippingQuote { /**
* Settings form callback: adds our custom settings to the Rules action form.
*/ publicfunction settings_form(&$form, $rules_settings){ $form['shipping_price'] = array( '#type' =>'textarea', '#title' =>t('Shipping price'), '#description' =>t('Configure what the shipping price per order should be.'), '#default_value' =>is_array($rules_settings)&&isset($rules_settings['shipping_price']) ? $rules_settings['shipping_price'] : 42, '#element_validate' =>array('rules_ui_element_decimal_validate'), ); }
/**
* Submit form callback: adds additional elements to the checkout pane when
* this shipping method is selected.
*/ publicfunction submit_form($pane_values, $checkout_pane, $order = NULL){ $form = parent::submit_form($pane_values, $checkout_pane, $order);
// Default to the order in the object's scope if none is explicitly passed in. if(empty($order)){ $order = $this->order; }
// Merge values from the order into the checkout pane values. if(!empty($order->data['commerce_shipping_example'])){ $pane_values += $order->data['commerce_shipping_example']; }
$form['name2'] = array( '#type' =>'none', '#title' =>t('Name2'), '#description' =>t('This is a demonstration field coded to fail validation for single character values.'), '#default_value' =>$pane_values['name2'], '#required' =>TRUE, );
Комментарии
pick up
Модулем не поделишься? Сам подзапарился с самовывозом в Commerce.
модулем не поделюсь, так как он узко заточен под мой сайт, и на простом коммерце работать не будет. под вашу задачу shipping + flat rate вполне подойдет
Тогда не подскажешь как сделать так, чтобы при Самомывозе (pickup) (как раз таки shipping + flat rate) пропадало поле Shipping information, и появлялся текст откуда забрать?
/**
* Settings form callback: adds our custom settings to the Rules action form.
*/
public function settings_form(&$form, $rules_settings) {
$form['shipping_price'] = array(
'#type' => 'textarea',
'#title' => t('Shipping price'),
'#description' => t('Configure what the shipping price per order should be.'),
'#default_value' => is_array($rules_settings) && isset($rules_settings['shipping_price']) ? $rules_settings['shipping_price'] : 42,
'#element_validate' => array('rules_ui_element_decimal_validate'),
);
}
/**
* Submit form callback: adds additional elements to the checkout pane when
* this shipping method is selected.
*/
public function submit_form($pane_values, $checkout_pane, $order = NULL) {
$form = parent::submit_form($pane_values, $checkout_pane, $order);
// Default to the order in the object's scope if none is explicitly passed in.
if (empty($order)) {
$order = $this->order;
}
// Merge values from the order into the checkout pane values.
if (!empty($order->data['commerce_shipping_example'])) {
$pane_values += $order->data['commerce_shipping_example'];
}
// Then merge in default values.
$pane_values += array(
'express' => 0,
'name2' => '',
);
$form ['removed'] = array(
'#title' => t('testing'),
'#type' => 'item',
'#description' =>t('developer'),
);
$form['name2'] = array(
'#type' => 'none',
'#title' => t('Name2'),
'#description' => t('This is a demonstration field coded to fail validation for single character values.'),
'#default_value' => $pane_values['name2'],
'#required' => TRUE,
);
return $form;
}
public function calculate_quote($currency_code, $form_values = array(), $order = NULL, $pane_form = NULL, $pane_values = NULL) {
if (empty($order)) {
$order = $this->order;
}
$settings = $this->settings;
$shipping_line_items = array();
$shipping_line_items[] = array(
'amount' => commerce_currency_decimal_to_amount($settings['shipping_price'], $currency_code),
'currency_code' => $currency_code,
'label' => t('Normal shipping'),
);
if (!empty($form_values['express'])) {
$shipping_line_items[] = array(
'amount' => commerce_currency_decimal_to_amount($settings['shipping_price'], $currency_code),
'currency_code' => $currency_code,
'label' => t('Express fee'),
);
}
return $shipping_line_items;
}
}
qqqarmani, я в личку написал.