I am looking to give guest customers the option to create an account when paying for their order when an invoice is emailed to them.
Our current process is that our sales team will create a guest order in WooCommerce and send an invoice to the customers email. The customer will review the order and pay.
I am trying to add the "Create an account?" checkbox to the /checkout/order-pay/ page when the user is not logged in.
My code:
<?php if (!is_user_logged_in()) : ?>
<div class="woocommerce-account-fields">
<p class="form-row form-row-wide create-account">
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
<input class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" id="createaccount" <?php checked((true === $checkout->get_value('createaccount') || (true === apply_filters('woocommerce_create_account_default_checked', false))), true); ?> type="checkbox" name="createaccount" value="1" /> <span><?php esc_html_e('Create an account?', 'woocommerce'); ?></span>
</label>
</p>
</div>
<?php endif; ?>
This is giving me an error of "Fatal error: Uncaught Error: Call to a member function get_value() on null".
If I remove
<?php checked((true === $checkout->get_value('createaccount') || (true === apply_filters('woocommerce_create_account_default_checked', false))), true); ?>
then I am able to see the create an account check box, but it does not create an account when checked.
Is there something that I am missing?