2013-06-27 29 views
0

我有一個產品有多個選項。Magento - 讓用戶選擇不含稅的包含稅

用戶選擇他想要爲產品付多少錢。 首先,我創建了一個值爲€5, - €10, - 等的下拉框。 我已將產品價格設置爲€0。

當我選擇10歐元時,產品更改爲10歐元 - 這很好。

現在我想要一個複選框,用戶可以在Exclude Tax和Include Tax之間進行選擇,所以如果我選擇不含稅,產品將被插入購物車中,因爲€10,00女巫可以(不含稅)。 但是,當我選擇包括稅產品需要插入購物車10 /1.21 =€8,26(不含稅)。

我該如何做到這一點?

編輯:

我有以下代碼:

$event = $observer->getEvent(); 
$quote_item = $event->getQuoteItem(); 

    if (is_array($quote_item->getOptions())) { 
     foreach ($quote_item->getOptions() as $optionValue) { 
      echo ???? . ' --> ' . $optionValue->getValue() . '<br />'; 
     } 
    } 

這會給我從選項的值。 但是,我如何得到真正的option_id?我現在得到了option_type_id。

回答

0

如果你看一下以下頁面 應用程序/設計/前端/預設/默認/模板/目錄/產品/ price.phtml

you will find below code 

<?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)): // including ?> 
     <span class="price-excluding-tax"> 
      <span class="label"><?php echo $_taxHelper->__('Excl. Tax:') ?></span> 
      <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
       <?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?> 
      </span> 
     </span> 
     <span class="price-including-tax"> 
      <span class="label"><?php echo $_taxHelper->__('Incl. Tax:') ?></span> 
      <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
       <?php echo $_coreHelper->currency($_finalPriceInclTax+$_weeeTaxAmount,true,false) ?> 
      </span> 
     </span> 
    <?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> 
     <span class="price-excluding-tax"> 
      <span class="label"><?php echo $_taxHelper->__('Excl. Tax:') ?></span> 
      <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
       <?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?> 
      </span> 
     </span> 

實現你可以參考

Changing the price in quote while adding product to cart: magento

+0

我可以用jQuery在產品視圖中顯示價格。但是,如何通過排除稅款而不是納稅來保存產品。例如,如果選擇10歐元並選擇不含稅的選項,那麼它需要在購物車中插入8,26歐元 – FamousWolluf

+0

您需要checkout_cart_save_before事件觀察員,然後修改所選產品的項目價格 –

+0

查看正題我添加了一個代碼一個問題 – FamousWolluf

相關問題