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 | |
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 | |
/** | |
* 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 | |
/** | |
* 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 | |
/* | |
* Usage de la fonction msk_send_mail | |
*/ | |
$destinataire = 'pierre@mosaika.fr'; | |
$data = array( | |
'prenom' => 'Bruce', |
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
/** | |
* Remove WC image sizes, useless | |
*/ | |
function msk_wc_remove_image_sizes() { | |
remove_image_size('shop_thumbnail'); | |
remove_image_size('shop_catalog'); | |
remove_image_size('shop_single'); | |
} | |
add_action('init', 'msk_wc_remove_image_sizes', 90); |
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 | |
/** | |
* Single Product Sale Flash | |
* | |
* @author WooThemes | |
* @package WooCommerce/Templates | |
* @version 1.6.4 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { |
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
/************************************************************************************************* | |
* On enregistre les valeurs de LOVES & HATES lorsqu'on enregistre un post | |
*************************************************************************************************/ | |
function msk_save_loves_hates_product_fields($product_id, $post, $update) { | |
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; | |
if ($post->post_type == 'product') { | |
if (isset($_POST['loves'])) { | |
$loves = (int)$_POST['loves']; | |
update_post_meta($product_id, 'loves', $loves); |
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
/************************************************************************************************* | |
* On ajoute 2 champs (post meta ou custom field) aux produits WC dans l'onglet "Avancé" | |
*************************************************************************************************/ | |
function msk_add_loves_hates_fields_to_product() { | |
woocommerce_wp_text_input( | |
array( | |
'id' => 'loves', | |
'data_type' => 'decimal', | |
'label' => __('Loves', 'msk'), | |
'placeholder' => __('Amount of love', 'msk'), |
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
/************************************************************************************************* | |
* On ajoute des champs de test pour se repérer, dans l'onglet Général | |
* Résultat visuel : http://img.saika.li/bWk6 | |
*************************************************************************************************/ | |
function msk_add_test_field_data() { | |
echo '<div style="background:#f8fbca; padding:1em;">'; | |
echo '<h4>Testons les différents types de champs</h4>'; | |
// Champ de type text |