Skip to content

Instantly share code, notes, and snippets.

View rayflores's full-sized avatar

Ray Flores rayflores

View GitHub Profile
@rayflores
rayflores / exclude_samples.php
Last active July 27, 2016 08:17
exclude variation id from Dynamic Pricing Advanced Category Product Rules
<?php
/* DO NOT ADD SAMPLE PRODUCT WITHIN DYNAMIC DISCOUNT RULES */
add_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'exclude_sample_products', 10, 2 );
function exclude_sample_products( $include, $product ) {
$products_to_exclude = array();
foreach (WC()->cart->cart_contents as $cart_item_key => $cart_item){
if ($cart_item['variation']['attribute_pa_buy-or-try'] == 'try-before-you-buy') {
$products_to_exclude[] = $cart_item['variation_id'];
}
@rayflores
rayflores / twice-loop.php
Last active June 9, 2016 19:36
loop getting two
<?php
$customer_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types(),
'post_status' => array_keys( wc_get_order_statuses() ),
) );
$nonPurchaseable = array();
@rayflores
rayflores / custom_checkout_filter.php
Last active May 20, 2016 16:25
custom checkout filer
<?php
function custom_add_validation_rules() {
if ( ! isset( WC()->cart ) ) {
return;
}
// Check if emails are ligitimate, if its not set add an error.
if ( isset($_POST['additional_field_644']) && ! is_email( $_POST['additional_field_644'] ) ){
wc_add_notice( 'Email Address For Summaries is not a valid email address.', 'error' );
}
@rayflores
rayflores / pinit_onlyon.php
Last active November 19, 2015 11:07
add attachment meta, and remove pinterest pinit button from those images with meta box checked...
<?php
/**
* Plugin Name: Pinit Only On Selected Media
* Plugin URI: http://www.rayflores.com/plugins/pinit-onlyon/
* Version: 1.0
* Author: Ray Flores
* Author URI: http://www.rayflores.com
* Description: Adds ability to select media attachments to be unpinned.
* Requires at least: 4.0
* Tested up to: 4.1
@rayflores
rayflores / page-lathes.php
Created November 6, 2015 06:56
close loop after each term
<?php
/**
* Theme: Flat Bootstrap
*
* Template Name: ACF Lathes
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
@rayflores
rayflores / need_cust_counter.php
Last active March 16, 2021 17:31
need custom counter per line (row)
<?php
/**
* Plugin Name: WooCommerce Modify CSV output
* Plugin URI: http://rayflores.com/plugins/csv-modifier/
* Description: Dan Colucci modifier
* Version: 1.0.1
* Author: Ray Flores
* Author URI: http://rayflores.com
*/
@rayflores
rayflores / multi-tax-dropdown.php
Last active August 29, 2015 14:19
dropdown taxes
<?php
function taxonomy_dropdowns_box( ) {
$brand_taxonomy = 'pa_marcas';
$taxonomy_name = 'MARCAS';
wp_nonce_field('custom-dropdown', 'dropdown-nonce');
$terms = get_terms( $brand_taxonomy, 'hide_empty=0');
foreach ($terms as $term) {
$all_terms[] = $term->term_id;
@rayflores
rayflores / wpdb-api_call.php
Last active August 29, 2015 14:16
need for API
<?php
* Returns all the orders made by the user
*
* @param int $user_id
* @param string $status (completed|processing|canceled|on-hold etc)
* @return array of order ids
*/
function get_all_user_orders($user_id,$status='completed'){
if(!$user_id)
return false;
@rayflores
rayflores / query_limited_deals.php
Created December 30, 2014 22:58
I wanted to show posts from limited deals plugin. Order it by the deal with the most time to expiration, and then ensure that the post contained a limited deal (via checkbox), and show the latest post from there... here is what I ended up with :)
<?php
$args = array(
'post_type' => 'product',
'meta_key' => '_limited_dates_to',
'orderby' => 'meta_value',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => '_limited',
'value' => 'yes',
@rayflores
rayflores / modify_csv_exporter.php
Created December 19, 2014 20:33
add globals for indexer :) works now...
<?php
/**
* Plugin Name: WooCommerce Modify CSV Exported file
* Description: Adds and removes desired and undesired fields respectively
* Version: 1.0.0
* Author: Ray Flores
* Author URI: http://www.rayflores.com
* Requires at least: 3.9
* Tested up to: 3.9
*