HEX
Server: Apache/2.4.49 (FreeBSD) OpenSSL/1.0.2s-freebsd PHP/5.6.36
System: FreeBSD hosting.icon.bg 11.3-RELEASE-p13 FreeBSD 11.3-RELEASE-p13 #0: Tue Sep 1 06:56:51 UTC 2020 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
User: ftpuser (1002)
PHP: 5.6.36
Disabled: NONE
Upload Files
File: /hosting/kak.bg/web/wp-content/plugins/wp-all-export-pro/src/App/Field/SalePrice.php
<?php

namespace Wpae\App\Field;


class SalePrice extends Field
{
    const SECTION = 'availabilityPrice';

    public function getValue($snippetData)
    {
        $availabilityPriceData = $this->feed->getSectionFeedData(self::SECTION);

        if($availabilityPriceData['salePrice'] == self::CUSTOM_VALUE_TEXT) {
            $price = $this->replaceSnippetsInValue($availabilityPriceData['salePriceCV'], $snippetData);

        } else if($availabilityPriceData['salePrice'] == 'useProductSalePrice') {
            $product = wc_get_product($this->entry->ID);
            $price = $product->get_sale_price();

        } else {
            throw new \Exception('Unknown field value '.$availabilityPriceData['salePrice']);
        }

        if($availabilityPriceData['adjustSalePriceValue']) {
            $adjustPriceValue = $this->replaceSnippetsInValue($availabilityPriceData['adjustSalePriceValue'], $snippetData);
            if($availabilityPriceData['adjustSalePriceType'] == '%') {
                if($price != 0) {
                    $price = $adjustPriceValue/100*$price;
                } else {
                    $price = 0;
                }
            } else {
                $price = $price + $adjustPriceValue;
            }
        }

        $rawPrices = false;
        $rawPrices = apply_filters('wp_all_export_raw_prices', $rawPrices);

        if(!$rawPrices){
            if($price) {
                if(is_numeric($price)){
                    return number_format($price, 2) .' '.$availabilityPriceData['currency'];
                } else {
                    return $price.' '.$availabilityPriceData['currency'];
                }

            } else {
                return "";
            }
        } else {
            return $price;
        }
    }

    public function getFieldName()
    {
        return 'sale_price';
    }
}