i have created some custom woocommerce fields and i’m changing the value of a checkbox using javascript based on some criteria.
var setborder = document.getElementById("setborder");
setborder.disabled = true;
setborder.checked = true;
in the frontend it works perfect, however i’m passing the value of this checkbox in the cart using:
add_filter( 'woocommerce_cart_item_name', 'cart_item_name', 10, 3 );
function cart_item_name( $name, $cart_item, $cart_item_key ) {
if ($cart_item['setborder'] == 'on') {
$setborder = __('with border','conditional-single-product');
}
return $setborder;
}
When the value is set to checked through Javascript, the if condition is NOT met.
of course if a user clicks the button the if condition is met.
it doesn’t make sense to mee.
do you have any clues?
2
Answers
For some really wierd reason the issue is resolved if i remove
i found a workaround by adding
Some insight on this would be really helpful.
your question is not clear enough and your code snippets are somewhat confusing. However, you should make changes to the checkbox attributes (in this case the value attribute of the checkbox) using keypress or click event of the your search criteria element then update your display to visualize behavior. Then pass your value to PHP via ajax call