Plugin Directory

Changeset 2406712


Ignore:
Timestamp:
10/26/2020 11:41:31 AM (5 years ago)
Author:
avecdo
Message:

Added support for the Discount Rules plugin and minor bug fixes

Location:
avecdo-for-woocommerce
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • avecdo-for-woocommerce/tags/1.4.12/avecdo.php

    r2365645 r2406712  
    44 * Plugin URI: https://avecdo.com/
    55 * Description: avecdo connector plugin for WooCommerce
    6  * Version: 1.4.11
     6 * Version: 1.4.12
    77 * Author: Modified Solutions ApS
    88 * Author URI: https://www.modified.dk/
     
    1010 * Developer URI: https://www.modified.dk/
    1111 * Requires at least: 3.5
    12  * Tested up to: 5.5.0
     12 * Tested up to: 5.5.1
    1313 * WC requires at least: 2.5.0
    14  * WC tested up to: 4.2.0
     14 * WC tested up to: 4.6.0
    1515 *
    1616 * Text Domain: avecdo-for-woocommerce
     
    3131 * @var string Version string
    3232 */
    33 define('AVECDO_WOOCOMMERCE_PLUGIN_VERSION', '1.4.11');
     33define('AVECDO_WOOCOMMERCE_PLUGIN_VERSION', '1.4.12');
    3434
    3535/**
  • avecdo-for-woocommerce/tags/1.4.12/models/Model.php

    r2365645 r2406712  
    392392                    // starts with 'attribute_'
    393393                    $this->assignAvecdoProductMetaData_Attribute($metaRow, $avecdoProduct);
     394
     395                    // Set the Discount Rule sale price if any.
     396                    $this->setDiscountRuleSalePrice($productId, $avecdoProduct);
    394397                    break;
    395398            }
     
    12421245                // If the shippingId is sat to 0, then we will use global costs, else we add the shipping price, with the class price.
    12431246                if($shippingId == 0) {
    1244                     $rate = (float)$shipping_method->instance_settings["cost"] + (float)$shipping_method->instance_settings["no_class_cost"];
     1247                   if(isset($shipping_method->instance_settings["no_class_cost"])){
     1248                        $rate = (float)$shipping_method->instance_settings["cost"] + (float)$shipping_method->instance_settings["no_class_cost"];
     1249                    } else {
     1250                        $rate = (float)$shipping_method->instance_settings["cost"];
     1251                    }
    12451252                } else {
    12461253                    $rate = (float)$shipping_method->instance_settings["cost"] + (float)$shipping_method->instance_settings["class_cost_".$shippingId];
  • avecdo-for-woocommerce/tags/1.4.12/models/WooQueries.php

    r2081150 r2406712  
    22
    33namespace Avecdo;
     4
     5use AvecdoSDK\POPO\Product;
    46
    57if (!defined('ABSPATH')) {
     
    468470    protected function getSalePrice($productId)
    469471    {
     472        $discountRulesPrice = $this->getDiscountRulesSalePrice($productId);
     473        if (!empty($discountRulesPrice)) {
     474            return $discountRulesPrice;
     475        }
     476
    470477        $query        = "
    471478                     SELECT
     
    534541        return $GLOBALS['woocommerce'];
    535542    }
     543
     544    // Check if the Discount Rules plugin is enabled.
     545    // https://wordpress.org/plugins/woo-discount-rules
     546    public function isDiscountRulesEnabled()
     547    {
     548        if ( ! function_exists( 'is_plugin_active' ) )
     549            require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
     550
     551        return \is_plugin_active('woo-discount-rules/woo-discount-rules.php');
     552    }
     553
     554    /**
     555     * @param $productId
     556     * @author Kasper Færch Mikkelsen <kasper@modified.dk>
     557     * @date 13/10/20
     558     *
     559     * Check if Discount Rules plugin is active, and then get the sale price for the selected product.
     560     */
     561    public function getDiscountRulesSalePrice($productId)
     562    {
     563        if ($this->isDiscountRulesEnabled()) {
     564            $product = wc_get_product($productId);
     565
     566            $discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', (float)$product->get_price(), $product, 1, 0, 'discounted_price', true, false);
     567            if (!empty($discount)) {
     568                return (float)$discount;
     569            }
     570
     571            return $product->get_sale_price();
     572        }
     573
     574        return null;
     575    }
     576
     577    // Set the sale price for a product to the value from the Discount Rules plugin.
     578    public function setDiscountRuleSalePrice($productId, Product $avecdoProduct)
     579    {
     580        $avecdoProduct->setPriceSale($this->getDiscountRulesSalePrice($productId));
     581    }
    536582}
  • avecdo-for-woocommerce/tags/1.4.12/readme.txt

    r2365645 r2406712  
    33Tags: feed, service, avecdo, Facebook, Google Shopping, shopping, woocommerce, kelkoo, miinto, Pricerunner, Partner-ads, ecommerce, e-commerce
    44Requires at least: 3.5
    5 Tested up to: 5.5.0
    6 Stable tag: 1.4.11
     5Tested up to: 5.5.1
     6Stable tag: 1.4.12
    77License: Mozilla Public License Version 2.0
    88License URI: https://www.mozilla.org/en-US/MPL/2.0/
     
    4545
    4646== Changelog ==
     47
     48= 1.4.12 =
     49* Support for version 2.x of the plugin 'Discount Rules for WooCommerce'.
     50* Minor bug fix related to shipping prices.
     51* Tested with latest Wordpress and WooCommerce versions.
    4752
    4853= 1.4.11 =
  • avecdo-for-woocommerce/trunk/avecdo.php

    r2365645 r2406712  
    44 * Plugin URI: https://avecdo.com/
    55 * Description: avecdo connector plugin for WooCommerce
    6  * Version: 1.4.11
     6 * Version: 1.4.12
    77 * Author: Modified Solutions ApS
    88 * Author URI: https://www.modified.dk/
     
    1010 * Developer URI: https://www.modified.dk/
    1111 * Requires at least: 3.5
    12  * Tested up to: 5.5.0
     12 * Tested up to: 5.5.1
    1313 * WC requires at least: 2.5.0
    14  * WC tested up to: 4.2.0
     14 * WC tested up to: 4.6.0
    1515 *
    1616 * Text Domain: avecdo-for-woocommerce
     
    3131 * @var string Version string
    3232 */
    33 define('AVECDO_WOOCOMMERCE_PLUGIN_VERSION', '1.4.11');
     33define('AVECDO_WOOCOMMERCE_PLUGIN_VERSION', '1.4.12');
    3434
    3535/**
  • avecdo-for-woocommerce/trunk/models/Model.php

    r2365645 r2406712  
    392392                    // starts with 'attribute_'
    393393                    $this->assignAvecdoProductMetaData_Attribute($metaRow, $avecdoProduct);
     394
     395                    // Set the Discount Rule sale price if any.
     396                    $this->setDiscountRuleSalePrice($productId, $avecdoProduct);
    394397                    break;
    395398            }
     
    12421245                // If the shippingId is sat to 0, then we will use global costs, else we add the shipping price, with the class price.
    12431246                if($shippingId == 0) {
    1244                     $rate = (float)$shipping_method->instance_settings["cost"] + (float)$shipping_method->instance_settings["no_class_cost"];
     1247                   if(isset($shipping_method->instance_settings["no_class_cost"])){
     1248                        $rate = (float)$shipping_method->instance_settings["cost"] + (float)$shipping_method->instance_settings["no_class_cost"];
     1249                    } else {
     1250                        $rate = (float)$shipping_method->instance_settings["cost"];
     1251                    }
    12451252                } else {
    12461253                    $rate = (float)$shipping_method->instance_settings["cost"] + (float)$shipping_method->instance_settings["class_cost_".$shippingId];
  • avecdo-for-woocommerce/trunk/models/WooQueries.php

    r2081150 r2406712  
    22
    33namespace Avecdo;
     4
     5use AvecdoSDK\POPO\Product;
    46
    57if (!defined('ABSPATH')) {
     
    468470    protected function getSalePrice($productId)
    469471    {
     472        $discountRulesPrice = $this->getDiscountRulesSalePrice($productId);
     473        if (!empty($discountRulesPrice)) {
     474            return $discountRulesPrice;
     475        }
     476
    470477        $query        = "
    471478                     SELECT
     
    534541        return $GLOBALS['woocommerce'];
    535542    }
     543
     544    // Check if the Discount Rules plugin is enabled.
     545    // https://wordpress.org/plugins/woo-discount-rules
     546    public function isDiscountRulesEnabled()
     547    {
     548        if ( ! function_exists( 'is_plugin_active' ) )
     549            require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
     550
     551        return \is_plugin_active('woo-discount-rules/woo-discount-rules.php');
     552    }
     553
     554    /**
     555     * @param $productId
     556     * @author Kasper Færch Mikkelsen <kasper@modified.dk>
     557     * @date 13/10/20
     558     *
     559     * Check if Discount Rules plugin is active, and then get the sale price for the selected product.
     560     */
     561    public function getDiscountRulesSalePrice($productId)
     562    {
     563        if ($this->isDiscountRulesEnabled()) {
     564            $product = wc_get_product($productId);
     565
     566            $discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', (float)$product->get_price(), $product, 1, 0, 'discounted_price', true, false);
     567            if (!empty($discount)) {
     568                return (float)$discount;
     569            }
     570
     571            return $product->get_sale_price();
     572        }
     573
     574        return null;
     575    }
     576
     577    // Set the sale price for a product to the value from the Discount Rules plugin.
     578    public function setDiscountRuleSalePrice($productId, Product $avecdoProduct)
     579    {
     580        $avecdoProduct->setPriceSale($this->getDiscountRulesSalePrice($productId));
     581    }
    536582}
  • avecdo-for-woocommerce/trunk/readme.txt

    r2365645 r2406712  
    33Tags: feed, service, avecdo, Facebook, Google Shopping, shopping, woocommerce, kelkoo, miinto, Pricerunner, Partner-ads, ecommerce, e-commerce
    44Requires at least: 3.5
    5 Tested up to: 5.5.0
    6 Stable tag: 1.4.11
     5Tested up to: 5.5.1
     6Stable tag: 1.4.12
    77License: Mozilla Public License Version 2.0
    88License URI: https://www.mozilla.org/en-US/MPL/2.0/
     
    4545
    4646== Changelog ==
     47
     48= 1.4.12 =
     49* Support for version 2.x of the plugin 'Discount Rules for WooCommerce'.
     50* Minor bug fix related to shipping prices.
     51* Tested with latest Wordpress and WooCommerce versions.
    4752
    4853= 1.4.11 =
Note: See TracChangeset for help on using the changeset viewer.