This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Si inexistante, on créée la table SQL "commissions" après l'activation du thème | |
*/ | |
global $wpdb; | |
$charset_collate = $wpdb->get_charset_collate(); | |
$commissions_table_name = $wpdb->prefix . 'commissions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* On ajoute un onglet "Parrainage" dans le back-office d'un produit WooCommerce | |
*/ | |
function msk_add_commission_product_tab($tabs) { | |
$tabs = array_insert_after('general', $tabs, 'commission', array( | |
'label' => __('Parrainage', 'mosaika'), | |
'target' => 'commission_product_data', | |
'class' => array() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Shortcode pour afficher le formulaire pour proposer un produit | |
*/ | |
add_shortcode('msk_formulaire_proposer_produit', 'msk_shortcode_product_submission'); | |
function msk_shortcode_product_submission($atts) { | |
// On ajoute un champ caché pour savoir si c'est un utilisateur lambda ou l'admin qui remplit le formulaire | |
$is_admin_hidden_field = (is_user_logged_in() && current_user_can('manage_options')) ? 'on' : 'off'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function msk_save_commissions_gains_from_order_items($order_id, $old_status, $new_status) { | |
global $wpdb; | |
$commissions_table_name = $wpdb->prefix . 'commissions'; | |
// On récupère la commande concernée et les valeurs importantes | |
$order = wc_get_order($order_id); | |
$order_items = $order->get_items(); | |
$order_customer_id = $order->get_customer_id(); | |
$type = 'gain'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function msk_display_use_points_checkbox() { | |
// On récupère le nombre de points de l'utilisateur | |
$user_points = msk_get_customer_commission_balance(get_current_user_id())['balance']; | |
// Si l'acheteur a des points... | |
if ($user_points > 0) { | |
if (isset($_POST['post_data'])) { | |
parse_str($_POST['post_data'], $form_data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Afficher la description d'un code promo | |
* Illustré sur http://media.mosaika.fr/mcbj | |
*/ | |
function msk_display_coupon_description($value, $coupon) { | |
$new_value = sprintf('%1$s <small class="coupon-description">%2$s</small>', $value, $coupon->get_description()); | |
return $new_value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Ajouter un champ "Code-barre" aux produits WooCommerce | |
* Ce nouveau champ s'affichera, ici, dans l'onglet "Inventaire" dans le back-office d'un produit WooCommerce | |
*/ | |
function msk_add_barcode_product_fields() { ?> | |
<div class="options_group"> | |
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Séparation des décimales des prix WooCommerce : remplacer la virgule par un point | |
*/ | |
function msk_wc_price_args($args) { | |
$args['decimal_separator'] = ','; | |
return $args; | |
} | |
add_filter('wc_price_args', 'msk_wc_price_args'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Ajouter un onglet 'Nouvel onglet' dans les onglets WooCommerce sur la page produit | |
* Tutoriel complet : https://mosaika.fr/woocommerce-ajouter-onglet-page-produit/ | |
*/ | |
function msk_woocommerce_new_tab($tabs) { | |
global $product; | |
$tabs['nouvel_onglet'] = array( |