From 0d775d736cd6acf75f9fe854bb50af19d0078ef2 Mon Sep 17 00:00:00 2001 From: ellynoize Date: Wed, 29 Jan 2025 11:58:54 +0300 Subject: [PATCH] method writeOptionalPurchasePrice --- intaro.retailcrm/lib/icml/icmlwriter.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/intaro.retailcrm/lib/icml/icmlwriter.php b/intaro.retailcrm/lib/icml/icmlwriter.php index 876db677..4ae4c81a 100644 --- a/intaro.retailcrm/lib/icml/icmlwriter.php +++ b/intaro.retailcrm/lib/icml/icmlwriter.php @@ -163,7 +163,7 @@ class IcmlWriter $this->writeOptionalSimpleElement('vatRate', $offer->vatRate); $this->writeOptionalSimpleElement('weight', $offer->weight); $this->writeOptionalSimpleElement('dimensions', $offer->dimensions); - $this->writeOptionalSimpleElement('purchasePrice', $offer->purchasePrice, true); + $this->writeOptionalPurchasePrice($offer->purchasePrice); $this->writer->endElement(); } @@ -173,15 +173,23 @@ class IcmlWriter * @param string $name * @param $value */ - private function writeOptionalSimpleElement(string $name, $value, bool $isEmptyAllowed = false): void + private function writeOptionalSimpleElement(string $name, $value): void { if (!empty($value)) { $this->writeSimpleElement($name, $value); - } elseif ($isEmptyAllowed && $name === 'purchasePrice') { - $this->writeSimpleElement($name, 0); } } + /** + * Запись закупочной стоимости + * + * @param $value + */ + private function writeOptionalPurchasePrice($value): void + { + $this->writeSimpleElement('purchasePrice', !empty($value) ? $value : 0); + } + /** * @param string $name * @param $value