Skip to content

Instantly share code, notes, and snippets.

View Spirecool's full-sized avatar

Jérôme OLLIVIER Spirecool

View GitHub Profile
<?php
add_action( 'woocommerce_before_checkout_form', 'skyverge_add_checkout_success', 9 );
function skyverge_add_checkout_success() {
wc_print_notice( __( 'Voici un message important!', 'woocommerce' ), 'success' );
}
<?php
add_action( 'woocommerce_before_checkout_form', 'skyverge_add_checkout_notice', 11 );
function skyverge_add_checkout_notice() {
wc_print_notice( __( 'A notice message instead.', 'woocommerce' ), 'notice' );
}
<?php
add_action( 'woocommerce_review_order_after_submit', 'popcorn_privacy_message_below_checkout_button' );
function popcorn_privacy_message_below_checkout_button() {
echo '<p><small>Tu peux ajouter du texte ici</small></p>';
}
<?php
add_filter( 'woocommerce_checkout_fields', 'popcorn_remove_fields', 9999 );
function popcorn_remove_fields( $woo_checkout_fields_array ) {
// she wanted me to leave these fields in checkout
// unset( $woo_checkout_fields_array['billing']['billing_first_name'] );
// unset( $woo_checkout_fields_array['billing']['billing_last_name'] );
// unset( $woo_checkout_fields_array['billing']['billing_phone'] );
<?php
add_filter( 'woocommerce_checkout_fields' , 'popcorn_not_required_fields', 9999 );
function popcorn_not_required_fields( $f ) {
unset( $f['billing']['billing_last_name']['required'] ); // that's it
unset( $f['billing']['billing_phone']['requiredd'] );
// the same way you can make any field required, example:
<?php
add_filter( 'woocommerce_checkout_fields' , 'popcorn_labels_placeholders', 9999 );
function popcorn_labels_placeholders( $f ) {
// first name can be changed with woocommerce_default_address_fields as well
$f['billing']['billing_first_name']['label'] = 'Quel est ton nom de famille?';
$f['order']['order_comments']['placeholder'] = 'Ton surnom?';
<?php
// add fields
add_action( 'woocommerce_after_checkout_billing_form', 'misha_select_field' );
add_action( 'woocommerce_after_order_notes', 'misha_subscribe_checkbox' );
// save fields to order meta
add_action( 'woocommerce_checkout_update_order_meta', 'misha_save_what_we_added' );
// select
<?php
add_filter( 'woocommerce_billing_fields', 'bbloomer_move_checkout_email_field' );
function bbloomer_move_checkout_email_field( $address_fields ) {
$address_fields['billing_email']['priority'] = 1;
return $address_fields;
}
<?php
// 1. Hide default notes
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
// 2. Create new billing field
add_filter( 'woocommerce_checkout_fields' , 'bbloomer_custom_order_notes' );
<?php
add_filter( 'woocommerce_default_address_fields' , 'popcorn_rename_city_field', 9999 );
function popcorn_rename_city_field( $fields ) {
$fields['city']['label'] = 'Ta ville'; //ici tu mets le champs que tu souhaites modifier, entre les crochets
return $fields;
}