我们有市场多供应商/卖家网站。我们为卖方提供了通过前端更新产品信息的选项。
卖家A在前端上传了产品A [quantity = 20]
如果卖家B有相同的产品,他会将相同的产品分配到他的帐户[quantity = 5]
此处更新卖家B,表示已分配卖家数量不起作用。
我使用以下代码编辑分配数量,但不保存在数据库中。
<span class="label qty" id="valueqty_<?php echo $assinproducts->getId(); ?>">
<?php echo intval($assinproducts['qty']); ?>
</span>
<input type = "text" id = "qty_<?php echo $assinproducts->getId(); ?>" onkeydown="validateNumbers(event)" name="stock" value="<?php echo intval($assinproducts['qty']); ?>" style="display:none;"/>
<span class="label wk_action" id="edit_link_<?php echo $assinproducts->getId(); ?>">
<img onclick="showField('<?php echo $assinproducts->getId(); ?>'); return false;" src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
</span>
<p id="updatedqty_<?php echo $assinproducts->getId(); ?>" style = "display:none;color:red;">Updated</p><br/>
<button id="update_button_<?php echo $assinproducts->getId(); ?>" class="button wk_mp_btn1" onclick="updateField('<?php echo $assinproducts->getId(); ?>',<?php echo intval($assinproducts['qty']); ?>); return false;" style="display:none" >
<span>
<span style="font-size:12px;"><?php echo $helper->__('Update') ?></span>
</span>
</button>
<button id="reset_button_<?php echo $assinproducts->getId(); ?>" type="reset" class="cancel" onclick="hideReset('<?php echo $assinproducts->getId(); ?>'); return false;" style="display:none"></button>
脚本
function hideReset(product_id)
{
var qtyId='#qty_'+ product_id;
var editLink="#edit_link_"+ product_id;
var updateButton="#update_button_"+ product_id;
var resetButton="#reset_button_"+ product_id;
$wk_jq(qtyId).hide();
$wk_jq(editLink).show();
$wk_jq(updateButton).hide();
$wk_jq(resetButton).hide();
}
function showField(product_id)
{
var qtyId = '#qty_'+ product_id;
var editLink = "#edit_link_"+ product_id;
var updateButton = "#update_button_"+ product_id;
var resetButton = "#reset_button_"+ product_id;
$wk_jq(qtyId).show();
$wk_jq(editLink).hide();
$wk_jq(updateButton).show();
$wk_jq(updateButton).prop('disabled', false);//just in case
$wk_jq(resetButton).show();
return false;
}
function updateField(product_id,assignqty)
{
var qtyId = '#qty_'+ product_id;
var valueId = '#valueqty_'+ product_id;
var updatedqty = '#updatedqty_'+ product_id;
var editLink = "#edit_link_"+ product_id;
var updateButton = "#update_button_"+ product_id;
var resetButton = "#reset_button"+ product_id;
var url = '<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateField/')?>';
$wk_jq(qtyId).toggle();
$wk_jq(editLink).hide();
$wk_jq(updateButton).show();
$wk_jq(resetButton).show();
$qty = $wk_jq(qtyId).val();
jQuery(valueId).html($qty);
hideReset(product_id);
var tmpQty = assignqty+parseInt($qty) ;
new Ajax.Request(url, {
method: 'post',
parameters: {id: product_id, qty: tmpQty},
onComplete: function (transport) {
jQuery(priceId).val($price);
jQuery(updatedqty).show().delay(2000).fadeOut();
$updateButton.prop('disabled', false);
}
});
}