1

in details product page i use easy tabs with related products, now i want when user check checkbox product in tabs change and total price in details page

http://prntscr.com/49e1by

how i can do this?

Thanks

1

You could try using Javascript

  1. Store the base product price in a javascript variable or hidden field

  2. Create a checkbox onchange event that sum the base price + current selected using element selector to get the related price (jQuery).

See https://stackoverflow.com/questions/12647770/magento-display-price-dynamically-based-on-quantity-tiered-pricing

var item_base_price = 0
jQuery( document ).ready(function() {
  //get base price on page load
  // to do - convert string to number
   item_base_price = jQuery(".topprice_con .price").text()

   // assuming options-18-list will not change or use a different selector
   jQuery('#options-18-list :checkbox').click(function() {
      updateprice();
   });

});


function updateprice(){
   jQuery(' [put selector here] input[type=checkbox]').each(function () {
     if(this.checked){
        //to do - convert from string to float
        price = $( "li.item-a" ).parent().find( put relate price selector here ).text()
        item_base_price = item_base_price + price
     });

     //update display price
     //format item_base_price before displaing
    jQuery(".topprice_con .price").html(item_base_price)
}
11
  • ok, i have Related products, i have price for replated product, how i can via JS when i check checkbox with current product display base price + price related product, i think this can do in product.js, but maybe have easy way?
    – John Genry
    Aug 4 '14 at 15:43
  • Are you using jQuery JS library? Take a look @ learn.jquery.com/using-jquery-core/selecting-elements and stackoverflow.com/questions/7031226/… Aug 4 '14 at 15:48
  • i think bad idea use JS library, maybe have solution how price related product add base price product, now my theme overloaded JS and etc...((
    – John Genry
    Aug 4 '14 at 15:57
  • jQuery is easier to learn and most magento installment already include it by some third party extension, but if you think it's a bad idea you can use prototype (which is included in core magento) or pure javascript Aug 4 '14 at 16:05
  • product.js possible change for my solution?
    – John Genry
    Aug 4 '14 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.