我必须将产品返回到我在网站上创建的列表,但是当我在产品详细信息页面上该功能正常工作时,可以将产品添加到我想要的列表中,以及页面上的位置如果我只有一个列表可以直接将其发送到列表但是当我有多个已经不合适的产品时,已经没有发生的产品列表。
模态屏幕功能:
<script>
var baseRegistryLink = '';
function showRegistries(link) {
baseRegistryLink = link;
<?php if ($this->getEvents(true)->count() > 1): ?>
$('adjgiftreg_popup').show();
<?php else: ?>
<?php foreach ($this->getEvents() as $event): ?>
addToGiftRegistry(<?php echo $event->getId()?>);
<?php endforeach ?>
<?php endif ?>
return false;
}
function addToGiftRegistry(e) {
baseRegistryLink = baseRegistryLink + 'event/' + e;
alert('addTogiftRegistry');
var form = $('product_addtocart_form');
var oldFormLink = form.action;
if (form) {
alert('addTogiftRegistry-form');
form.action = baseRegistryLink;
if (!productAddToCartForm.submit()) {
alert('addTogiftRegistry-productaddTocart');
form.action = oldFormLink;
}
}
else {
document.location.href = baseRegistryLink;
}
return false;
}
</script>
<div id="adjgiftreg_popup" style='display: none; cursor: default;' onclick="event.cancelBubble = true; if(event.stopPropagation) event.stopPropagation();">
<div class='box base-mini'>
<div class='head'>
<h4><?php echo $this->helper('adjgiftreg')->__('Add to Registry') ?></h4>
<div class="btn-close">
<a href="#" onclick="event.cancelBubble = true; if(event.stopPropagation) event.stopPropagation(); $('adjgiftreg_popup').hide(); return false;"><img
src="<?php echo $this->getSkinUrl('images/btn_window_close.gif') ?>"
alt="<?php echo $this->__('Close') ?>"/></a>
</div>
</div>
<div class='content'>
<p>
<?php //sends to the function ?>
<?php foreach ($this->getEvents() as $event): ?>
<a href="#"
onclick="event.cancelBubble = true; if(event.stopPropagation) event.stopPropagation(); return addToGiftRegistry(<?php echo $event->getId() ?>)"><?php echo $this->htmlEscape($event->getFullTitle()) ?></a>
<br/>
<?php endforeach ?>
</p>
</div>
</div>
</div>
na pagina que funcionaocódigoestaassim:
<a href="<?php echo $_registryUrl ?>" class="adjgiftreg_add_to" onclick="return showRegistries(this.href)"> List Present</a>
na pagina quenãofuncionaocódigoestaassim:
<a href="<?php echo $_registryUrl ?>" class="adjgiftreg_add_to" onclick="event.cancelBubble = true;
if(event.stopPropagation) event.stopPropagation(); return showRegistries(this.href);">List Present</a>
这两个页面(详细的产品和产品选项列表)将函数调用放在表单中:
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"
<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
我认为我的错误涉及到,然后问题发生在这个abeixo放入详细的产品屏幕(在我的情况下和view.phtml文件中)以及产品在网格视图中时的功能列出发送的参数未到达功能,有人上升告诉我该怎么做
代码:
form.action = baseRegistryLink;
if (!productAddToCartForm.submit()) {
alert('addTogiftRegistry-productaddTocart');
form.action = oldFormLink;
}
答案 0 :(得分:0)
不再,因为我可以在产品的页面上插入以下javascript代码:
<script type="text/javascript">
//<![CDATA[
var productAddToCartForm = new VarienForm('product_addtocart_form');
productAddToCartForm.submit = function (button, url) {
if (this.validator.validate()) {
var form = this.form;
var oldUrl = form.action;
if (url) {
form.action = url;
}
var e = null;
try {
this.form.submit();
} catch (e) {
}
this.form.action = oldUrl;
if (e) {
throw e;
}
if (button && button != 'undefined') {
button.disabled = true;
}
}
}.bind(productAddToCartForm);
productAddToCartForm.submitLight = function (button, url) {
if (this.validator) {
var nv = Validation.methods;
delete Validation.methods['required-entry'];
delete Validation.methods['validate-one-required'];
delete Validation.methods['validate-one-required-by-name'];
// Remove custom datetime validators
for (var methodName in Validation.methods) {
if (methodName.match(/^validate-datetime-.*/i)) {
delete Validation.methods[methodName];
}
}
if (this.validator.validate()) {
if (url) {
this.form.action = url;
}
this.form.submit();
}
Object.extend(Validation.methods, nv);
}
}.bind(productAddToCartForm);
//]]>
</script>