使用自定义属性填充 magento 订单表单
我创建了一个属性集,并添加了一个 shirtsize
属性,其中包含“小”、“中”和“大”选项。
在 template/catalog/product/view.phtml 上,我正在填充一个下拉列表,
<?php
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'shirtsize');
foreach ($attribute->getSource()->getAllOptions(true, true) as $instance) {
echo '<option>' . $instance['label'] . '</option>';
}
?>
现在,我需要获取此数据以使用 product_addtocart_form
表单发布,以便我可以保存他们的选择和订单在结帐页面/收据上访问它。
我怎样才能做到这一点?
I created an attribute set and added a shirtsize
attribute with the options Small, Medium, and Large.
On template/catalog/product/view.phtml, I'm populating a drop down with
<?php
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'shirtsize');
foreach ($attribute->getSource()->getAllOptions(true, true) as $instance) {
echo '<option>' . $instance['label'] . '</option>';
}
?>
Now, I need to get this data to post with the product_addtocart_form
form so I can save their selection with the order and access it on the checkout page / receipt.
How can I accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎正在尝试做的是创建一个可配置的产品。为此,并使客户能够在目录中选择正确的尺寸,需要添加“可配置产品”类型的项目,并在其下方添加“简单产品”类型的项目(每种尺寸一个)。当您使可配置产品在目录中可见时,Magento 将自动提供尺寸选项并管理购买每种尺寸产品的技术方面。
如果您不想生产这么多产品,那么您会更多地查看产品上的产品选项,该选项不会作为属性添加。相反,在编辑表单中将其添加到您的产品中,Magento 将再次管理此选项的选择/存储。
希望有帮助!
谢谢,
乔
What you appear to be trying to do is to create a configurable product. To do this, and have the customer able to select the correct size in the catalog, is to add a "Configurable Product" typed item, and add the "Simple Product" type items underneath it (one for each size). When you make the configurable product viewable in the catalog, Magento will automatically provide the sizing options and manage the technical aspects of buying the products in each size.
If you don't want to make so many products, you're looking more at a Product Option on a product, which is not added as an attribute. Instead, add it to your product in the edit form, and again Magento will manage selection / storing of this option.
Hope that helps!
Thanks,
Joe