Plugin Directory

Changeset 2298313


Ignore:
Timestamp:
05/05/2020 09:17:46 AM (6 years ago)
Author:
marguspala
Message:

version 3.0.5

Location:
smartaccounts/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • smartaccounts/trunk/SmartAccountsArticleAsync.php

    r2053161 r2298313  
    143143
    144144        $regularPrice = get_post_meta($post_id, '_regular_price', true);
    145         $salePrice    = get_post_meta($post_id, '_price', true);
    146         if ( ! $regularPrice) {
     145        $finalPrice   = get_post_meta($post_id, '_price', true);
     146        $salePrice    = get_post_meta($post_id, '_sale_price', true);
     147        if ( ! $regularPrice || ! $finalPrice) {
     148            // No price set at all yet, set one now.
    147149            update_post_meta($post_id, '_regular_price', $data['price']);
    148         } else if ($regularPrice && $salePrice && ($salePrice == $regularPrice)) {
    149             update_post_meta($post_id, '_regular_price', $data['price']);
    150         } else if ($regularPrice && $salePrice && (floatval($data['price']) > floatval($regularPrice))) {
     150            update_post_meta($post_id, '_price', $data['price']);
     151        } elseif ($salePrice && ($salePrice !== $regularPrice)) {
     152            // Sale price is set. Update only regular price and keep actual sale price what it is.
    151153            update_post_meta($post_id, '_regular_price', $data['price']);
    152154        }
    153155
    154         update_post_meta($post_id, '_price', $data['price']);
     156        if ($finalPrice && (floatval($data['price']) > floatval($regularPrice))) {
     157            // New final price is more than regular price so regular price will be updated also.
     158            update_post_meta($post_id, '_regular_price', $data['price']);
     159        }
     160
    155161        update_post_meta($post_id, '_sku', $code);
    156162        update_post_meta($post_id, '_visibility', 'visible');
  • smartaccounts/trunk/SmartAccountsClass.php

    r2283842 r2298313  
    3434            error_log("Offer data: " . json_encode($offer));
    3535            error_log("SmartAccounts sales offer created for order $order_id=" . $offer['offer']['offerId']);
     36            $order->add_order_note("Offer sent to SmartAccounts: " . $offer['offer']['offerNumber']);
     37
    3638            $offerIdsString = get_option('sa_failed_offers');
    3739            $offerIds       = json_decode($offerIdsString);
     
    5759
    5860            wp_schedule_single_event(time() + 129600, 'sa_retry_failed_job');
     61            $order->add_order_note("Offer sending to SmartAccounts failed: " . $exception->getMessage());
    5962        }
    6063    }
     
    8285            update_post_meta($order_id, 'smartaccounts_invoice_id', $invoice['invoice']['invoiceNumber']);
    8386            error_log("SmartAccounts sales invoice created for order $order_id - " . $invoice['invoice']['invoiceNumber']);
     87            $order->add_order_note("Invoice sent to SmartAccounts: " . $invoice['invoice']['invoiceNumber']);
     88
    8489            $invoiceIdsString = get_option('sa_failed_orders');
    8590            $invoiceIds       = json_decode($invoiceIdsString);
     
    105110
    106111            wp_schedule_single_event(time() + 129600, 'sa_retry_failed_job');
     112            $order->add_order_note("Invoice sending to SmartAccounts failed: " . $exception->getMessage());
    107113        }
    108114    }
  • smartaccounts/trunk/readme.txt

    r2282902 r2298313  
    3232== Importing products from SmartAccounts ==
    3333* Products must be active sales items and of type Warehouse Item or Product. Services are not imported.
    34 * Product final sale price is price taken from SmartAccounts. If discount prices is needed then Regular price needs to be changed and then Regular price is not changed.
     34* Product final price is taken from SmartAccounts unless sale price is set. If sale price is set manually then only regular price is changed.
    3535
    3636== Note about Woo and SmartAccounts client matching ==
     
    5858
    5959== Changelog ==
     60
     61= 3.0.5 =
     62Improved pricing when sale price is set.
    6063
    6164= 3.0.2 =
  • smartaccounts/trunk/smartaccounts.php

    r2290867 r2298313  
    44 * Plugin URI: https://github.com/smartman/woocommerce_smartaccounts
    55 * Description: This plugin creates sales invoices in the smartaccounts.ee Online Accounting Software after Woocommerce order creation
    6  * Version: 3.0.4
     6 * Version: 3.0.5
    77 * Author: Margus Pala
    88 * Author URI: https://marguspala.com
Note: See TracChangeset for help on using the changeset viewer.