Skip to content
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 5 commits into from
Feb 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions classes/class-wc-connect-payment-gateway.php
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();

}

}

}

43 changes: 37 additions & 6 deletions woocommerce-connect-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Copy link
Contributor

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 👍


$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' ) );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra blank line sneaked in here

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
}
}

Expand Down