Plugin Directory

Changeset 2887511


Ignore:
Timestamp:
03/27/2023 11:04:39 AM (3 years ago)
Author:
viaads
Message:

Performance on sync after initial

Location:
viaads
Files:
16 added
3 edited

Legend:

Unmodified
Added
Removed
  • viaads/trunk/readme.txt

    r2884235 r2887511  
    44Requires at least: 5.4
    55Tested up to: 6.1
    6 Stable tag: 1.1.10
     6Stable tag: 1.1.11
    77Requires PHP: 7.0
    88License: GPLv3
  • viaads/trunk/sync.php

    r2884235 r2887511  
    3131            $webshop->ApiKey = get_option($name);
    3232            $webshop->Categories = ViaAds_getCategories();
    33             $webshop->Products = ViaAds_getProducts();
     33            $webshop->Products = ViaAds_getProducts($_GET['full']);
    3434            if (isset($_GET['debug']) && $_GET['debug'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") {
     35                print_r(ViaAds_PostToUrl("https://sync.viaads.dk/woocommerce/WebShopData", $webshop, true));
     36            } else if (isset($_GET['debug1']) && $_GET['debug1'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") {
    3537                print_r(json_encode($webshop));
    36                 print_r(ViaAds_PostToUrl("https://sync.viaads.dk/woocommerce/WebShopData", $webshop, true));
    3738            } else {
    3839                //Split array in chucks for max data size
     
    4748            $orders = ViaAds_getOrders();
    4849            if (isset($_GET['debug']) && $_GET['debug'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") {
     50                print_r(ViaAds_PostToUrl("https://sync.viaads.dk/woocommerce/WebShopOrderData", $orders, true));
     51            } else if (isset($_GET['debug1']) && $_GET['debug1'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") {
    4952                print_r(json_encode($orders));
    50                 print_r(ViaAds_PostToUrl("https://sync.viaads.dk/woocommerce/WebShopOrderData", $orders, true));
    5153            } else {
    5254                ViaAds_PostToUrl("https://sync.viaads.dk/woocommerce/WebShopOrderData", $orders, true);
     
    6971
    7072
    71 function ViaAds_getProducts()
     73function ViaAds_getProducts($full)
    7274{
    73     $args = array(
    74         'orderby' => 'name',
    75         'limit' => -1,
    76     );
     75    if ($full == "True") {
     76        $args = array(
     77            'orderby' => 'name',
     78            'limit' => -1,
     79        );
     80    } else {
     81        $args = array(
     82            'orderby' => 'name',
     83            'limit' => -1,
     84            'date_modified' => '>' . (time() - 3 * 24 * 60 * 60),
     85        );
     86    }
    7787    $productCollection = wc_get_products($args);
    7888    $products = [];
    7989
    80     if (isset($_GET['debug1']) && $_GET['debug1'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") {
     90    if (isset($_GET['debug2']) && $_GET['debug2'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") {
    8191        print_r($productCollection);
    8292    }
    83 
    8493
    8594    foreach ($productCollection as $product) {
     
    318327
    319328    $orderCollection = wc_get_orders(array(
    320         'limit'      => -1,
     329        'limit' => -1,
    321330        'date_modified' => date('Y-m-d', strtotime(date("Y-m-d") . ' - ' . $lookBackDays . ' days')) . '...'
    322331            . date('Y-m-d'),
    323332    ));
    324333
    325     if (isset($_GET['debug1']) && $_GET['debug1'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") {
     334    if (isset($_GET['debug2']) && $_GET['debug2'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") {
    326335        print_r($orderCollection);
    327336    }
     
    347356            // Vat Percentage
    348357            $vat_percentage = floatval('0.25');
    349             foreach($order->get_items('tax') as $item_id => $item ) {
    350                 $tax_rate_id    = $item->get_rate_id(); // Tax rate ID
    351                 $tax_percent    = WC_Tax::get_rate_percent( $tax_rate_id ); // Tax percentage
    352                 $vat_percentage       = floatval("0." . str_replace('%', '', $tax_percent)); // Tax rate
     358            foreach ($order->get_items('tax') as $item_id => $item) {
     359                $tax_rate_id = $item->get_rate_id(); // Tax rate ID
     360                $tax_percent = WC_Tax::get_rate_percent($tax_rate_id); // Tax percentage
     361                $vat_percentage = floatval("0." . str_replace('%', '', $tax_percent)); // Tax rate
    353362            }
    354363
     
    422431
    423432                // Refunds
    424                 if(count($refundItems) > 0) {
     433                if (count($refundItems) > 0) {
    425434                    foreach ($refundItems as $refund) {
    426435                        if ($order_item_object->Product_id == $refund->Product_id &&
     
    431440                }
    432441
    433                 if($order_item_object->Quantity > 0) {
     442                if ($order_item_object->Quantity > 0) {
    434443                    array_push($orderItems, $order_item_object);
    435444                }
  • viaads/trunk/viaads.php

    r2884235 r2887511  
    33 * Plugin Name: ViaAds
    44 * Description: Plugin der muliggør forbindelsen til ViaAds / Plug-in enabling the connection to ViaAds.
    5  * Version: 1.1.10
     5 * Version: 1.1.11
    66 * Author: ViaAds
    77 * Author URI: https://www.viaads.dk/
Note: See TracChangeset for help on using the changeset viewer.