Skip to content

Instantly share code, notes, and snippets.

View yojance's full-sized avatar
🏠
Working from home

Yojance Rabelo yojance

🏠
Working from home
View GitHub Profile
@yojance
yojance / expired.sql
Created September 18, 2015 17:59
Finding Expiring Discounts
SELECT post_id FROM wp_postmeta WHERE meta_key = 'expiry_date' AND meta_value <= '2015-09-18' AND meta_value != '';
@yojance
yojance / class-advanced-search.php
Created August 12, 2015 12:22
Advanced Search Foundation
<?php
class Advanced_Search {
public $version = 1;
public function __construct() {
// WordPress Hooks
$this->hooks();
}
@yojance
yojance / Books SQL
Last active October 6, 2015 17:21
Books SQL Query
SELECT order_id, order_item_name FROM kt_woocommerce_order_items WHERE order_item_name IN (
'The Best of The Digital Photography Book Series', #1605950
'How Do I Do That In Lightroom?', #1564501
'The Headshot: The Secrets to Creating Amazing Headshot Portraits', #1542682
'(Spiral Bound) The Adobe Photoshop Lightroom CC Book for Digital Photographers', #1475578
'The Adobe Photoshop Lightroom CC Book for Digital Photographers (Paperback)', #1446548
'It’s Not About The f-Stop', #1383012
'The Photoshop Elements 13 Book for Digital Photographers', #1286356
'The Adobe Photoshop CC Book for Digital Photographers', #1090080
'Light, Gesture & Color', #1090070
$protection_engine = new MM_ProtectedContentEngine();
$attached_bundle = $protection_engine->getPostAccessRights( $course_id );
$bundle_id = $attached_bundle[0]->access_id;
$bundle = new MM_Bundle( $bundle_id );
$associated_product_id = key( $bundle->getAssociatedProducts() );
$associated_product = new MM_Product( $associated_product_id );
$buy_link = add_query_arg( array( 'rid' => $associated_product->getReferenceKey() ), home_url( '/' ) . 'checkout/' );
@yojance
yojance / random-courses.php
Created July 8, 2015 14:34
Random Courses file
<?php
$args = array(
'post_type' => 'sfwd-courses',
'orderby' => 'rand',
'no_found_rows' => 1,
'posts_per_page'=> 2,
'author' => $post->post_author, // Needs the current Course Author ID
'post__not_in' => array( $post->ID ), // Needs the current Course ID
);
@yojance
yojance / functions.php
Created February 28, 2015 20:58
Output the Tab's content
<?php
/* Output the Tab's content */
add_action( 'woocommerce_product_data_panels', 'internal_comments_data_panel' );
function internal_comments_data_panel() {
?>
<div id="internal_comments_data" class="panel woocommerce_options_panel" style="display: none;">
<div class="options_group">
<?php
woocommerce_wp_textarea_input(
array( 'id' => '_internal_notes',
@yojance
yojance / functions.php
Created February 28, 2015 15:01
Adding A New Product Data Tab
<?php
/* Register New Tab */
add_filter( 'woocommerce_product_data_tabs', 'register_internal_comments_data_tab' );
function register_internal_comments_data_tab( $data_tabs ) {
$internal_comments = array(
'internal_comments' => array(
'label' => __('Internal Comments', 'spyr'),
'target' => 'internal_comments_data',
'class' => array(),
),
@yojance
yojance / functions.php
Created February 24, 2015 02:32
Functions required for the incentive program
<?php
/**
* Will extract the Variation ID if available otherwise it will get the Product ID
* @param $product Product
* @param bool $check_variations Whether or not to check for variation IDs
* @return mixed
*/
function get_id_from_product( $product, $check_variations = true ) {
// Are we taking variations into account?
if( $check_variations ) {
@yojance
yojance / functions.php
Created February 21, 2015 21:02
Product From A Category AND Minimum Cart Total
<?php
// Product From A Category AND Minimum Cart Total
function qualifies_for_incentive() {
// Incentive product we are giving away
$incentive_product_id = 102;
if( qualifies_basedon_product_category( 'premium-quality' )
&& qualifies_basedon_cart_total( 199 ) ) {
add_incentive_to_cart( $incentive_product_id );
} else {
@yojance
yojance / functions.php
Created February 21, 2015 21:01
Product From A Category In The Cart OR Minimum Cart Total
<?php
// Product From A Category In The Cart OR Minimum Cart Total
function qualifies_for_incentive() {
// Incentive product we are giving away
$incentive_product_id = 102;
if( qualifies_basedon_product_category( 'premium-quality' )
|| qualifies_basedon_cart_total( 199 ) ) {
add_incentive_to_cart( $incentive_product_id );
} else {