Created
November 7, 2019 20:40
-
-
Save claudiosanches/27918ec8a28fd1650b6a2fbc6dfed767 to your computer and use it in GitHub Desktop.
Revisions
-
claudiosanches created this gist
Nov 7, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ <?php /** * Plugin Name: Test "pay button" support */ add_action( 'plugins_loaded', function() { class My_Custom_Gateway extends WC_Payment_Gateway { public function __construct() { $this->id = 'custom_gateway'; $this->has_fields = false; $this->method_title = 'Custom Gateway'; $this->method_description = 'Custom Gateway for tests'; $this->pay_button_id = 'custom-pay-button'; // Pay button ID. $this->supports = array( 'products', 'pay_button', // Pay button supporte declared. ); // Load the settings. $this->init_form_fields(); $this->init_settings(); } /** * Initialise Gateway Settings Form Fields. */ public function init_form_fields() { $this->form_fields = array( 'enabled' => array( 'title' => 'Enable/Disable', 'type' => 'checkbox', 'label' => '', 'default' => 'yes', ), ); } } // Register class. add_filter( 'woocommerce_payment_gateways', function( $gateways ) { $gateways[] = 'My_Custom_Gateway'; return $gateways; } ); /** * Sample button implementation. */ add_action( 'wp_footer', function() { echo '<script>jQuery( "#custom-pay-button" ).text( "Pay now" ).css( "color", "#fff" ).css( "background", "#222" ).css( "padding", "5px" ).css( "max-width", "150px" );</script>'; } ); }, 10 );