Force customers to use credits
Sunshine Photo Cart allows you to give your customers credits to use to pay for orders in your client galleries. This is often used when your overall photography shoot package includes some credits towards purchase. to help ensure your customers use these credits you may want to default the checkout to pre-select the "Use credits" option. This code snippet will automatically check the box if a currently logged in customer has credits on their account:
add_action( 'wp', 'sunshine_auto_apply_credits' );
function sunshine_auto_apply_credits() {
if ( is_user_logged_in() && SPC()->customer && SPC()->customer->get_credits() ) {
$data = SPC()->session->get( 'checkout_data' );
if ( ! isset( $data['use_credits'] ) ) {
SPC()->cart->set_use_credits( true );
}
}
}
Learn how to add this custom code to your WordPress website
Still need help?
If you have not yet found your answer in the documentation articles, please contact support