/**
  * cart was edited at SOFORT-backend, apply changes in shop
  * @param PnagInvoice $PnagInvoice
  */
 public function editArticlesShop(PnagInvoice $PnagInvoice, $orderNumber)
 {
     $lng = $PnagInvoice->getLanguageCode();
     $newAmount = $PnagInvoice->getAmount();
     $invoiceArticles = $PnagInvoice->getItems();
     foreach ($invoiceArticles as $article) {
         $getTotalItems = explode('|', $article->itemId);
         if (count($getTotalItems) > '1') {
             $sofortIdArray[$getTotalItems[0]] = $getTotalItems[0];
             $sofortArticleArray[$getTotalItems[0]] = $article;
         } else {
             $ordersProductsId = $this->_getOrderProductsId($article->itemId, $orderNumber);
             $sofortIdArray[$ordersProductsId] = $ordersProductsId;
             $sofortArticleArray[$ordersProductsId] = $article;
         }
     }
     $shopProductsQuery = shopDbQuery("SELECT orders_products_id FROM " . TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . $orderNumber . "'");
     while ($shopProductsResult = shopDbFetchArray($shopProductsQuery)) {
         $shopArticleArray[] = $shopProductsResult['orders_products_id'];
     }
     $taxLow = 0;
     $taxHigh = 0;
     $subtotal = 0;
     foreach ($shopArticleArray as $shopArticle) {
         if (!in_array($shopArticle, $sofortIdArray)) {
             $this->_sofortRestock($this->_getItemId($shopArticle, $orderNumber), $orderNumber, 0);
             $this->_deleteShopOrderArticle($shopArticle, $PnagInvoice->getStatusReason());
         } else {
             $qty = $sofortArticleArray[$shopArticle]->quantity;
             $price = $sofortArticleArray[$shopArticle]->unitPrice;
             $itemId = $sofortArticleArray[$shopArticle]->itemId;
             $this->_sofortRestock($itemId, $orderNumber, $qty);
             $this->_updateShopOrderArticle($shopArticle, $qty, $price, $PnagInvoice->getStatusReason());
             if ($sofortArticleArray[$shopArticle]->tax == '7.00') {
                 $taxLow += $sofortArticleArray[$shopArticle]->quantity * $sofortArticleArray[$shopArticle]->unitPrice;
             } elseif ($sofortArticleArray[$shopArticle]->tax == '19.00') {
                 $taxHigh += $sofortArticleArray[$shopArticle]->quantity * $sofortArticleArray[$shopArticle]->unitPrice;
             }
             $subtotal += $sofortArticleArray[$shopArticle]->quantity * $sofortArticleArray[$shopArticle]->unitPrice;
         }
     }
     $shipping = 0;
     $discount = array();
     $agio = array();
     foreach ($sofortIdArray as $sofortId) {
         if (!in_array($sofortId, $shopArticleArray)) {
             switch ($sofortId) {
                 case 'shipping':
                     $shipping = $sofortArticleArray[$sofortId]->unitPrice;
                     break;
                 case 'discount':
                     $splitItemId = explode('|', $sofortArticleArray[$sofortId]->itemId);
                     $discountClass = $splitItemId[1];
                     array_push($discount, array('class' => $discountClass, 'value' => $sofortArticleArray[$sofortId]->unitPrice));
                     break;
                 case 'agio':
                     $splitItemId = explode('|', $sofortArticleArray[$sofortId]->itemId);
                     $agioClass = $splitItemId[1];
                     array_push($agio, array('class' => $agioClass, 'value' => $sofortArticleArray[$sofortId]->unitPrice));
                     break;
                 default:
                     $this->_sofortRestock($sofortArticleArray[$sofortId]->itemId, $orderNumber, $sofortArticleArray[$sofortId]->quantity);
                     $this->_insertShopOrderArticle($sofortArticleArray[$sofortId], $orderNumber, $lng);
                     $subtotal += $sofortArticleArray[$sofortId]->quantity * $sofortArticleArray[$sofortId]->unitPrice;
                     break;
             }
             if ($sofortArticleArray[$sofortId]->tax == '7.00') {
                 $taxLow += $sofortArticleArray[$sofortId]->unitPrice * $sofortArticleArray[$sofortId]->quantity;
             } elseif ($sofortArticleArray[$sofortId]->tax == '19.00') {
                 $taxHigh += $sofortArticleArray[$sofortId]->unitPrice * $sofortArticleArray[$sofortId]->quantity;
             }
         }
     }
     $status = $PnagInvoice->getStatusReason();
     $this->_updateShopTotals($taxLow, $taxHigh, $subtotal, $newAmount, $orderNumber, $shipping, $discount, $agio, $status);
 }