Plugin Directory

Changeset 2315763


Ignore:
Timestamp:
06/01/2020 10:52:36 AM (6 years ago)
Author:
Easify
Message:

Version 4.20

Location:
easify-server-woocommerce/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • easify-server-woocommerce/trunk/easify.php

    r2289263 r2315763  
    55 * Plugin URI: http://www.easify.co.uk/wordpress/
    66 * Description: Connects Easify Business Management, EPOS (Electronic Point of Sale) and invoicing software to your WooCommerce enabled WordPress website. Allowing you to keep your online and offline shop's orders and stock control synchronised.
    7  * Version: 4.19
     7 * Version: 4.20
    88 * License: GPL2
    99 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1212 * Requires at least: 4.0
    1313 * Tested up to: 5.4
     14 * WC tested up to: 4.1
    1415 */
    1516
    1617/**
    17  * Copyright (C) 2019  Easify Ltd (email:support@easify.co.uk)
     18 * Copyright (C) 2020  Easify Ltd (email:support@easify.co.uk)
    1819 * This program is free software; you can redistribute it and/or
    1920 * modify it under the terms of the GNU General Public License
  • easify-server-woocommerce/trunk/includes/class-easify-wc-send-order-to-easify.php

    r2173054 r2315763  
    11<?php
    22/**
    3  * Copyright (C) 2017  Easify Ltd (email:support@easify.co.uk)
     3 * Copyright (C) 2020  Easify Ltd (email:support@easify.co.uk)
    44 * This program is free software; you can redistribute it and/or
    55 * modify it under the terms of the GNU General Public License
     
    3131 *
    3232 * @class       Easify_WC_Send_Order_To_Easify
    33  * @version     4.5
     33 * @version     4.20
    3434 * @package     easify-woocommerce-connector
    3535 * @author      Easify
     
    228228
    229229            // Copy WooCommerce order detail (product) to Easify Order Model order details   
    230             $easify_order_detail->Sku = $this->get_easify_sku_by_woocommerce_product_id($woocommerce_product['product_id']);
     230           
     231            $variationId = $woocommerce_product['variation_id'];
     232            Easify_Logging::Log('Easify_WC_Send_Order_To_Easify.do_order_details() $variationId: ' . $variationId);         
     233           
     234            $easify_order_detail->Sku = $this->get_easify_sku_by_woocommerce_product_id($woocommerce_product['product_id'], $variationId);                 
     235                     
    231236            $easify_order_detail->Qty = $woocommerce_product['qty'];
    232237            $easify_order_detail->Price = round($woocommerce_product['line_subtotal'] / ($woocommerce_product['qty'] == 0 ? 1 : $woocommerce_product['qty']), 4);
     
    288293     * @return integer
    289294     */
    290     private function get_easify_sku_by_woocommerce_product_id($woocommerce_product_id) {
     295    private function get_easify_sku_by_woocommerce_product_id($woocommerce_product_id, $variationId) {
    291296        global $wpdb;
    292         return $wpdb->get_var($wpdb->prepare(
    293                                 "SELECT meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = '_sku' AND post_id = '%s' LIMIT 1", $woocommerce_product_id
    294         ));
     297       
     298        Easify_Logging::Log('Easify_WC_Send_Order_To_Easify.get_easify_sku_by_woocommerce_product_id() ' .
     299                ' $woocommerce_product_id: ' . $woocommerce_product_id .
     300                ' $variationId: ' . $variationId);
     301       
     302        if ($variationId != '0')
     303        {
     304            // Have variation - try to get sku
     305            $sku = $wpdb->get_var($wpdb->prepare(
     306                    "SELECT meta_value FROM " . $wpdb->postmeta .
     307                    " WHERE meta_key = '_sku' AND post_id = '%s' LIMIT 1", $variationId));
     308           
     309            if ($sku == '')
     310            {
     311                Easify_Logging::Log('Easify_WC_Send_Order_To_Easify.get_easify_sku_by_woocommerce_product_id() ' .
     312                ' variation not found, must be first variation which does not have SKU. Using productId instead.');
     313       
     314                // First variation doesn't have a SKU, instead use product Id           
     315                $sku = $wpdb->get_var($wpdb->prepare(
     316                    "SELECT meta_value FROM " . $wpdb->postmeta .
     317                    " WHERE meta_key = '_sku' AND post_id = '%s' LIMIT 1", $woocommerce_product_id));             
     318            }
     319                       
     320        }
     321        else
     322        {
     323            // Not a variation
     324            $sku = $wpdb->get_var($wpdb->prepare(
     325                    "SELECT meta_value FROM " . $wpdb->postmeta .
     326                    " WHERE meta_key = '_sku' AND post_id = '%s' LIMIT 1", $woocommerce_product_id));
     327        }
     328       
     329        return $sku;
    295330    }
    296331
  • easify-server-woocommerce/trunk/readme.txt

    r2289263 r2315763  
    55Requires at least: 4.0
    66Tested up to: 5.4
    7 Stable tag: 4.19
     7Stable tag: 4.20
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    10 WC tested up to: 4.0
     10WC tested up to: 4.1
    1111
    1212Connects Easify V4.x Small Business Software to your WooCommerce online shop,
     
    101101
    102102== Changelog ==
     103= 4.20 =
     104* Added support for WooCommerce product variations. See https://www.easify.co.uk/Help/ecommerce-woocommerce-product-variations
    103105= 4.19 =
    104106* Added new Product settings options to allow products to be not uploaded from
     
    165167
    166168== Upgrade Notice ==
    167 = 4.19 =
    168 * Added new Product settings options to allow products to be not uploaded from
    169 Easify when first published, also to ignore price and/or stock level changes
    170 from Easify.
     169= 4.20 =
     170* Added support for WooCommerce product variations. See https://www.easify.co.uk/Help/ecommerce-woocommerce-product-variations
Note: See TracChangeset for help on using the changeset viewer.