Skip to content

Commit

Permalink
fix: using direct class call for Subscription (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateus-picoloto authored Nov 8, 2023
1 parent ae27c9e commit 33ca98c
Showing 1 changed file with 6 additions and 8 deletions.
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

0 comments on commit 33ca98c

Please sign in to comment.