WordPress.org

Plugin Directory

Changeset 1660552


Ignore:
Timestamp:
05/19/17 02:54:48 (6 months ago)
Author:
DrewAPicture
Message:

Version 1.1.3 – WooCommerce 3.0+ compatibility.

Location:
affiliatewp-order-details-for-affiliates/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • affiliatewp-order-details-for-affiliates/trunk/affiliatewp-order-details-for-affiliates.php

    r1660551 r1660552  
    22/** 
    33 * Plugin Name: AffiliateWP - Order Details For Affiliates 
    4  * Plugin URI: http://affiliatewp.com/addons/order-details-affiliates/ 
    5  * Description: Share customer purchase information with the affiliate who referred them 
    6  * Author: Pippin Williamson and Andrew Munro 
    7  * Author URI: http://affiliatewp.com 
    8  * Version: 1.1.2 
     4 * Plugin URI: https://affiliatewp.com/addons/order-details-affiliates/ 
     5 * Description: Share customer purchase information with the affiliate who referred them. 
     6 * Author: AffiliateWP 
     7 * Author URI: https://affiliatewp.com 
     8 * Version: 1.1.3 
    99 * Text Domain: affiliatewp-order-details-for-affiliates 
    1010 * Domain Path: languages 
     
    2424 * @package Order Details For Affiliates 
    2525 * @category Core 
    26  * @author Andrew Munro 
    27  * @version 1.1.2 
     26 * @author AffiliateWP 
     27 * @version 1.1.3 
    2828 */ 
    2929 
     
    4646 
    4747    /** 
    48      * Class Properties 
     48     * Order Details instance. 
     49     * 
     50     * @access public 
     51     * @var    \AffiliateWP_Order_Details_For_Affiliates_Order_Details 
    4952     */ 
    5053    public $order_details; 
     54 
     55    /** 
     56     * Emails instance. 
     57     * 
     58     * @access public 
     59     * @var    \AffiliateWP_Order_Details_For_Affiliates_Emails 
     60     */ 
    5161    public $emails; 
     62 
     63    /** 
     64     * Shortcodes instance. 
     65     * 
     66     * @access public 
     67     * @var    \AffiliateWP_Order_Details_For_Affiliates_Shortcodes 
     68     */ 
    5269    public $shortcodes; 
    5370 
     
    6986            self::$plugin_dir = plugin_dir_path( __FILE__ ); 
    7087            self::$plugin_url = plugin_dir_url( __FILE__ ); 
    71             self::$version    = '1.1.2'; 
     88            self::$version    = '1.1.3'; 
    7289 
    7390            self::$instance->load_textdomain(); 
     
    321338        return $links; 
    322339    } 
     340 
     341    /** 
     342     * Determines whether WooCommerce is version 3.0.0+ or not. 
     343     * 
     344     * @access public 
     345     * @since  1.1.3 
     346     * 
     347     * @return bool True if WooCommerce 3.0.0+, otherwise false. 
     348     */ 
     349    public function woocommerce_is_300() { 
     350        $wc_is_300 = false; 
     351 
     352        if ( function_exists( 'WC' ) && true === version_compare( WC()->version, '3.0.0', '>=' ) ) { 
     353            $wc_is_300 = true; 
     354        } 
     355 
     356        return $wc_is_300; 
     357    } 
     358 
    323359} 
    324360 
     
    333369 * 
    334370 * @since 1.0 
    335  * @return object The one true AffiliateWP_Order_Details_For_Affiliates Instance 
     371 * @return \AffiliateWP_Order_Details_For_Affiliates The one true AffiliateWP_Order_Details_For_Affiliates Instance 
    336372 */ 
    337373function affiliatewp_order_details_for_affiliates() { 
  • affiliatewp-order-details-for-affiliates/trunk/includes/class-order-details.php

    r1660551 r1660552  
    3232 
    3333    /** 
     34     * Determines if the order attached to the referral actually exists. 
     35     * 
     36     * @access public 
     37     * @since  1.1.3 
     38     * 
     39     * @param int|\AffWP\Referral $referral Referral object or ID. 
     40     * @return bool True if the order exists, otherwise false. 
     41     */ 
     42    public function exists( $referral ) { 
     43        $exists = true; 
     44 
     45        switch( $referral->context ) { 
     46            case 'edd': 
     47                if ( ! function_exists( 'edd_get_payment' ) 
     48                    || ( function_exists( 'edd_get_payment' ) && ! edd_get_payment( $referral->reference ) ) 
     49                ) { 
     50                    $exists = false; 
     51                } 
     52 
     53                break; 
     54 
     55            case 'woocommerce': 
     56 
     57                if ( affiliatewp_order_details_for_affiliates()->woocommerce_is_300() ) { 
     58 
     59                    try { 
     60                        $order = new WC_Order( $referral->reference ); 
     61                    } catch ( Exception $e ) { 
     62 
     63                        $this->woocommerce_order_error( $referral ); 
     64 
     65                        $exists = false; 
     66                    } 
     67 
     68                } else { 
     69 
     70                    $order = new WC_Order( $referral->reference ); 
     71 
     72                    if ( $order->id <= 0 ) { 
     73                        $this->woocommerce_order_error( $referral ); 
     74 
     75                        $exists = false; 
     76                    } 
     77 
     78                } 
     79 
     80                break; 
     81        } 
     82 
     83        return $exists; 
     84    } 
     85 
     86    /** 
     87     * Handles messaging/logging output in the event of a WooCommerce order error on retrieval. 
     88     * 
     89     * @access private 
     90     * @since  1.1.3 
     91     * 
     92     * @param \AffWP\Referral $referral Referral object. 
     93     */ 
     94    private function woocommerce_order_error( $referral ) { 
     95        if ( method_exists( 'Affiliate_WP_Utilities', 'log' ) ) { 
     96            affiliate_wp()->utils->log( sprintf( 'Invalid order ID #%1$s for referral #%2$s in the Order Details tab.', $referral->reference, $referral->referral_id ) ); 
     97        } 
     98 
     99        esc_html_e( 'No data could be found for the current order.', 'affiliatewp-order-details-for-affiliates' ); 
     100    } 
     101 
     102    /** 
    34103     * Has customer details or order details 
    35104     * 
     
    144213                if ( $info == 'order_number' ) { 
    145214 
    146                     $seq_order_number = get_post_meta( $order->id, '_order_number', true ); 
     215                    if ( affiliatewp_order_details_for_affiliates()->woocommerce_is_300() ) { 
     216                        $order_id = $order->get_id(); 
     217                    } else { 
     218                        $order_id = $order->id; 
     219                    } 
     220 
     221                    $seq_order_number = get_post_meta( $order_id, '_order_number', true ); 
    147222 
    148223                    // sequential order numbers compatibility 
     
    158233 
    159234                if ( $info == 'order_date' ) { 
    160                     return $is_allowed['order_date'] ? $order->order_date : ''; 
     235                    if ( affiliatewp_order_details_for_affiliates()->woocommerce_is_300() ) { 
     236                        $order_date = $order->get_date_created(); 
     237                    } else { 
     238                        $order_date = $order->order_date; 
     239                    } 
     240 
     241                    return $is_allowed['order_date'] ? $order_date : ''; 
    161242                } 
    162243 
     
    166247 
    167248                if ( $info == 'customer_name' ) { 
    168                     return $is_allowed['customer_name'] && $order->billing_first_name ? $order->billing_first_name : ''; 
     249                    if ( affiliatewp_order_details_for_affiliates()->woocommerce_is_300() ) { 
     250                        $billing_first_name = $order->get_billing_first_name(); 
     251                    } else { 
     252                        $billing_first_name = $order->billing_first_name; 
     253                    } 
     254 
     255                    return $is_allowed['customer_name'] && $billing_first_name ? $billing_first_name : ''; 
    169256                } 
    170257 
    171258                if ( $info == 'customer_email' ) { 
    172                     return $is_allowed['customer_email'] && $order->billing_email ? $order->billing_email : ''; 
     259                    if ( affiliatewp_order_details_for_affiliates()->woocommerce_is_300() ) { 
     260                        $billing_email = $order->get_billing_email(); 
     261                    } else { 
     262                        $billing_email = $order->billing_email; 
     263                    } 
     264 
     265                    return $is_allowed['customer_email'] && $billing_email ? $billing_email : ''; 
    173266                } 
    174267 
    175268                if ( $info == 'customer_phone' ) { 
    176                     return $is_allowed['customer_phone'] && $order->billing_phone ? $order->billing_phone : ''; 
     269                    if ( affiliatewp_order_details_for_affiliates()->woocommerce_is_300() ) { 
     270                        $billing_phone = $order->get_billing_phone(); 
     271                    } else { 
     272                        $billing_phone = $order->billing_phone; 
     273                    } 
     274 
     275                    return $is_allowed['customer_phone'] && $billing_phone ? $billing_phone : ''; 
    177276                } 
    178277 
  • affiliatewp-order-details-for-affiliates/trunk/readme.txt

    r1420612 r1660552  
    11=== AffiliateWP - Order Details For Affiliates === 
    2 Contributors: sumobi, mordauk 
     2Contributors: sumobi, mordauk, drewapicture 
    33Tags: AffiliateWP, affiliate, Pippin Williamson, Andrew Munro, mordauk, pippinsplugins, sumobi, ecommerce, e-commerce, e commerce, selling, membership, referrals, marketing 
    44Requires at least: 3.3 
    5 Tested up to: 4.5.2 
    6 Stable tag: 1.1.2 
     5Tested up to: 4.7.5 
     6Stable tag: 1.1.3 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    5656Then you allow access in one of two ways: 
    5757 
    58 1. Globally enable access for all affiliates. This can be done via the "Allow Global Access To Order Details" checkbox located in Affiliates &rarr; Settings &rarr; Misc. 
     581. Globally enable access for all affiliates. This can be done via the "Allow Global Access To Order Details" checkbox located in Affiliates &rarr; Settings &rarr; Integrations. 
    59592. Enable access on a per-affiliate level. This can be done by editing an affiliate and enabling the "Order Details Access" checkbox located from Affiliates &rarr; Affiliates &rarr; Edit. 
    6060 
     
    7474 
    7575== Changelog == 
     76 
     77= 1.1.3 = 
     78* Fix: Avoid a fatal error in WooCommerce 3.0.0+ on the Order Details tab when an order doesn't exist 
     79* Fix: Other WooCommerce 3.0.0+ compatibility fixes 
    7680 
    7781= 1.1.2 = 
  • affiliatewp-order-details-for-affiliates/trunk/templates/dashboard-tab-order-details.php

    r1660551 r1660552  
    3737 
    3838            foreach ( $referrals as $referral ) { 
     39 
     40                // Skip output if the order doesn't exist. 
     41                if ( ! $affwp_odfa->order_details->exists( $referral ) ) { 
     42                    continue; 
     43                } 
    3944 
    4045                $order_number              = $affwp_odfa->order_details->get( $referral, 'order_number' ); 
Note: See TracChangeset for help on using the changeset viewer.