Skip to content

Instantly share code, notes, and snippets.

View Yame-'s full-sized avatar

Yannick Van Meerbeeck Yame-

View GitHub Profile
@Yame-
Yame- / wordpress-plugin-composer-file.json
Created August 1, 2018 13:15
Default WordPress Plugin composer file
{
"name": "demo/demo",
"description": "Demo plugin",
"type": "wordpress-plugin",
"require": {
"composer/installers": "v1.0.6"
},
"authors": [
{
"name": "iValue",
@Yame-
Yame- / add_bcc_to_certain_emails.php
Created June 7, 2018 19:20 — forked from jessepearson/add_bcc_to_certain_emails.php
Add a BCC to certain defined emails sent from WooCommerce
<?php // only copy this line if needed
/**
* Function adds a BCC header to emails that match our array
*
* @param string $headers The default headers being used
* @param string $object The email type/object that is being processed
*/
function add_bcc_to_certain_emails( $headers, $object ) {
@Yame-
Yame- / functions.php
Created July 20, 2017 10:23
When WordPress Admin Bar has disappeared...
<?php
// in your functions.php
function admin_bar(){
if(is_user_logged_in()){
add_filter( 'show_admin_bar', '__return_true' , 1000 );
}
}
add_action('init', 'admin_bar' );
@Yame-
Yame- / woocommerce-eu-vat-vies-offline-fix.php
Last active January 21, 2017 08:54
WooCommerce EU VAT plugin relies on the Europa VIES service. But when it's down your customers get an annoying error and the order cannot be completed. This snippet provides a fix.
<?pp
/*
!!! Just a quick warning, if WooCommerce updates its plugin these changes will be gone !!!
1) Find class-wc-eu-vat-number.php, it's located under wp-contents/plugins/woocommerce-eu-vat-number/includes
2) Skim trough until you find line 160
3) Do the following
*/
@Yame-
Yame- / mautic-builder-active.js
Last active August 15, 2016 12:20
Checking if a Mautic theme (Landing page or E-mail) is being edited through the Builder.
// Checking if we are editting in the Mautic Builder.
if( $('.builder-active', window.parent.document).length ) {
// Do stuff here
}
<?php
function send_sms_order_not_complete($orderid){
// Our order
$order = new WC_Order($orderid);
// When after 10min our order hasn't got the completed status...
if( $order->get_status() != 'completed' ){
// We send out a message through either a notification or SMS api.
}
<?php
function catch_new_order($orderid){
// Check for new order
// Set a scheduled event after 10min to check if order has been succesfully proccesed.
// If not, send SMS with orderID and name of client.
// 1: We are setting the time of the event after 10 minutes.
// 2: We provide an action to be called if the event is run.
// 3: We provide additional parameters to got with the action. In this case our order id.
@Yame-
Yame- / woocommerce-global-discount.php
Last active August 29, 2015 14:23
Automatically add a coupon / global discount to a WooCommerce cart.
function global_discount(){
global $woocommerce;
$coupon = 'your-coupon-code-name';
// We'll add the coupon code the first time.
// This way users can remove the coupon code
// when they have a bigger discount coupon.
if( 0 == $woocommerce->cart->cart_contents_count ){
// This coupon can be managed from the coupon dashboard
@Yame-
Yame- / woocommerce-product-wpcf7.php
Created June 16, 2015 21:53
Add a WooCommerce product with Contact Form 7
<?php
/* Capture CF7 data */
add_action( 'wpcf7_mail_sent', 'wpcf7_capture_data' );
function wpcf7_capture_data( $contact_form ) {
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
@Yame-
Yame- / add-woocommerce-product.php
Last active December 6, 2022 17:14
Adding a WooCommerce product programmatically.
<?php
$args = array(
'post_author' => 1,
'post_content' => '',
'post_status' => "draft", // (Draft | Pending | Publish)
'post_title' => '',
'post_parent' => '',
'post_type' => "product"
);