现在我已经阅读了十几个线程甚至十几个不同的网页,它们都提出了类似的问题。但是,这些答复对我不起作用。我尝试了所有这些。另请注意,我无法对问题发表评论,因此无法对此线程发表评论。从我在 magento 结帐中可以看出的内容尽可能详细与 SHOPGRAM 有关?这是我目前的结账车。我有两个名为 license_period 的自定义属性,另一个名为 number_of_devices。
我需要在结帐购物车中添加这两个字段。需要注意的一件事是,在我所做的测试之外,似乎位于@/app/design/frontend/shopgram/default/template/checkout 的文件 cart_new.phtml 控制布局。这个脚本我已经尝试过编辑我已经尝试了很多但是我所做的任何更改甚至都没有出现。即使我编辑 default.phtml @/app/design/frontend/shopgram/default/template/checkout/cart/item 它也没有做任何更改我什至删除了这些目录中的大部分文件并且它不会改变内容。只有 cart_new.phtml 控制内容。
现在我不太了解 magento,所以我可能会误会。但是,当我确实尝试了很多不同的查询时,大多数查询什么都不做。其中一些导致表格消失。
以下只是我尝试过的 100 个链接中的两个。但是我只能发布两个链接。
Display Magento Custom Option Values in Shoping Cart
https://magento.stackexchange.com/questions/5057/magento-checkout-getting-custom-attribute-value
最佳答案
在此处发布此脚本,以防有人需要知道如何将自定义属性添加到您的购物车中。
/**
** 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>
附言
您会发现此脚本位于@app/design/frontend/shopgram/default/template/checkout 中的cart_new.php 中。
另一条建议是,如果您将此代码放在脚本中的任何位置,它将无法运行。因此,如果它不起作用,请不要感到沮丧。它必须去某个地方,它不会阻止其他脚本工作。我将我的放在每个项目的实际中,因为项目循环在其中绘制购物车的数据。
关于java - Magento Shopgram 结帐页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33501663/