This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('init', 'copy_gravity_form_data'); | |
function copy_gravity_form_data() { | |
global $wpdb; | |
if (is_admin() && current_user_can('administrator') && isset($_GET['do-gravity-form-sync'])) { | |
$copy_args = array( | |
array( | |
'category' => 'your-product-category-slug', | |
'product_id' => 'PRODUCT_ID' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wc_dynamic_pricing_get_product_pricing_rule_sets', 'custom_wc_dynamic_pricing_get_product_pricing_rule_sets', 10, 3 ); | |
function custom_wc_dynamic_pricing_get_product_pricing_rule_sets( $rulesets, $product_id, $pricing_module ) { | |
$custom_rule_set = array( | |
'conditions_type' => 'all', | |
'conditions' => array( | |
1 => array( | |
'type' => 'apply_to', | |
'args' => array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_catalog_restrictions_get_roles_for_current_user', 'custom_woocommerce_catalog_restrictions_get_roles_for_current_user'); | |
function custom_woocommerce_catalog_restrictions_get_roles_for_current_user($roles){ | |
if ( current_user_can( 'wholesale_user')) { | |
unset($roles['guest']); | |
} | |
return $roles; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_catalog_restrictions_get_roles_for_current_user', 'custom_woocommerce_catalog_restrictions_get_roles_for_current_user'); | |
function custom_woocommerce_catalog_restrictions_get_roles_for_current_user($roles){ | |
if ( !current_user_can( 'wholesale_user')) { | |
$roles['customer'] = 'customer'; | |
} | |
return $roles; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wc_dynamic_pricing_price_html', 'custom_wc_dynamic_pricing_price_html', 10, 2); | |
function custom_wc_dynamic_pricing_price_html($html, $product){ | |
$html = $html . $product->get_price_suffix(); | |
return $html; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_dynamic_pricing_is_rule_set_valid_for_user', 'allow_guest_for_rules', 10, 3); | |
function allow_guest_for_rules( $result, $condition, $adjustment_set ) { | |
if ( $condition['args']['applies_to'] == 'roles' && isset( $condition['args']['roles'] ) && is_array( $condition['args']['roles'] ) ) { | |
foreach ( $condition['args']['roles'] as $role ) { | |
if ( ( $role == 'guest' && !is_user_logged_in() ) || current_user_can( $role ) ) { | |
$result = 1; | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_get_availability', 'custom_woocommerce_get_availability', 10, 2); | |
function custom_woocommerce_get_availability($avail, $product) { | |
global $post; | |
$old_post = $post; | |
$post = get_post($product->variation_id); | |
$result = WC_Conditional_Content_Display::instance()->template_display(0, false); | |
$post = $old_post; | |
if ($result){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$exists = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status = %s AND ID = %d", 'you-post-type', 'publish', $your_post_id)); | |
if (!empty($exists) && !is_wp_error( $exists )){ | |
//post exists. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*--------------------------------------------------------------------------------------------- | |
* | |
* Postbox: Fields | |
* | |
*---------------------------------------------------------------------------------------------*/ | |
#acf-field-group-fields > .inside { | |
padding: 0; | |
margin: 0; | |
} | |
#acf-field-group-fields > .handlediv, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_dynamic_pricing_process_product_discounts', 'wcdp_exclude_sale_items', 10, 2); | |
function wcdp_exclude_sale_items( $include, $product ) { | |
$instance = WC_Dynamic_Pricing::instance(); | |
remove_filter( 'woocommerce_get_price', array($instance, 'on_get_price'), 10, 2 ); | |
remove_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'wcdp_exclude_sale_items', 10, 2 ); | |
if ( $product->is_on_sale() ) { | |
$include = false; | |
} | |
add_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'wcdp_exclude_sale_items', 10, 2 ); |