V
V
Vladislav Prubnyak2018-02-05 16:34:32
WordPress
Vladislav Prubnyak, 2018-02-05 16:34:32

How to flexibly set up payment in woocommerce?

Is it possible in woocommerce to turn off the ability to pay on receipt if the order amount is less than a certain amount, ideally, the item would be shown, but it could not be selected and a window would appear that needs to be added by amount, maybe there are some plugins?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav Prubnyak, 2018-02-09
@Vaprubnyak

Problem solved thanks OKyJIucT
Working code:

add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );

$limit_reached = false;

function wc_minimum_order_amount() 
{
  // Задать переменную, чтобы указать минимальное значение заказа
  $minimum = 1000;
  
  if ( WC()->cart->total < $minimum ) {
    $limit_reached = true;
    
  }
  return $limit_reached;
}

function unsetting_payment_gateways( $available_gateways ) 
{	
  $limit_reached = wc_minimum_order_amount();
  if ($limit_reached) {			
      // Здесь установить способ оплаты
      unset($available_gateways['cod']);
  }
  
  return $available_gateways;
}
add_action('woocommerce_available_payment_gateways', 'unsetting_payment_gateways');

W
WordPress WooCommerce, 2018-02-07
@maxxannik

Usually such problems are solved by minor code changes. There are hooks in which you can intercept data. Check for the right condition. And then hide the item or add the deactivation attribute to the input.
Something like this. To compose the code, you need to read the docs, source codes, test, debug, etc. It's not difficult. But this is a task, not a question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question