Skip to content

Instantly share code, notes, and snippets.

@wplaunchify
wplaunchify / functions.php
Created May 16, 2023 23:33 — forked from gmmedia/functions.php
Enable Gutenberg editor for WooCommerce
<?php
// Find the description at https://bloggerpilot.com/en/gutenberg-for-woocommerce/
// Disable new WooCommerce product template (from Version 7.7.0)
function bp_reset_product_template($post_type_args) {
if (array_key_exists('template', $post_type_args)) {
unset($post_type_args['template']);
}
return $post_type_args;
}
@wplaunchify
wplaunchify / a-generic-checkout.json
Created March 10, 2020 21:13
LaunchFlows - A Generic Checkout Example
{"version":"0.4","title":"A Generic Checkout","type":"section","content":[{"id":"24ce239c","settings":{"structure":"20","_ha_condition_list":[{"_ha_condition_key":"login_status","_ha_condition_operator":"is","_ha_condition_login_status":"login","_id":"09a7033","_ha_condition_role":"subscriber","_ha_condition_operating_system":"mac_os","_ha_condition_browser":"chrome","_ha_condition_date_range":"07-03-2020 to 09-03-2020","_ha_condition_date":"07-03-2020","_ha_condition_time":"12:00","_ha_condition_day":"monday"}],"margin":{"unit":"px","top":"100","right":0,"bottom":"100","left":0,"isLinked":true}},"elements":[{"id":"69e0b28b","settings":{"_column_size":50,"_inline_size":null,"_ha_condition_list":[{"_ha_condition_key":"login_status","_ha_condition_operator":"is","_ha_condition_login_status":"login","_id":"eb82ef1","_ha_condition_role":"subscriber","_ha_condition_operating_system":"mac_os","_ha_condition_browser":"chrome","_ha_condition_date_range":"07-03-2020 to 09-03-2020","_ha_condition_date":"07-03-2020","_h
@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 */
@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 / 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 / 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: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: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 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 / 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