Skip to content

Instantly share code, notes, and snippets.

@wplaunchify
wplaunchify / benchmark-to-trigger.php
Created August 20, 2019 16:36
Change BenchMark To Trigger (or any other word) in Groundhogg.io
add_filter( 'gettext', 'lab_translate' );
function lab_translate( $translated ) {
$original = array(
// 'original word' = > 'your new translated word'
'Benchmark' => 'Trigger',
);
$translated = str_ireplace( array_keys($original), $original, $translated );
return $translated;
@wplaunchify
wplaunchify / wait-el.js
Created November 23, 2019 15:09 — forked from chrisjhoughton/wait-el.js
Wait for an element to exist on the page with jQuery
var waitForEl = function(selector, callback) {
if (jQuery(selector).length) {
callback();
} else {
setTimeout(function() {
waitForEl(selector, callback);
}, 100);
}
};
@wplaunchify
wplaunchify / cartflows-prefill-checkout-from-url.txt
Created December 6, 2019 00:11
CartFlows Prefill WooCommerce Checkout Fields From URL (Instructions)
CartFlows Prefill WooCommerce Checkout Fields From URL
How To Use This Plugin:
This plugin provides a convenient way to pre-fill any WooCommerce checkout form, either natively or in CartFlows, from a custom url that you generate using your favorite form builder.
The parameters it passes from the url are:
a) Email
b) First Name
c) Last Name
@wplaunchify
wplaunchify / functions.php
Created January 30, 2020 06:10 — forked from dleone81/functions.php
Woocommerce get product type
/**
* is_type can be simple, variable, grouped, external
* woocommerce_single_product_summary is hook!
* Put this into your functions.php (child-theme)
**/
add_action( 'woocommerce_single_product_summary', 'get_product_type', 5 );
function get_product_type() {
global $post;
if( function_exists('get_product') ){
$product = get_product( $post->ID );
@wplaunchify
wplaunchify / functions.php
Created February 24, 2020 05:52 — forked from corsonr/functions.php
WooCommerce: Add conditional checkout fields based on products in cart
<?php // Do not include this if already open! Code goes in theme functions.php.
/**
* Add fields to the checkout page based on products in cart.
*
* @how-to https://remicorson.com/?p=7871
* @author Remi Corson
* @testedwith WooCommerce 3.4.0
*/
@wplaunchify
wplaunchify / functions.php
Created February 24, 2020 05:54 — forked from ajmorris/functions.php
Check for specific Product IDs in your cart to return true if they are there. WooCommerce/WordPress
<?php
/**
* Check if a specific product ID is in the cart
*/
function wc_ninja_product_is_in_the_cart() {
// Add your special product IDs here
$ids = array( '45', '70', '75' );;
// Products currently in the cart
$cart_ids = array();
@wplaunchify
wplaunchify / functions.php
Created February 24, 2020 05:55 — forked from ajmorris/functions.php
Remove checkout field if product IDs exist. WooCommerce / WordPress
<?php
/**
* Conditionally remove a checkout field based on products in the cart
*/
function wc_ninja_remove_checkout_field( $fields ) {
if ( ! wc_ninja_product_is_in_the_cart() ) {
unset( $fields['billing']['billing_company'] );
}
return $fields;
@wplaunchify
wplaunchify / functions.php
Created February 24, 2020 05:55 — forked from ajmorris/functions.php
Code for WooCommerce to check if products in the cart belong to one of the categories we're looking for.
<?php
/**
* Check if a specific product category is in the cart
*/
function wc_ninja_category_is_in_the_cart() {
// Add your special category slugs here
$categories = array( 'clothing', 'posters' );
// Products currently in the cart
$cart_ids = array();
@wplaunchify
wplaunchify / launchflows-pluggable-checkout-fields-and-style.php
Last active March 2, 2020 00:42
LaunchFlows - Pluggable functions to unset, reorder, make not-required, or style into full width, first column or second column position
// adds inline style for leadmagnet
add_action('woocommerce_before_checkout_form', 'lf_leadmagnet_style');
if (! function_exists ('lf_leadmagnet_style') ) { // make pluggable
function lf_leadmagnet_style() {
?>
<style id="lf-leadmagnet">
.woocommerce-billing-fields h3 {
display: none;
}
@wplaunchify
wplaunchify / dynamic-bump-style.css
Last active March 9, 2020 00:53
LaunchFlows - Dynamic Bump Checkbox Style Rules
.lf-bump img{
display: none; /* hide or show thumbnail. default is "block" */
width: 300px; /* change size larger or smaller. default is 75px */
margin: 0 0 0 10px; /* add space between checkbox and img */
}
.lf-bump input.switch {
transform: scale(2); /* larger numbers increase size. default is 1.5 */