Title: Adding to a plugin&#039;s options
Last modified: August 30, 2016

---

# Adding to a plugin's options

 *  [elbego](https://wordpress.org/support/users/elbego/)
 * (@elbego)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/adding-to-a-plugins-options/)
 * Hi all – having bit of trouble adding an option to reduce stock on a product 
   within a deposit login (woo commerce deposits). Currently the options as standard
   are: ‘deposit’ or ‘full payment’ – I wish to also add ‘both deposit or full payment’
   so stock would be reduced if either deposit or full payment is taken.
 * Help, much appreciated!
 * Updated function#1:
 *     ```
       public function payment_complete_reduce_order_stock($reduce, $order_id) {
           $order = wc_get_order($order_id);
           $status = $order->get_status();
           $reduce_on = get_option('wc_deposits_reduce_stock', 'full');
   
           if ($status === 'partially-paid' && $reduce_on === 'full') {
             $reduce = false;
           }
           else if ($status !== 'partially-paid' && $reduce_on === 'deposit') {
             $reduce = false;
           } //added in...
          else if ($status !== 'partially-paid' && $reduce_on === 'both' || $status == 'partially-paid' && $reduce_on === 'both'){
             $reduce = false;
           }
       ```
   
 * Updated function#2:
 *     ```
       'deposits_stock' => array(
                 'name'  => __('Reduce Stocks On', 'woocommerce-deposits'),
                 'type'  => 'radio',
                 'desc'  => __('Choose when to reduce stocks.', 'woocommerce-deposits'),
                 'id'    => 'wc_deposits_reduce_stock',
                 'options' => array(
                   'deposit' => __('Deposit Payment', 'woocommerce-deposits'),
                   'full'    => __('Full Payment', 'woocommerce-deposits'),
                   // added in...
       	    'both'    => __('Both Full Payment or Deposit', 'woocommerce-deposits')
                 ),
                 'default' => 'full'
               ),
       ```
   
 * This is where I think I fall down:
 * Original ‘Save all settings’ function:
 *     ```
       $reduce_stock = isset($_POST['wc_deposits_reduce_stock']) ?
             ($_POST['wc_deposits_reduce_stock'] === 'deposit' ? 'deposit' : 'full') : 'full';
       ```
   
 * I’m not sure how to add in the additional option, this doesn’t work!:
 *     ```
       $reduce_stock = isset($_POST['wc_deposits_reduce_stock']) ?
             ($_POST['wc_deposits_reduce_stock'] === 'deposit' ? 'deposit' : 'full' ? 'both' : 'full' ) : 'full';
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [elbego](https://wordpress.org/support/users/elbego/)
 * (@elbego)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/adding-to-a-plugins-options/#post-6746423)
 * Just to say – I’ve got this working – it’s just the selection in the admin options
   page that is acting strangely – It defaults to my new option – (which is great
   for me!), but would be good to know how to get it working properly for if/when
   it’s needed.
 * Cheers

Viewing 1 replies (of 1 total)

The topic ‘Adding to a plugin's options’ is closed to new replies.

## Tags

 * [woocommerce deposits](https://wordpress.org/support/topic-tag/woocommerce-deposits/)

 * 1 reply
 * 1 participant
 * Last reply from: [elbego](https://wordpress.org/support/users/elbego/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/adding-to-a-plugins-options/#post-6746423)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
