Skip to content

Instantly share code, notes, and snippets.

View bobbiejwilson's full-sized avatar

Bobbie Wilson bobbiejwilson

View GitHub Profile
@bobbiejwilson
bobbiejwilson / webflow-lottie.js
Last active April 3, 2023 21:51
Webflow Lottie Animations Access
<script>
var lottie, animations
// Return a promise that resolves to true once animation is loaded
async function animationLoaded(animation) {
if(animation.isLoaded) {
return true
}
return new Promise((resolve, reject) => {
(function($){
function exportTableToCSV($table, filename) {
var $rows = $table.find('tr:has(th), tr:has(td)'),
// Temporary delimiter characters unlikely to be typed by keyboard
// This is to avoid accidentally splitting the actual contents
tmpColDelim = String.fromCharCode(11), // vertical tab character
tmpRowDelim = String.fromCharCode(0), // null character
@bobbiejwilson
bobbiejwilson / functions.php
Created October 28, 2016 15:31 — forked from yojance/functions.php
Removing a Product From The Cart Programatically In WooCommerce
<?php
add_action( 'template_redirect', 'remove_product_from_cart' );
function remove_product_from_cart() {
// Run only in the Cart or Checkout Page
if( is_cart() || is_checkout() ) {
// Set the product ID to remove
$prod_to_remove = 56;
// Cycle through each product in the cart
foreach( WC()->cart->cart_contents as $prod_in_cart ) {
@bobbiejwilson
bobbiejwilson / functions_wc_dropdown.php
Last active March 13, 2018 16:00
Woocommerce variation dropdown with stock qty.
function wc_dropdown_variation_attribute_options( $args = array() ) {
global $product;
$variations = $product->get_available_variations();
$args = wp_parse_args( apply_filters( 'woocommerce_dropdown_variation_attribute_options_args', $args ), array(
'options' => false,
'attribute' => false,
'product' => false,
'selected' => false,
'name' => '',
@bobbiejwilson
bobbiejwilson / gist:5a4538c4dba1794463f8da0e09faff86
Created April 3, 2016 05:42
Manually add entries to form and trigger notifications
<?php
// Manually create entries and send notifications with Gravity Forms
$form_id = 10;
// add entry
$entry = array(
"form_id" => $form_id,
"1" => "Entry for field ID 1",
@bobbiejwilson
bobbiejwilson / breadcrumb.php
Created April 9, 2015 23:53
WordPress Breadcrumb function
<?php
function wds_breadcrumbs() {
global $post, $paged;
if ( !is_home() || !is_front_page() || !is_paged() ) {
echo '<a href="' . esc_url( get_home_url() ) . '" class="crumb-home"><span class="screen-reader-text">' . __( 'Home', 'wds' ) . '</span></a>';
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Send an email each time an order with coupon(s) is completed
* The email contains coupon(s) used during checkout process
*
*/
function woo_email_order_coupons( $order_id ) {
@bobbiejwilson
bobbiejwilson / gist:c5b5d36e763f68338c4f
Created February 28, 2015 02:41
Woocommerce Auto Coupon
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' );
function apply_matched_coupons() {
global $woocommerce;
$coupon_code = '10percent'; // your coupon code here
if ( $woocommerce->cart->has_discount( $coupon_code ) ) return;
if ( $woocommerce->cart->cart_contents_total >= 500 ) {
@bobbiejwilson
bobbiejwilson / gist:9dfb43cfa0c72fb3b8a3
Last active August 29, 2015 14:15
Woocommerce Store Closing
<?php
//Add to functions.php. Set the redirect to the proper permalink for notice
add_action('template_redirect','store_closed');
function store_closed(){
if (!is_admin() && is_woocommerce()){
wp_redirect('/store-closed/');
exit;
}
@bobbiejwilson
bobbiejwilson / gist:4678137
Last active December 11, 2015 23:39
Login Redirect Based on Roles
function my_login_redirect($redirect_to, $request){
global $user;
get_currentuserinfo();
//is there a user to check?
if(is_array($user->roles))
{
//check for admins
if(in_array("administrator", $user->roles))
return home_url("/wp-admin/");