-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add connect services WC settings pages #12
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7a55eda
Only load shipping method class if shipping services are defined.
jeffstieler c924ed9
Add POC support for payment gateways.
jeffstieler 3705ccb
Better variable naming and earlier return paths for shipping method a…
jeffstieler 9e632e7
Remove extra newline.
jeffstieler eed27b2
Use “payment” instead of “checkout” for payment gateway services.
jeffstieler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
if ( ! class_exists( 'WC_Connect_Payment_Gateway' ) ) { | ||
|
||
class WC_Connect_Payment_Gateway extends WC_Payment_Gateway { | ||
|
||
public function __construct( $settings ) { | ||
|
||
foreach ( (array) $settings as $key => $value ) { | ||
$this->{$key} = $value; | ||
} | ||
|
||
$this->init_settings(); | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,22 +67,53 @@ public function __construct() { | |
), | ||
), | ||
), | ||
'payment' => array( | ||
'paypal' => array( | ||
'id' => 'wc-connect-paypal', | ||
'enabled' => 'yes', | ||
'title' => __( 'PayPal', 'woocommerce' ), | ||
'method_title' => __( 'PayPal (WooCommerce Connect)', 'woocommerce' ), | ||
'method_description' => __( 'Checkout via PayPal, Powered by WooCommerce Connect', 'woocommerce' ) | ||
) | ||
), | ||
); | ||
|
||
add_action( 'woocommerce_shipping_init', array( $this, 'woocommerce_shipping_init' ) ); | ||
add_filter( 'woocommerce_shipping_methods', array( $this, 'woocommerce_shipping_methods' ) ); | ||
add_filter( 'woocommerce_payment_gateways', array( $this, 'woocommerce_payment_gateways' ) ); | ||
} | ||
|
||
public function woocommerce_shipping_init() { | ||
public function woocommerce_shipping_methods( $shipping_methods ) { | ||
|
||
$wcc_shipping_methods = (array) $this->services[ 'shipping' ]; | ||
|
||
if ( empty( $wcc_shipping_methods ) ) { | ||
return $shipping_methods; | ||
} | ||
|
||
require_once( plugin_basename( 'classes/class-wc-connect-shipping-method.php' ) ); | ||
|
||
foreach ( $wcc_shipping_methods as $wcc_shipping_method ) { | ||
$shipping_methods[] = new WC_Connect_Shipping_Method( $wcc_shipping_method ); | ||
} | ||
|
||
return $shipping_methods; | ||
} | ||
|
||
public function woocommerce_shipping_methods( $methods ) { | ||
foreach ( (array) $this->services[ 'shipping' ] as $key => $value ) { | ||
$methods[] = new WC_Connect_Shipping_Method( $value ); | ||
public function woocommerce_payment_gateways( $payment_gateways ) { | ||
|
||
$wcc_payment_gateways = (array) $this->services[ 'payment' ]; | ||
|
||
if ( empty( $wcc_payment_gateways ) ) { | ||
return $payment_gateways; | ||
} | ||
|
||
require_once( plugin_basename( 'classes/class-wc-connect-payment-gateway.php' ) ); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra blank line sneaked in here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
foreach ( $wcc_payment_gateways as $wcc_payment_gateway ) { | ||
$payment_gateways[] = new WC_Connect_Payment_Gateway( $wcc_payment_gateway ); | ||
} | ||
|
||
return $methods; | ||
return $payment_gateways; | ||
} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks much better/good to go 👍