2015-11-03 31 views
3

現在我已經閱讀了十幾個線程,甚至有十幾個不同的網頁提出了類似的問題。然而,這些回覆對我來說並不合適。我嘗試了所有這些。另外要注意的是我不能評論這個問題,因此也不能評論這個主題。儘可能詳細從我在magento checkout中可以看出來的內容與SHOPGRAM有關?這是我目前的結帳購物車。我有兩個名爲license_period的自定義屬性,另一個名爲number_of_devices。Magento Shopgram結賬頁面

我需要在結帳購物車中添加這兩個字段。有一點需要注意的是,我已經完成了測試,似乎位於@/app/design/frontend/shopgram/default/template/checkout的文件cart_new.phtml控制了佈局。這個腳本我試過編輯我已經嘗試了很多,但是我所做的任何改變甚至都沒有出現。即使當我編輯default.phtml @ /應用程序/設計/前端/ shopgram /默認/模板/ checkout /購物車/項目它不做任何更改,我甚至已刪除這些directorys中的大部分文件,它不會導致任何更改內容。只有cart_new.phtml控制內容。

現在我不知道magento太好,所以我可能會誤會。但是,當我嘗試了很多不同的查詢,並且他們大多數什麼都不做。其中一些導致桌子消失。

以下只是我嘗試過的100個鏈接中的2個。不過,我只能發佈兩個鏈接。

Display Magento Custom Option Values in Shoping Cart

https://magento.stackexchange.com/questions/5057/magento-checkout-getting-custom-attribute-value

+1

要查看要編輯的文件,請啓用模板路徑提示(系統 - >配置 - >開發者),重新加載前端將顯示特定頁面上使用的文件的名稱和路徑。除此之外,請務必清除緩存。 –

+0

謝謝,但我已經把問題整理出來了。花了很多編程和測試大聲笑 – Noob

+1

然後隨意發佈答案並將問題標記爲已解決。 :D –

回答

0

發佈此腳本這裏櫃面有人需要知道如何添加自定義屬性到您的購物車。

/** 
** This will load the product attributes. Now you can create a plugin to do this which will 
**help with performance however in my case the plugin was not working correctly. 
**/ 

    <?php $_product= Mage::getSingleton('catalog/product')->load($_item->getProductId()) ?> 



/** 
**Use javascript to add the attribute into the correct location in the shopping cart. 
** 
**/ 

<script> 

var elements = document.getElementsByClassName('item-options'), last = elements.length - 1; 

elements[last].innerHTML = "<dt>Odkaz </dt><dd>Instalační soubor</dd> <dt>No Of Devices:</dt> <dd><?php echo $_product->getResource()->getAttribute('number_of_devices')->getFrontend()->getValue($_product); ?></dd> <dt>License Period:</dt> <dd><?php echo $_product->getResource()->getAttribute('licence_period')->getFrontend()->getValue($_product); ?></dd> "; 
</script>      

PS

你會發現這個腳本被放置在位於@應用程序/設計/前端/ shopgram /默認/模板/結帳cart_new.php。

另一個建議是,如果您將此代碼放在腳本的任何位置,它將無法工作。所以,如果它不起作用,不要被嘲笑。它必須在某個不會阻止其他腳本工作的地方。我將每個項目的實際內容放在項目循環中,以便爲購物車繪製數據。