Magento 自定义选项 - 选中每个第一个单选按钮
我们有一个 Magento 商店,其中一些产品具有单选按钮等自定义选项。默认情况下,每个非必需选项都会选中第一个按钮,但不会选中必需的按钮。我怎样才能检查它们?
我已经安装了扩展“依赖自定义选项”(图库)。这使我可以选择设置默认情况下应检查哪个自定义选项,但这不会将价格更新为正确的值。
感谢您的帮助
We have a Magento Shop with some products that have custom options as radio buttons. Every non required option has the first button checked by default but not the required ones. How can I make them checked?
I've allready installed the extension Dependent Custom Options (gallery). That gives me the option to set which custom option should be checked by default but that doesn't update the price to the right value.
Thanks for evey help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个解决方案可能不是最适合您的,但我也遇到了同样的问题,并且刚刚修复了它。
首先,我必须使用复杂的方法在 Magento 中正确安装 jQuery。我认为部分问题来自于 Spriptaculous Effects 文件在最新的 Magento 版本中已经过时。所以我访问了网站 www.script.aculo.us 并下载了最新版本。然后我取出effects.js 文件并用它来覆盖以下位置的effects.js:
然后我从 jQuery 站点下载了 jQuery,并在以下位置创建了一个名为 jquery 的文件夹:
并将 jquery 文件转储到那里。
然后我打开文件:
并找到了一个如下所示的行列表:
我复制了其中一行并将路径替换为 jquery 文件的路径,如下所示。
现在 jQuery 将包含在您的所有页面中。
重要的!您必须在 noConflict() 模式下运行 jQuery。这就是 JS 的样子(对我来说),它可以使用自定义选项选择任何页面上的第一个单选按钮。
我将该文件保存到 jquery 文件夹中,并以与链接到 jQ 库相同的方式链接到它。
刷新我的缓存,瞧!
我希望这有帮助!
This solution may not be the best for you, but I had this same problem, and just fixed it.
First I had to use a convoluted method for installing jQuery correctly in Magento. Part of the problem, I believe comes from the Spriptaculous Effects file being outdated with the latest Magento build. So I went to the site www.script.aculo.us and downloaded the latest version. I then pulled out the effects.js file and used it to overwrite the effects.js in:
Then I downloaded jQuery from the jQuery site and made a folder called jquery in:
And dumped the jquery file in there.
Then I opened the file:
And found a list of lines that look like this:
I copied one of these and replaced the path to that of the jquery file like this.
Now jQuery will be included in all your pages.
Important! You have to run jQuery in noConflict() mode. So this is what the JS looks like that (for me) worked to select the first radio button on any page with custom options.
I saved that file into my jquery folder and linked to it the same way I linked to the jQ library.
Flushed my cache, and voila!
I hope this helps!
正如 Gordon 所说,您可以使用 jQuery,但要更新价格,您需要在检查时运行 opConfig.reloadPrice() 函数。所以代码将是这样的:
You can use jQuery, as Gordon says, but to update the price you need to run opConfig.reloadPrice() function when check. So the code will be something like this:
有一个名为
optionsConfig.reloadPrice()
的 JavaScript 函数,在调用时会根据选项更新价格。您可能需要在dom:loaded
事件期间触发此操作。There is a javascript function named something like
optionsConfig.reloadPrice()
which, when called, updates the price according to options. You probably need to have this triggered during thedom:loaded
event.转到 app\code\core\Mage\Catalog\Block\Product\View\Options\Type\select.php
您可以在此处找到您的自定义选项标题并使用您的标题设置 if 条件。
例如,我的自定义选项标题是价格:
if($this->htmlEscape($_option->getTitle()=='Price'))
Go to app\code\core\Mage\Catalog\Block\Product\View\Options\Type\select.php
You can find here your custom option title and set if condition with your title.
For example, my custom option title is price:
if($this->htmlEscape($_option->getTitle()=='Price'))