-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #298 from reepay/dev
v 1.6.1 - Card saving fixes, user creation fixesDev
- Loading branch information
Showing
22 changed files
with
927 additions
and
496 deletions.
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
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,48 @@ | ||
<?php | ||
/** | ||
* Checkout actions | ||
* | ||
* @package Reepay\Checkout | ||
*/ | ||
|
||
namespace Reepay\Checkout\Actions; | ||
|
||
/** | ||
* Class Admin | ||
* | ||
* @package Reepay\Checkout | ||
*/ | ||
class Admin { | ||
/** | ||
* Admin constructor. | ||
*/ | ||
public function __construct() { | ||
add_action( 'admin_notices', array( $this, 'admin_notice_api_action' ) ); | ||
} | ||
|
||
/** | ||
* Add notifications in admin for api actions. | ||
*/ | ||
public function admin_notice_api_action() { | ||
$error = get_transient( 'reepay_api_action_error' ); | ||
$success = get_transient( 'reepay_api_action_success' ); | ||
|
||
if ( ! empty( $error ) ) : | ||
?> | ||
<div class="error notice is-dismissible"> | ||
<p><?php echo esc_html( $error ); ?></p> | ||
</div> | ||
<?php | ||
set_transient( 'reepay_api_action_error', null, 1 ); | ||
endif; | ||
|
||
if ( ! empty( $success ) ) : | ||
?> | ||
<div class="notice-success notice is-dismissible"> | ||
<p><?php echo esc_html( $success ); ?></p> | ||
</div> | ||
<?php | ||
set_transient( 'reepay_api_action_success', null, 1 ); | ||
endif; | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
/** | ||
* Checkout actions | ||
* | ||
* @package Reepay\Checkout | ||
*/ | ||
|
||
namespace Reepay\Checkout\Actions; | ||
|
||
use WC_Order; | ||
use WC_Order_Item_Product; | ||
|
||
/** | ||
* Class Checkout | ||
* | ||
* @package Reepay\Checkout | ||
*/ | ||
class Checkout { | ||
/** | ||
* Checkout constructor. | ||
*/ | ||
public function __construct() { | ||
add_action( 'woocommerce_checkout_create_order_line_item', array( $this, 'action_checkout_create_order_line_item' ), 10, 4 ); | ||
add_filter( 'woocommerce_cart_needs_payment', array( $this, 'check_need_payment' ), 10 ); | ||
} | ||
|
||
/** | ||
* Count line item discount | ||
* | ||
* @param bool $need_payment need payment marker. | ||
* | ||
* @see WC_Cart::needs_payment | ||
* | ||
* @return bool | ||
*/ | ||
public function check_need_payment( bool $need_payment ): bool { | ||
if ( wcs_cart_have_subscription() ) { | ||
return true; | ||
} | ||
|
||
return $need_payment; | ||
} | ||
|
||
/** | ||
* Count line item discount | ||
* | ||
* @param WC_Order_Item_Product $item created order item. | ||
* @param string $cart_item_key order item key in cart. | ||
* @param array $values values from cart item. | ||
* @param WC_Order $order new order. | ||
* | ||
* @see WC_Checkout::create_order_line_items | ||
*/ | ||
public function action_checkout_create_order_line_item( WC_Order_Item_Product $item, string $cart_item_key, array $values, WC_Order $order ) { | ||
$line_discount = $values['line_subtotal'] - $values['line_total']; | ||
$line_discount_tax = $values['line_subtotal_tax'] - $values['line_tax']; | ||
|
||
$item->update_meta_data( '_line_discount', $line_discount + $line_discount_tax ); | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.