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 | |
$args = array( | |
'label' => '', // Text in Label | |
'class' => '', | |
'style' => '', | |
'wrapper_class' => '', | |
'value' => '', // if empty, retrieved from post meta where id is the meta_key | |
'id' => '', // required | |
'name' => '', //name will set from id if empty |
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 st_popular_posts_shortcode( $atts, $content ) { | |
$pop_posts = get_transient( 'st_popular_posts' ); | |
if( false === $pop_posts ) { | |
$args = apply_filters( 'showcase_filter_popular_posts', array( | |
'orderby' => 'comment_count', | |
'posts_per_page' => 4, | |
) ); | |
$pop_posts = new WP_Query( $args ); | |
set_transient( 'st_popular_posts', $pop_posts, WEEK_IN_SECONDS ); |
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 | |
$args = array( | |
'limit' => 9999, | |
'return' => 'ids', | |
'date_completed' => '2018-10-01...2018-10-10', | |
'status' => 'completed' | |
); | |
$query = new WC_Order_Query( $args ); | |
$orders = $query->get_orders(); | |
foreach( $orders as $order_id ) { |
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 | |
$order = wc_get_order( $order_id ); | |
$customer_id = $order->get_user_id(); |
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 | |
$order = wc_get_order( $order_id ); | |
echo $order->get_billing_email(); | |
echo $order->get_billing_first_name(); | |
echo $order->get_billing_last_name(); | |
echo $order->get_billing_address_1(); | |
echo $order->get_billing_address_2(); | |
echo $order->get_billing_postcode(); | |
echo $order->get_billing_state(); | |
echo $order->get_billing_country(); |
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
/** | |
* How to get the product associated with a WooCommerce subscription | |
*/ | |
function ct_checkout_subscription_created( $subscription, $order, $recurring_cart ) { | |
$id = $subscription->get_id(); // You can use this to set meta in the subscription | |
// Get the products in the order | |
$items = $order->get_items(); | |
foreach( $items as $item ) { | |
$product = $item->get_product(); | |
$product_id = $product->get_id(); |
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 my_spaced_filter_amenities_icons( $icons ) { | |
$icons['spaced_cctv'] = array( | |
'id' => 'spaced_cctv', | |
'icon' => 'icon-cctv', | |
'label' => __( 'CCTV', 'spaced' ) | |
); | |
return $icons; | |
} | |
add_filter( 'spaced_filter_amenities_icons', 'my_spaced_filter_amenities_icons' ); |
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 | |
/** | |
* This will hide widgets | |
* @param array $instance The current widget instance's settings. | |
* @param WP_Widget $this The current widget instance. | |
* @param array $args An array of default widget arguments. | |
*/ | |
function wcmo_filter_widget_display_callback( $settings, $widget, $args ) { | |
$can_access = false; // You need to set your conditions here | |
if( $can_access || in_array( $widget->name, $whitelist ) ) { |
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 | |
/** | |
* All credit to Henrik Jacobsen for this: https://bitbucket.org/snippets/henjak/4eBAqR/product-extras-for-woocommerce-add | |
* | |
* Add countries as options to a selectbox. | |
* | |
* When creating the selectbox in admin set "countrylist" as the first option and | |
* this code will insert all the countries. | |
* | |
* @uses product-extras-for-woocommerce/inc/functions-single-product.php/pewc_filter_item_start_list |
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 | |
/** | |
* Add a text field to each cart item | |
*/ | |
function prefix_after_cart_item_name( $cart_item, $cart_item_key ) { | |
$notes = isset( $cart_item['notes'] ) ? $cart_item['notes'] : ''; | |
printf( | |
'<div><textarea class="%s" id="cart_notes_%s" data-cart-id="%s">%s</textarea></div>', | |
'prefix-cart-notes', | |
$cart_item_key, |
OlderNewer