• Hi,

    I’m new to developing on WordPress and I have a few questions. I’m trying to add multiple Stripe accounts to WooCommerce and am following this guide:

    https://www.neshable.com/how-to-use-multiple-stripe-accounts-in-one-woocommerce-install/

    From my understanding, I need to create a new file called /public_html/wp-includes/class-woo-conditional-stripe-keys.php and put the provided code into that file.

    I’m then stuck when it says to call new Woo_Conditional_Stripe_Keys( $publishable, $secret ) within the login to change the keys.

    Please excuse my lack of knowledge and hopefully someone can help! Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    That’s not a proper location for a custom file. The provided class code is intended to be part of your “project”, which probably should be your own custom plugin. Making a plugin is relatively simple. Having it do what you want is more complicated.

    Include the class code in your plugin file. You need to define what values $publishable and $secret should be. For example:
    $secret = 'my-Secret-key-1234-!';
    except use the actual private key string.

    Instantiate the class as an object:
    $my_stripe = new Woo_Conditional_Stripe_Keys( $publishable, $secret );

    Then you can use class methods, for example:
    return $my_stripe->wc_stripe_params_function( ['key'=>'value',] );

    I don’t know how the referenced filters are supposed to be used, but here’s a generic example of adding a filter:

    add_filter('the_filter_name', 'my_callback');
    function my_callback() {
      // above example code might go here
    }

    There are different ways to use classes, what I’ve presented may not be optimal, but should work provided the filter callback ends up returning the proper value and the defined parameters are correct.

    Thread Starter rustyingles

    (@rustyingles)

    Thank you, that’s great. I’ll give all of that a go!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help with functions and logic’ is closed to new replies.