• Resolved teeboy4real

    (@teeboy4real)


    Hello,

    Please im not good in code but is this code correct for multiple gateways

    function woa_date_order_hook( $old_date, $gateway, $mode ) {
    	// For example, change date only for cheque.
    	if ( 'paystack' == $gateway ) {
    	if ( 'wallet == $gateway ) {
    		$old_date = strtotime( 'today -5 days' );
    	}
       }
    	return $old_date;
    }
    add_filter( 'woo_cao_date_order', 'woa_date_order_hook', 10, 3 );
    

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author RVOLA

    (@rvola)

    Hello
    in this code the error comes from the missing apostrophe after ‘wallet’.
    Otherwise it is not correct for several gateways, but by several conditional (both if)
    I would rather like this:

    function woa_date_order_hook( $old_date, $gateway, $mode ) {
    	if ( in_array( $gateway, array( 'gateway_example_1 'gateway_example_2', 'gateway_example_3' ) ) {
    		$old_date = strtotime( 'today -5 days' );
    	}
    	return $old_date;
    }
    add_filter( 'woo_cao_date_order', 'woa_date_order_hook', 10, 3 );
    Thread Starter teeboy4real

    (@teeboy4real)

    Thank you so much im really grateful

    I think you also forgot to add ‘ at the back of ‘gateway_example_1 if im correct.

    Plugin Author RVOLA

    (@rvola)

    Oups
    a comma is missing …
    here is the corrected code:

    function woa_date_order_hook( $old_date, $gateway, $mode ) {
    	if ( in_array( $gateway, array( 'gateway_example_1', 'gateway_example_2', 'gateway_example_3' ) ) {
    		$old_date = strtotime( 'today -5 days' );
    	}
    	return $old_date;
    }
    add_filter( 'woo_cao_date_order', 'woa_date_order_hook', 10, 3 );
    Thread Starter teeboy4real

    (@teeboy4real)

    Perfect Thanks maybe you should add this code to the github wiki for users who don’t know how to apply it for multiple gateways. This will reduce future suport request.

    Thanks again for the support.

    Thread Starter teeboy4real

    (@teeboy4real)

    Hello you missed one more ) at ‘gateway_example_3’ ) ) {

    The correct code should be

    function woa_date_order_hook( $old_date, $gateway, $mode ) {
    	if ( in_array( $gateway, array( 'gateway_example_1', 'gateway_example_2', 'gateway_example_3' ) ) ) {
    		$old_date = strtotime( 'today -5 days' );
    	}
    	return $old_date;
    }
    add_filter( 'woo_cao_date_order', 'woa_date_order_hook', 10, 3 ); 
    Plugin Author RVOLA

    (@rvola)

    Yes that’s it.

    It’s the worry of not working with an editor without coloring.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Errors in code’ is closed to new replies.