Skip to content

Instantly share code, notes, and snippets.

View reandimo's full-sized avatar
🎯
Focusing on creating things.

Renan Diaz reandimo

🎯
Focusing on creating things.
View GitHub Profile
@vividvilla
vividvilla / sale-flash.php
Last active October 18, 2018 10:10
Display Discount/Offer percentage in WooCommerce
<?php
/**
* Product loop sale flash
*
* @author Vivek R @ WPSTuffs.com
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@woogists
woogists / wc-bookings-bookings_calendar_default_to_first_available.php
Created March 9, 2018 16:17
[WooCommerce Bookings] Make calendar default to first available booking
/**
* Will make the Bookings calender default to the month with the first available booking.
*/
add_filter( 'wc_bookings_calendar_default_to_current_date', '__return_false' );
@gbot
gbot / woocommerce-login-logout-redirects.php
Last active November 16, 2021 10:11
WP: Redirect to home page for WooCommerce login and logout. #ST3
/*----------------------------------------------------------------------------*/
// redirects for login / logout
/*----------------------------------------------------------------------------*/
add_filter('woocommerce_login_redirect', 'login_redirect');
function login_redirect($redirect_to) {
return home_url();
}
@bcamarneiro
bcamarneiro / Single Value from mysqli PHP.php
Created April 22, 2014 15:14
Return single value from mysqli PHP
$name = $mysqli->query("SELECT name FROM contacts WHERE id = 5")->fetch_object()->name;
@JeroenSormani
JeroenSormani / woocommerce-dont-apply-discount-on-sale-items.php
Created February 2, 2016 12:50
Don't apply coupon codes to sale products
<?php
function custom_wc_coupon_validity( $valid, $product, $this, $values ) {
if ( $product->is_on_sale() ) {
return false;
}
return $valid;
}
@phillcoxon
phillcoxon / functions.php
Created August 2, 2017 05:29 — forked from TimBHowe/functions.php
WooCommerce - Add custom post_meta data to the order REST API response.
<?php
/**
* Hook into order API response to add custom field data.
*
* @param $order_data array
* @param $order WC_Order
* @param $fields array
* @param $server array
*
@MatthewEppelsheimer
MatthewEppelsheimer / country-shortcode.php
Last active February 27, 2023 11:44
WP Contact Form 7 shortcode with list of Countries
<?php
/*
Localizations:
- [Spanish](https://gist.github.com/MatthewEppelsheimer/1498955#gistcomment-3317461) props @chdgp
UPDATED: 2020-03-09
@lukecav
lukecav / functions.php
Created December 29, 2017 16:38
Get All orders IDs for a given product ID in WooCommerce
/**
* Get All orders IDs for a given product ID.
*
* @param integer $product_id (required)
* @param array $order_status (optional) Default is 'wc-completed'
*
* @return array
*/
function get_orders_ids_by_product_id( $product_id, $order_status = array( 'wc-completed' ) ){
global $wpdb;
@bekarice
bekarice / wc-custom-order-action-sample.php
Created October 24, 2016 06:55
Add a WooCommerce custom order action
<?php // only copy if needed
/**
* Add a custom action to order actions select box on edit order page
* Only added for paid orders that haven't fired this action yet
*
* @param array $actions order actions array to display
* @return array - updated actions
*/
function sv_wc_add_order_meta_box_action( $actions ) {
@JeroenSormani
JeroenSormani / woocommerce-custom-order-action.php
Last active September 11, 2023 17:02
Add a new action to the order action drop down
add_action('woocommerce_order_actions', 'custom_wc_order_action', 10, 1 );
function custom_wc_order_action( $actions ) {
if ( is_array( $actions ) ) {
$actions['custom_action'] = __( 'My custom action' );
}
return $actions;
}