• Resolved brayleiton

    (@brayleiton)


    Hello, I have a specific need in the free plugin, I would like to know if I can add code or modify part of the code to implement what I need

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sarankumar

    (@sarankumar)

    @brayleiton

    Please specify your requirement then only we can guide you. Like every other WordPress plugin you can customise code as per GPL license.

    if you can specify your requirement and what you are trying to do, we can add some development support in plugin (hook /filters ) which will help other users too.

    Thread Starter brayleiton

    (@brayleiton)

    I will only put a functionality that if there is a product or several in an out of stock status in the cart, then if it allows me to validate the approval of the order. Otherwise, let the payment process continue

    Plugin Author Sarankumar

    (@sarankumar)

    Order approval plugin using payment gateway feature for achieving desired functionality.You can unset payment gateway based on stock status. following sample code may hep you

    add_filter('woocommerce_available_payment_gateways','conditional_payment_gateways', 10, 1);

    function conditional_payment_gateways( $available_gateways ) {
        // Not in backend (admin)
        if( is_admin() ) 
            return $available_gateways;
    
        foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
           
            // Get the WC_Product object
            $product = wc_get_product($cart_item['product_id']);
            // Get the  stock
            $stock = $product->get_stock_quantity();
            // Your Logic goes here
         
        }
       // Based on condition 
        unset($available_gateways['woa_gateway']); // unset 'order approval'
    
        return $available_gateways;
    }
    • This reply was modified 4 years, 1 month ago by Sarankumar.
    Thread Starter brayleiton

    (@brayleiton)

    Thank you very much, my question was resolved

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Code modification’ is closed to new replies.