2016-11-11 5 views
0

サイトがローカルまたはステージングサイトに設定されている場合、Stripe Woocommerceアドオンをテストモードにする方法を探しています。私は正しい方向に私を向けることができるリソースはまだ見つけていません。Force Stripe WooCommerce Addonをホスト名に応じてtestmodeに追加

は、私には、値の設定を取得しますクラス-WC-ゲートウェイstrip.phpのコード見つけた:

// Get setting values. 
    $this->title     = $this->get_option('title'); 
    $this->description   = $this->get_option('description'); 
    $this->enabled    = $this->get_option('enabled'); 
    $this->testmode    = 'yes' === $this->get_option('testmode'); 
    $this->capture    = 'yes' === $this->get_option('capture', 'yes'); 
    $this->stripe_checkout  = 'yes' === $this->get_option('stripe_checkout'); 
    $this->stripe_checkout_locale = $this->get_option('stripe_checkout_locale'); 
    $this->stripe_checkout_image = $this->get_option('stripe_checkout_image', ''); 
    $this->saved_cards   = 'yes' === $this->get_option('saved_cards'); 
    $this->secret_key    = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key'); 
    $this->publishable_key  = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key'); 
    $this->bitcoin    = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin'); 
    $this->logging    = 'yes' === $this->get_option('logging'); 

をそして私は、ドメインにチェックをやってみたこととupdate_option('testmode','yes');を試してみましたが、それは」doesnの何の効果もないようです。

私の前進に役立つアイデアやリソースはありますか?

+0

あなたは、実際のオプション名を見つけることができる場合は、[ 'pre_option_ $ option_name']を経由して、それをフィルタリングすることができるかもしれ(https://core.trac.wordpress.org/browser/tags/4.6/src/ wp-includes/option.php#L52) – helgatheviking

+0

Nevermind、私は思う*すべてのストライプ設定は 'woocommerce_stripe_settings'の下に配列として保存されます。したがって、 'get_option(" woocommerce_stripe_settings ")'を実行し、結果の配列を操作し、新しいデータで 'update_option()'を操作する必要があります。 – helgatheviking

答えて

0

私のコメントに基づいてテストされていませんが、私はあなたがオプションを調整できると思います。

add_action('init', 'so_40555974_stripe_testing'); 
function so_40555974_stripe_testing(){ 

    $localIPs = array(
     '127.0.0.1', 
     '::1' 
    ); 

    // or use your own conditional logic for determining local/testing server 
    if(in_array($_SERVER['REMOTE_ADDR'], $localIPs)){ 
     $settings = get_option("woocommerce_stripe_settings"); 
     $settings["testmode"] = "yes"; 
     update_option("woocommerce_stripe_settings", $settings); 
    } 
} 
+0

私はこれを投稿したことを完全に忘れてしまったが、これがやってしまった。ありがとう! –

+0

これがあなたの答えになったら、それを受け入れることができますか? – helgatheviking

関連する問題