Plugin Directory

Changeset 1603451


Ignore:
Timestamp:
02/25/2017 01:18:17 PM (9 years ago)
Author:
RightPress
Message:

Version 1.0.1

Location:
decorator-woocommerce-email-customizer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • decorator-woocommerce-email-customizer/trunk/changelog

    r1556452 r1603451  
     1Version 1.0.1, 25 February 2017
     2------------------------------------------------------------------------------------
     3* Tweak - Improved compatibility with WooCommerce 2.7
     4
    15Version 1.0, 12 December 2016
    26------------------------------------------------------------------------------------
  • decorator-woocommerce-email-customizer/trunk/decorator.php

    r1556452 r1603451  
    55 * Plugin URI: http://www.rightpress.net/decorator
    66 * Description: Use native WordPress Customizer to make WooCommerce emails match your brand
    7  * Version: 1.0
     7 * Version: 1.0.1
    88 * Author: RightPress
    99 * Author URI: http://www.rightpress.net
     
    4242define('RP_DECORATOR_PLUGIN_PATH', plugin_dir_path(__FILE__));
    4343define('RP_DECORATOR_PLUGIN_URL', plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)));
    44 define('RP_DECORATOR_VERSION', '1.0');
     44define('RP_DECORATOR_VERSION', '1.0.1');
    4545define('RP_DECORATOR_SUPPORT_PHP', '5.3');
    4646define('RP_DECORATOR_SUPPORT_WP', '4.4');
  • decorator-woocommerce-email-customizer/trunk/includes/classes/rp-decorator-preview.class.php

    r1556452 r1603451  
    135135        $email->find['order-date']      = '{order_date}';
    136136        $email->find['order-number']    = '{order_number}';
    137         $email->replace['order-date']   = date_i18n(wc_date_format(), strtotime($email->object->order_date));
     137        $email->replace['order-date']   = date_i18n(wc_date_format(), (method_exists($email->object, 'get_date_created') ? $email->object->get_date_created() : strtotime($email->object->order_date)));
    138138        $email->replace['order-number'] = $email->object->get_order_number();
    139139
    140140        // Other properties
    141         $email->recipient = $email->object->billing_email;
     141        $email->recipient = method_exists($email->object, 'get_billing_email') ? $email->object->get_billing_email() : $email->object->billing_email;
    142142
    143143        // Get email content and apply styles
     
    170170        ));
    171171
    172         // Use WooCommerce order
     172        // Use real order
    173173        if (!empty($last_order_id)) {
    174174            $last_order_id = array_pop($last_order_id);
    175175            return wc_get_order($last_order_id);
    176176        }
    177         // Use mockup order
     177        // Use mockup order (WC 2.7+)
     178        else if (RP_Decorator::wc_version_gte('2.7')) {
     179
     180            // Instantiate order object
     181            $order = new WC_Order();
     182
     183            // Other order properties
     184            $order->set_props(array(
     185                'id'                    => 1,
     186                'status'                => ($order_status === null ? 'processing' : $order_status),
     187                'billing_first_name'    => 'Sherlock',
     188                'billing_last_name'     => 'Holmes',
     189                'billing_company'       => 'Detectives Ltd.',
     190                'billing_address_1'     => '221B Baker Street',
     191                'billing_city'          => 'London',
     192                'billing_postcode'      => 'NW1 6XE',
     193                'billing_country'       => 'GB',
     194                'billing_email'         => 'sherlock@holmes.co.uk',
     195                'billing_phone'         => '02079304832',
     196                'date_created'          => date('Y-m-d H:i:s'),
     197                'total'                 => 24.90,
     198            ));
     199
     200            // Item #1
     201            $order_item = new WC_Order_Item_Product();
     202            $order_item->set_props(array(
     203                'name'      => 'A Study in Scarlet',
     204                'subtotal'  => '9.95',
     205            ));
     206            $order->add_item($order_item);
     207
     208            // Item #2
     209            $order_item = new WC_Order_Item_Product();
     210            $order_item->set_props(array(
     211                'name'      => 'The Hound of the Baskervilles',
     212                'subtotal'  => '14.95',
     213            ));
     214            $order->add_item($order_item);
     215
     216            // Return mockup order
     217            return $order;
     218        }
     219        // Use mockup order (pre WC 2.7)
    178220        else {
    179221
Note: See TracChangeset for help on using the changeset viewer.