From time to time, I find myself needing to do test purchasing on a live site. Generally speaking, it’s because there is something occurring outside the payment flow on a live site that cannot be replicated locally. The following code ensures that the test gateway is enabled only for logged-in admin users. Hope it’s helpful!

add_filter( 'option_custom_gateway_options', function( $gateways ) {

    if ( current_user_can( 'manage_options' ) && ! in_array( 'wpsc_merchant_testmode', $gateways ) ) {
        $gateways[] = 'wpsc_merchant_testmode';
    }

    return $gateways;
} );
Category:
Code Snippets, eCommerce

Join the conversation! 1 Comment

  1. […] Justin Sainton posted a quick snippet on making the WP eCommerce test gateway admin-only. […]

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *