mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
Fix the Psalm errors
This commit is contained in:
parent
11244fa055
commit
ac42b18592
1 changed files with 13 additions and 4 deletions
|
@ -14,6 +14,7 @@ use WC_Cart;
|
||||||
use WC_Order;
|
use WC_Order;
|
||||||
use WC_Order_Item_Product;
|
use WC_Order_Item_Product;
|
||||||
use WC_Order_Item_Shipping;
|
use WC_Order_Item_Shipping;
|
||||||
|
use WC_Subscription;
|
||||||
use WC_Subscriptions_Product;
|
use WC_Subscriptions_Product;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
|
||||||
|
@ -22,6 +23,7 @@ use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer;
|
use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
|
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
|
||||||
|
use WP_Error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class WooCommerceOrderCreator
|
* Class WooCommerceOrderCreator
|
||||||
|
@ -227,7 +229,7 @@ class WooCommerceOrderCreator {
|
||||||
$items = $wc_order->get_items();
|
$items = $wc_order->get_items();
|
||||||
$items_in_package = array();
|
$items_in_package = array();
|
||||||
foreach ( $items as $item ) {
|
foreach ( $items as $item ) {
|
||||||
$items_in_package[] = $item->get_name() . ' × ' . $item->get_quantity();
|
$items_in_package[] = $item->get_name() . ' × ' . (string) $item->get_quantity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$shipping->add_meta_data( __( 'Items', 'woocommerce-paypal-payments' ), implode( ', ', $items_in_package ) );
|
$shipping->add_meta_data( __( 'Items', 'woocommerce-paypal-payments' ), implode( ', ', $items_in_package ) );
|
||||||
|
@ -297,10 +299,11 @@ class WooCommerceOrderCreator {
|
||||||
*
|
*
|
||||||
* @param WC_Order $wc_order The WC order.
|
* @param WC_Order $wc_order The WC order.
|
||||||
* @param int $product_id The product ID.
|
* @param int $product_id The product ID.
|
||||||
* @return WC_Order The subscription order
|
* @return WC_Subscription The subscription order
|
||||||
|
* @throws RuntimeException If problem creating.
|
||||||
*/
|
*/
|
||||||
protected function create_subscription( WC_Order $wc_order, int $product_id ): WC_Order {
|
protected function create_subscription( WC_Order $wc_order, int $product_id ): WC_Subscription {
|
||||||
return wcs_create_subscription(
|
$subscription = wcs_create_subscription(
|
||||||
array(
|
array(
|
||||||
'order_id' => $wc_order->get_id(),
|
'order_id' => $wc_order->get_id(),
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
|
@ -309,5 +312,11 @@ class WooCommerceOrderCreator {
|
||||||
'customer_id' => $wc_order->get_customer_id(),
|
'customer_id' => $wc_order->get_customer_id(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( $subscription instanceof WP_Error ) {
|
||||||
|
throw new RuntimeException( $subscription->get_error_message() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $subscription;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue