diff --git a/commerce_pricelist.module b/commerce_pricelist.module index 6a60777..b950a9b 100644 --- a/commerce_pricelist.module +++ b/commerce_pricelist.module @@ -107,7 +107,9 @@ function update_price_list_item(array $form, \Drupal\Core\Form\FormStateInterfac $itemEntity->setName($entity->getTitle()); } if (!$itemEntity->getPrice()) { - $itemEntity->setPrice($entity->getPrice()); + if ($entity->getPrice()) { + $itemEntity->setPrice($entity->getPrice()); + } } $itemEntity->save(); } diff --git a/src/Form/PriceListItemInlineForm.php b/src/Form/PriceListItemInlineForm.php index 18ad313..2b40ec4 100644 --- a/src/Form/PriceListItemInlineForm.php +++ b/src/Form/PriceListItemInlineForm.php @@ -2,6 +2,7 @@ namespace Drupal\commerce_pricelist\Form; +use Drupal\commerce_price\Price; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\inline_entity_form\Form\EntityInlineForm; @@ -93,7 +94,9 @@ class PriceListItemInlineForm extends EntityInlineForm { // set price if price is null if ($product && !$entity->getPrice()) { - $entity->setPrice($product->getPrice()); + if ($product->getPrice()) { + $entity->setPrice($product->getPrice()); + } } $entity->save();