• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
    • Help
      • Online help
      • Learn Git
      • Welcome to Bitbucket
      • Keyboard shortcuts
    • Log In
    Blackrock
    1. Blackrock

    main

    Public
    Actions
    • Clone

    Learn more about cloning repositories

    You have read-only access

    Navigation
    • Source
    • Commits
    • Branches
    • All Branches Graph
    • Graphs
    • Forks
    1. Blackrock
    2. main

    Source

    main/wp-content/plugins/woocommerce-gateway-paypal-express-checkout/includes/class-wc-gateway-ppec-with-paypal-addons.php
    Артем ШиряевАртем Ширяев committed 554847ddcb906 Apr 2021
    Raw file
    Source viewDiff to previous
     
    1
    <?php
    2
    ​
    3
    if ( ! defined( 'ABSPATH' ) ) {
    4
        exit; // Exit if accessed directly
    5
    }
    6
    ​
    7
    class WC_Gateway_PPEC_With_PayPal_Addons extends WC_Gateway_PPEC_With_PayPal {
    8
    ​
    9
        public function __construct() {
    10
            parent::__construct();
    11
    ​
    12
            $this->supports = array_merge(
    13
                $this->supports,
    14
                array(
    15
                    'subscriptions',
    16
                    'subscription_cancellation',
    17
                    'subscription_reactivation',
    18
                    'subscription_suspension',
    19
                    'multiple_subscriptions',
    20
                    'subscription_payment_method_change_customer',
    21
                    'subscription_payment_method_change_admin',
    22
                    'subscription_amount_changes',
    23
                    'subscription_date_changes',
    24
                )
    25
            );
    26
    ​
    27
            $this->_maybe_register_callback_in_subscriptions();
    28
        }
    29
    ​
    30
        /**
    31
         * Maybe register callback in WooCommerce Subscription hooks.
    32
         *
    33
         * @since 1.2.0
    34
         */
    35
        protected function _maybe_register_callback_in_subscriptions() {
    36
            if ( ! class_exists( 'WC_Subscriptions_Order' ) ) {
    37
                return;
    38
            }
    39
    ​
    40
            add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
    41
            add_action( 'woocommerce_subscription_failing_payment_method_' . $this->id, array( $this, 'update_failing_payment_method' ) );
    42
    ​
    43
            // When changing the payment method for a WooCommerce Subscription to PayPal Checkout, let WooCommerce Subscription
    44
            // know that the payment method for that subscription should not be changed immediately. Instead, it should
    45
            // wait for the IPN notification, after the user confirmed the payment method change with PayPal.
    46
            add_filter( 'woocommerce_subscriptions_update_payment_via_pay_shortcode', array( $this, 'indicate_async_payment_method_update' ), 10, 2 );
    47
    ​
    48
            // Add extra parameter when updating the subscription payment method to PayPal.
    49
            add_filter( 'woocommerce_paypal_express_checkout_set_express_checkout_params_get_return_url', array( $this, 'add_query_param_to_url_subscription_payment_method_change' ), 10, 2 );
    50
            add_filter( 'woocommerce_paypal_express_checkout_set_express_checkout_params_get_cancel_url', array( $this, 'add_query_param_to_url_subscription_payment_method_change' ), 10, 2 );
    51
        }
    52
    ​
    53
        /**
    54
         * Checks whether order is part of subscription.
    55
         *
    56
         * @since 1.2.0
    57
         *
    58
         * @param int $order_id Order ID
    59
         *
    60
         * @return bool Returns true if order is part of subscription
    61
         */
    62
        public function is_subscription( $order_id ) {
    63
            return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
    • Git repository management for enterprise teams powered by Atlassian Bitbucket
    • Atlassian Bitbucket v5.10.1
    • Documentation
    • Contact Support
    • Request a feature
    • About
    • Contact Atlassian
    Atlassian

    Everything looks good. Well let you know here if theres anything you should know about.