添加到插件的选项

时间:2015-11-13 15:05:47

标签: plugins woocommerce options

在存款插件中添加减少产品库存的选项时会遇到一些麻烦(商业存款)。目前作为标准的选项是:'存款'或者'全额付款' - 我还想添加存款或全额付款'如果存款或全额付款,股票将会减少。

帮助,非常感谢!

更新了功能#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'){ // added to allow reduction on both Deposit and Full
  $reduce = true;
}
else  if ($status == !'partially-paid' && $order->wc_deposits_remaining_paid == 'yes') { // Added to NOT reduce if prepayment taken then completing order
    $reduce = false;           
}

更新了功能#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'
    ),

这是我认为我堕落的地方:

原创'保存所有设置'功能:

$reduce_stock = isset($_POST['wc_deposits_reduce_stock']) ?
  ($_POST['wc_deposits_reduce_stock'] === 'deposit' ? 'deposit' : 'full') : 'full';

我不确定如何添加其他选项,这不起作用!:

$reduce_stock = isset($_POST['wc_deposits_reduce_stock']) ?
  ($_POST['wc_deposits_reduce_stock'] === 'deposit' ? 'deposit' : 'full' ? 'both' : 'full' ) : 'full';

0 个答案:

没有答案