we are having marketplace [multi vendor] site. so in each seller/vendor account we are displaying name, sku, price .... etc. so that sellers/vendors can edit the product information and save . so it will reflect in backend.... we are using following code to display "Price" and "special price". if we click edit button on "special Price field" , its allowing to edit "Price Field". Please help me what code i need to add to fix this . I am trying following code :
Php code for Price
<span id="valueprice_<?php echo $products->getId(); ?>">
<?php echo $products->getPrice(); ?></span>
<input type = "text" id = "price_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" "name = "price" value = "<?php echo $products->getPrice(); ?>" />
<span class="label wk_action" id="edit_link_<?php echo $products->getId(); ?>">
<img onclick="showFieldPrice('<?php echo $products->getId(); ?>'); return false;" src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
</span>
<p id="updatedprice_<?php echo $products->getId(); ?>" style = "display:none;color:red;">Updated</p>
<br/>
<button id="price_update_button_<?php echo $products->getId(); ?>" class="button wk_mp_btn1" onclick="updateFieldPrice('<?php echo $products->getId(); ?>'); return false;" style="display:none" >
<span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
</button>
<button id="price_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetPrice('<?php echo $products->getId(); ?>'); return false;" style="display:none" >
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>
</span>
php code for special price
<span id="valueprice_<?php echo $products->getId(); ?>"><?php echo $products->getSpecialPrice(); ?></span>
<input type = "text" id = "price_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" "name = "price" value = "<?php echo $products->getSpecialPrice(); ?>" style = "display:none"/>
<span class="label wk_action" id="edit_link_<?php echo $products->getId(); ?>">
<img onclick="showFieldPrice('<?php echo $products->getId(); ?>'); return false;" src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
</span>
<p id="updatedprice_<?php echo $products->getId(); ?>" style = "display:none;color:red;">Updated</p>
<br/>
<button id="price_update_button_<?php echo $products->getId(); ?>" class="button wk_mp_btn1" onclick="updateFieldPrice('<?php echo $products->getId(); ?>'); return false;" style="display:none" >
<span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
</button>
<button id="price_reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideResetPrice('<?php echo $products->getId(); ?>'); return false;" style="display:none" >
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>
Javascript and ajax code for price
<script>
function updateFieldPrice(product_id)
{
var priceId = '#price_'+ product_id;
var valueId = '#valueprice_'+ product_id;
var updatedqty = '#updatedprice_'+ product_id;
var editLink = "#price_edit_link_"+ product_id;
var updateButton = "#price_update_button_"+ product_id;
var resetButton = "#price_reset_button"+ product_id;
var url ='<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateFieldPrice/')?>';
$wk_jq(priceId).toggle()
$wk_jq(editLink).hide();
$wk_jq(updateButton).show();
$wk_jq(resetButton).show();
$price = $wk_jq(priceId).val();
jQuery(valueId).html($price);
hideReset(product_id);
new Ajax.Request(url, {
method: 'post',
parameters: {id: product_id, price: $price},
onComplete: function (transport) {
//alert(transport.responseText);
jQuery(updatedqty).show().delay(2000).fadeOut();
$updateButton.prop('disabled', false);
$wk_jq(priceId).setValue($price);
}
});
}
function updateAllFields(product_id) {
updateFieldPrice(product_id);
updateField(product_id);
}
</script>
Javascript and ajax code for special price
function updateFieldSpecialPrice(product_id)
{
var priceId = '#price_'+ product_id;
var valueId = '#valueprice_'+ product_id;
var updatedqty = '#updatedprice_'+ product_id;
var editLink = "#price_edit_link_"+ product_id;
var updateButton = "#price_update_button_"+ product_id;
var resetButton = "#price_reset_button"+ product_id;
var url ='<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateFieldPrice/')?>';
$wk_jq(priceId).toggle()
$wk_jq(editLink).hide();
$wk_jq(updateButton).show();
$wk_jq(resetButton).show();
$price = $wk_jq(priceId).val();
jQuery(valueId).html($price);
hideReset(product_id);
new Ajax.Request(url, {
method: 'post',
parameters: {id: product_id, price: $price},
onComplete: function (transport) {
//alert(transport.responseText);
jQuery(updatedqty).show().delay(2000).fadeOut();
$updateButton.prop('disabled', false);
$wk_jq(priceId).setValue($price);
}
});
}