I am trying to have a piece of code that displays data from table, saves the data inside a checkbox which, if selected, posts it forward. But I am stuck on a problem with trying to select a different amount of quantity than the original, it will always select the maximum amount due to the checkbox being set to stone when the page is loaded, can I update the checkbox values in some way? The checkbox code looks like this:
$order = wc_get_order( $ordernumber );
foreach ($order->get_items() as $item ){
$unitprice = $item->get_total() / $item->get_quantity();
echo "<input type='checkbox' name='productinfo[]' value='" . " " . $item->get_name() . " , " . $item->get_quantity() . " units" . " | " . $item->get_total() ."'>";
and this displays a choice of amount for quantities of 2 and more:
if($item->get_quantity() > 1) {
echo "Amount: " . "<input type='number' name='numberqty' value='" . $item->get_quantity() . "'max='" .$item->get_quantity() . "' min='1' > " . "<br/>";
}
this is how it's displayed on the site itself 
After selecting the desired checkboxes the user would press a button that would direct them to the next site with the selected products from the earlier page
if 2 is selected by the user here I want the number on the next page be 2, and if 1 is selected then it would be 1. But right now even if 2 is selected, it will display 3 on the next page instead of the desired 2.
is there a way to make this work by updating the given amount into the checkbox value that was set before?
from How to update checkbox values using user input
No comments:
Post a Comment