PluginProbe ʕ •ᴥ•ʔ
WooCommerce PayPal Payments / 3.3.2
WooCommerce PayPal Payments v3.3.2
4.0.4 4.0.3 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.4.0 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.4.0 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.6.0 2.6.1 2.7.0 2.7.1 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 4.0.0 4.0.1 4.0.2
woocommerce-paypal-payments / modules / ppcp-order-tracking / src / TrackingAvailabilityTrait.php
woocommerce-paypal-payments / modules / ppcp-order-tracking / src Last commit date
Assets 1 year ago Endpoint 9 months ago Integration 9 months ago Shipment 1 year ago MetaBoxRenderer.php 1 year ago OrderTrackingModule.php 9 months ago TrackingAvailabilityTrait.php 10 months ago
TrackingAvailabilityTrait.php
46 lines
1 <?php
2
3 /**
4 * The order tracking module.
5 *
6 * @package WooCommerce\PayPalCommerce\OrderTracking
7 */
8 declare (strict_types=1);
9 namespace WooCommerce\PayPalCommerce\OrderTracking;
10
11 use WC_Order;
12 use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
13 use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
14 use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
15 use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
16 trait TrackingAvailabilityTrait
17 {
18 /**
19 * Checks if tracking should be enabled for current post.
20 *
21 * @param Bearer $bearer The Bearer.
22 * @return bool
23 */
24 protected function is_tracking_enabled(Bearer $bearer): bool
25 {
26 // phpcs:ignore WordPress.Security.NonceVerification
27 $post_id = (int) wc_clean(wp_unslash($_GET['id'] ?? $_GET['post'] ?? ''));
28 if (!$post_id) {
29 return \false;
30 }
31 $order = wc_get_order($post_id);
32 if (!is_a($order, WC_Order::class)) {
33 return \false;
34 }
35 $captured = $order->get_meta(AuthorizedPaymentsProcessor::CAPTURED_META_KEY);
36 $is_captured = empty($captured) || wc_string_to_bool($captured);
37 $is_paypal_order_edit_page = $order->get_meta(PayPalGateway::ORDER_ID_META_KEY) && !empty($order->get_transaction_id());
38 try {
39 $token = $bearer->bearer();
40 return $is_paypal_order_edit_page && $is_captured && $token->is_tracking_available() && apply_filters('woocommerce_paypal_payments_shipment_tracking_enabled', \true);
41 } catch (RuntimeException $exception) {
42 return \false;
43 }
44 }
45 }
46