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

fix: using direct class call for Subscription #334

Merged
merged 1 commit into from
Nov 8, 2023
Merged
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
14 changes: 6 additions & 8 deletions src/Model/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
}

use WC_Order;
use WC_Subscription;
use WC_Subscriptions_Cart;
use Woocommerce\Pagarme\Controller\Orders;
use Woocommerce\Pagarme\Service\LogService;
use Woocommerce\Pagarme\Service\CardService;
Expand Down Expand Up @@ -169,7 +167,7 @@ public function processSubscription($amountToCharge, WC_Order $wc_order)
public function processChangePaymentSubscription($subscription)
{
try {
$subscription = new WC_Subscription($subscription);
$subscription = new \WC_Subscription($subscription);
$newPaymentMethod = wc_clean($_POST['payment_method']);
if ('woo-pagarme-payments-credit_card' == $newPaymentMethod) {
$pagarmeCustomer = $this->getPagarmeCustomer($subscription);
Expand Down Expand Up @@ -257,10 +255,10 @@ private function createCreditCard($pagarmeCustomer)
/**
* Save card information on table post_meta
* @param array $card
* @param WC_Subscription $subscription
* @param \WC_Subscription $subscription
* @return void
*/
private function saveCardInSubscription(array $card, WC_Subscription $subscription)
private function saveCardInSubscription(array $card, \WC_Subscription $subscription)
{
$subscription->add_meta_data('_pagarme_payment_subscription', json_encode($card), true);
$subscription->save();
Expand Down Expand Up @@ -356,7 +354,7 @@ public static function hasSubscriptionProductInCart()
if (!self::hasSubscriptionPlugin()) {
return false;
}
return WC_Subscriptions_Cart::cart_contains_subscription() || wcs_cart_contains_renewal();
return \WC_Subscriptions_Cart::cart_contains_subscription() || wcs_cart_contains_renewal();
}

/**
Expand All @@ -367,7 +365,7 @@ public static function hasSubscriptionFreeTrial()
if (!self::hasSubscriptionPlugin()) {
return false;
}
return WC_Subscriptions_Cart::all_cart_items_have_free_trial();
return \WC_Subscriptions_Cart::all_cart_items_have_free_trial();
}

/**
Expand All @@ -381,7 +379,7 @@ public static function getRecurrenceCycle()
if (wcs_cart_contains_renewal()) {
return "subsequent";
}
if (WC_Subscriptions_Cart::cart_contains_subscription()) {
if (\WC_Subscriptions_Cart::cart_contains_subscription()) {
return "first";
}
return null;
Expand Down
Loading