Skip to content

Instantly share code, notes, and snippets.

View rayflores's full-sized avatar

Ray Flores rayflores

View GitHub Profile
@rayflores
rayflores / rearrange-product-addons.php
Created September 21, 2017 18:38
WooCommerce Rearrange Product Addons
<?php
/*
Plugin Name: WooCommerce Rearrange Product Addons
*/
$GLOBALS['Product_Addon_Display']; // get globals
// if variations - remove from single variation hook
function remove_plugin_actions(){
remove_action( 'woocommerce_single_variation', array( $GLOBALS['Product_Addon_Display'], 'display' ), 15);
@rayflores
rayflores / shipping-label-text.php
Created September 5, 2017 16:16
Add text to shipping label
<?php
add_filter( 'woocommerce_cart_shipping_method_full_label', 'add_free_to_free_shipping_label', 10, 2);
function add_free_to_free_shipping_label( $label, $method ){
if ( $method->cost === '0.00' ){
$label = $label . ' (Free)';
}
return $label;
}
@rayflores
rayflores / list-products.php
Created August 4, 2017 15:19
get products
<?php
$base_rest_url = 'http://rayflores.staging.wpengine.com/wp-json/';
$woo_namespace_ver = 'wc/v1/products';
define( 'WC_CONSUMER_KEY', 'ck_d18285f04efdc33b160849682f40d4cf58a3540a' );
define( 'WC_CONSUMER_SECRET', 'cs_75b36a35c2645c518f60916f6e5387740e37389c' );
define( 'WC_BASE_REST_URL', $base_rest_url );
define( 'WC_NAMESPACE_VER', $woo_namespace_ver );
$params = array(
'consumer_key' => urlencode( WC_CONSUMER_KEY ),
'consumer_secret' => urlencode( WC_CONSUMER_SECRET )
@rayflores
rayflores / add_continue_shopping_button.php
Last active September 18, 2017 21:55
Add Continue Shopping Button to View Cart Message
<?php
/*
Plugin Name: Add Continue Shopping Button for WooCommerce
Plugin URI: https://rayflores.com/add-continue-shopping-button-on-single-product-page/
Description: Add a "Continue Shopping" button to the added to cart message on single product pages
Version: 1.0
Author: Ray Flores
Author URI: https://www.rayflores.com/
*/
add_filter( 'wc_add_to_cart_message_html', 'add_continue_shopping_button', 10, 2);
@rayflores
rayflores / htaccess.htaccess
Last active January 26, 2017 21:57
301 perm redir to index alt TLD
# 1. GoDaddy -> login
# 2. Go to Domains
# 3. Go to Manage Hosting for that domain
# 4. Click on Manage for the site.
# You should now be in Control Panel backend of oldsite.com
# Either via FTP or FileManager (icon)
# find .htaccess file in root of domain folder
# open that file with a text editor (eg. Notepad or Notepad++)
# replace the contents of existing file with one of the following code snippets
@rayflores
rayflores / mods.php
Created December 9, 2016 19:46
sort not working PIP
<?php
add_action( 'wc_pip_styles','add_custom_css' );
function add_custom_css(){
?>
.customer-details {
margin-left: -15px;
margin-right: -15px;
}
.customer-details li {
padding: 0 15px;
<?php
$i=1;
foreach (WC()->cart->cart_contents as $item) {
if ( isset( $cart_item[ 'composite_data' ] ) && ! empty( $cart_item[ 'composite_parent' ] ) ) {
return $cart_item_class . ' item-' . $i + 10;
} elseif ( isset( $cart_item[ 'composite_data' ] ) && ! empty( $cart_item[ 'composite_children' ] ) ) {
return $cart_item_class . ' item-' . $i + 20;
@rayflores
rayflores / logconsole.js
Last active August 22, 2018 21:05
need to log
;( function ( $, window, document, undefined ) {
$( '.composite_data' )
.on( 'wc-composite-initializing', function( event, composite ) {
var l = composite.api;
var step_objects = l.get_steps();
var review_step = l.get_step_by( 'id', 'review' );
var result = $.grep(l, function(e){ return e.id == id; });
//console.log(step_objects);
@rayflores
rayflores / camaroon.php
Last active September 23, 2016 16:14
camaroon
<?php
// vars
$field = get_field_object('cameroon','option');
$cameroon = $field['value'];
$label = ucfirst($field['choices'][ $cameroon ]); // if needed for id
?>
<path id="Cameroon" class="'. $cameroon . '" blah blah blah
@rayflores
rayflores / secondtolast.php
Created September 19, 2016 15:37
find second to last p
function ads_added_above_last_p($text) {
if( is_single() ) {
$ad_code5 = "<!-- /35404881/JOA_end_of_article_300x250_1 -->
<center><div id='div-gpt-ad-1466631079074-3' style='height:250px; width:300px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1466631079074-3'); });
</script>
</div></center>";
$last = strrpos($content, '</p>');