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
<?php | |
/** | |
* Ensure that products with user ID permissions override any global settings | |
*/ | |
add_filter( 'wcmo_always_show_user_products', '__return_true' ); |
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
<?php | |
function pewc_ajax_add_child_product_to_cart() { | |
$result = WC()->cart->add_to_cart( intval( $_POST['product_id'] ), intval( $_POST['quantity'] ) ); | |
$result ? wp_send_json_success() : wp_send_json_error(); | |
} | |
add_action('wp_ajax_pewc_add_child_product_to_cart', 'pewc_ajax_add_child_product_to_cart'); | |
add_action('wp_ajax_nopriv_pewc_add_child_product_to_cart', 'pewc_ajax_add_child_product_to_cart'); |
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
<?php | |
/** | |
* Automatically populate a field with user data | |
* Enter the user field in the 'Default' field | |
* Wrapped in {} | |
* E.g. {first_name} | |
*/ | |
function junhee_populate_user_field( $value, $id, $item, $posted ) { | |
if( is_user_logged_in() ) { |
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
<?php | |
function prefix_external_registration_approval_message( $message, $url, $user_id ) { | |
if( ! apply_filters( 'wcmo_allow_external_approval', false ) ) { | |
return $message; | |
} | |
$user_data = get_userdata( $user_id ); | |
$message .= '<p>User email: ' . $user_data->user_email . '</p>'; | |
return $message; |
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
<?php | |
add_filter( 'wcmo_allow_external_approval', '__return_true' ); |
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
<?php | |
/** | |
* Get the user's location and populate the address | |
*/ | |
function prefix_created_customer( $user_id ) { | |
// Lcoation field ID | |
$field_id = '4171f87f'; | |
// Get the location |
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
<?php | |
/** | |
* Apply the standard booking cost as a fixed cost to a booking, regardless of how long the booking is | |
*/ | |
function prefix_fixed_booking_cost( $booking_cost, $product_id ) { | |
$product = wc_get_product( $product_id ); | |
$booking_cost = floatval( bfwc_get_standard_cost( $product ) ); | |
return $booking_cost; | |
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
<?php | |
function demo_close_accordion() { | |
return 'yes'; | |
} | |
add_filter( 'pewc_close_accordion', 'demo_close_accordion' ); |
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
<?php | |
/** | |
* Query WordPress attachments with no alt text | |
* Automatically create alt text using file name | |
* Remove this snippet once you've run it | |
*/ | |
function pr_query_attachments() { | |
if( did_action( 'init' ) > 1 ) { | |
return; | |
} |
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
<?php | |
/** | |
* Remove quantity input field in cart for specific products | |
*/ | |
function prefix_cart_item_quantity( $product_quantity, $cart_item_key ){ | |
$cart_item = WC()->cart->cart_contents[ $cart_item_key ]; | |
$product_id = $cart_item['data']->get_id(); | |
if( in_array( $product_id, array( 467, 789 ) ) ){ | |
$product_quantity = $cart_item['quantity']; | |
} |
NewerOlder