Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Ищу модуль опций


Recommended Posts

добрый день

может кто подскажет, или может сделать такое

см. скрин в приложении

 

если кратко то в админке должно быть в опциях выбор товара, но должно учитываться вес и количество этого товара при покупке и выборе опции

по сути это все должно работать как комплекты товаров думаю

важно что бы учитывалось количество товаров на складе (был учет). Все остальное должно работать как обычные опции

 

может кто видел такое или делал уже?

 

SCR-20230606-rddl.png

Link to comment
Share on other sites


Posted (edited)

решение коротко

 

<input type="checkbox" name="product_id" data-product-id="40" onchange="handleCheckboxChange(this)">
<input type="checkbox" name="product_id" data-product-id="41" onchange="handleCheckboxChange(this)">
<input type="checkbox" name="product_id" data-product-id="42" onchange="handleCheckboxChange(this)">
<input type="checkbox" name="product_id" data-product-id="43" onchange="handleCheckboxChange(this)">
<button type="button" class="btn-cart" onclick="addAllToCart()"><i class="fa fa-shopping-cart"></i> Добавить все в корзину</button>

<script>
var products = [];

function handleCheckboxChange(checkbox) {
  var productId = checkbox.getAttribute('data-product-id');
  if (checkbox.checked) {
    products.push(productId);
  } else {
    var index = products.indexOf(productId);
    if (index > -1) {
      products.splice(index, 1);
    }
  }
}

function addAllToCart() {
  for (var i = 0; i < products.length; i++) {
    cart.add(products[i]);
  }
}
</script>

 

останется только передать в опцию значения из товара

 

Edited by ruslanstroj
Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.