You may have noticed that on January 6, 2023 the so-called “button amendment” came into effect. Besides the useful things it regulates – such as rules for displaying discounts or showing reviews only from real customers – there are also a few amusing ones. You can find a nice article about the amendment on the website of one of the leading WooCommerce plugin makers, Wpify. You can also download a plugin from them that helps you apply the rules.
Do you need a plugin?
But if you have a smaller e-shop and don’t work with discounts and reviews, you may well get by without a plugin. A few of those amusing rules can simply be applied using short snippets that you insert, for example, into the functions.php file of your child theme.
Prompt to check the cart
Yes, you’re supposed to prompt the customer to double-check their cart. We achieve this easily with this code.
add_action('woocommerce_review_order_before_submit', 'lh_cart_control_notice');
function lh_cart_control_notice(){
echo '<p>Před odesláním objednávky si prosím pečlivě překontrolujte košík</p>';
}
The prompt appears at checkout before the button that submits the order.
Changing the order button wording
If you’ve come across the clunky-sounding phrase Order with obligation to pay on some e-shop, then that e-shop has probably already dealt with the amendment. The button should make it clear that if the customer clicks it, a purchase contract is concluded. The button wording can be changed easily (and it doesn’t even have to be that clunky):
add_filter( 'woocommerce_order_button_text', 'lh_order_button_text' );
function lh_order_button_text( $button_text ) {
return 'Potvrďte nákup';
}
Terms and conditions in the e-mail
When an order is placed, the customer should receive the current wording (at the time of ordering) of the terms and conditions in the e-mail. So it’s ideal to send the terms and conditions as a PDF attachment. Convert your terms and conditions to PDF (Word, for example, can do it). The following code sends the terms and conditions for the order statuses On hold (customer_on_hold_order), Processing (customer_processing_order) and Completed (customer_completed_order). Of course you don’t have to send them for all statuses… it depends on how you work with statuses.
add_filter('woocommerce_email_attachments', 'lh_terms_attachment_to_email', 10, 4);
function lh_terms_attachment_to_email($attachments, $email_id, $order, $email) {
$email_ids = array('customer_on_hold_order', 'customer_processing_order', 'customer_completed_order');
if (in_array($email_id, $email_ids)) {
$upload_dir = wp_upload_dir();
$attachments[] = $upload_dir['basedir']."/terms/obchodni_podminky.pdf";
}
return $attachments;
}
Upload the terms and conditions via FTP to a folder on the server. The example above assumes the terms and conditions are in the terms folder inside the uploads folder. By default /wp-content/uploads/terms/.