diff --git a/modules/commerce_kickstart/commerce_kickstart_block/commerce_kickstart_block.module b/modules/commerce_kickstart/commerce_kickstart_block/commerce_kickstart_block.module index 926ec0d..d347346 100644 --- a/modules/commerce_kickstart/commerce_kickstart_block/commerce_kickstart_block.module +++ b/modules/commerce_kickstart/commerce_kickstart_block/commerce_kickstart_block.module @@ -37,6 +37,36 @@ function commerce_kickstart_block_block_info() { ); return $blocks; } +function commerce_kickstart_block_block_configure($delta = '') { + // The $delta parameter tells us which block is being configured. + // In this example, we'll allow the administrator to customize + // the text of the 'configurable text string' block defined in this module. + + $form = array(); + if ($delta == 'shipping_discount') { + // All we need to provide is the specific configuration options for our + // block. Drupal will take care of the standard block configuration options + // (block title, page visibility, etc.) and the save button. + $form['block_discount_amount'] = array( + '#type' => 'textfield', + '#title' => t('Discount Amount'), + '#size' => 60, + '#description' => t('This amount will appear in the discount block - do not use decimals.'), + '#default_value' => variable_get('block_discount_amount', t('9999')), + ); + } + return $form; +} + +function commerce_kickstart_block_block_save($delta = '', $edit = array()) { + // We need to save settings from the configuration form. + // We need to check $delta to make sure we are saving the right block. + if ($delta == 'shipping_discount') { + // Have Drupal save the string to the database. + variable_set('block_discount_amount', $edit['block_discount_amount']); + } + return; +} /** * Implements hook_block_view(). @@ -51,9 +81,13 @@ function commerce_kickstart_block_block_view($delta = '') { switch ($delta) { case 'shipping_discount': - $amount = '99'; + if (variable_get('block_discount_amount', FALSE)) { + $amount = variable_get('block_discount_amount',FALSE); + }else{ + $amount = '9999'; + } $items = array( - commerce_kickstart_block_build_element(t('Free shipping on orders over'), 'shipping_message'), + commerce_kickstart_block_build_element(t('Free delivery on orders over'), 'shipping_message'), commerce_kickstart_block_build_element(t('@amount', array('@amount' => commerce_currency_format($amount, commerce_default_currency()))), 'shipping_currency'), ); $block['content'] = commerce_kickstart_block_build_element(implode('', $items), 'shipping', NULL, 'div');