The main issue in your code is the following part, whereby you set the attribute source to text which means (after the block/post is saved) the editor will read the value from the inner text of the div returned by your save function:
source: "text", // this shouldn't be "...
Posting the solution that worked for me in case it helps anyone in the future (Credit to Rup & WooCommerce Community Slack)
I was filtering the tax class getter on the cart side and that was doing what I needed, so I was focused on figuring out how to also filter the tax class getter on the order side. Devinsays on Community Slack recommended the ...
Your checkbox data is saved as 1 or '' if someone checked or unchecked it.
you can also verify this using var_dump($checkbox) inside custom_checkbox_field_html function
This should work.
$checkbox = get_option( 'disabletitle_text' );
$is_checked = ( $checkbox != '' && $checkbox == 1 ) ? 'checked': '';
This is because you have used the checked() function, which echoes its value, inside another echo statement. If you are adding a value to a string you need the function to return a value. This can be done by setting the third argument, $echo, to false:
echo '<lable for="zoom_activity_state"> <input type="checkbox" name="...
This is how I did it.
Getting the cart content.
$cart_content = WC()->cart->cart_contents;
Replacing the cart item with the new updated version.
$cart_content[$cart_item_key] = $cart_item;
This here made the change. Setting the updated cart content.
It doesn't appear that you can (easily) add arbitrary attributes to the <body> tag.
However, WordPress provides the function body_class() so you can add classes to the <body> tag.
If your theme uses it, you'll find something along these lines in a template file (eg. header.php):
<body <?php body_class(); ?>>
In that case, you'll be ...