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
/** | |
* Register term fields | |
*/ | |
add_action( 'init', 'register_vendor_custom_fields' ); | |
function register_vendor_custom_fields() { | |
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_add_form_fields', 'add_vendor_custom_fields' ); | |
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_edit_form_fields', 'edit_vendor_custom_fields', 10 ); | |
add_action( 'edited_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' ); | |
add_action( 'created_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' ); | |
} |
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 | |
/** | |
* Redirect users to custom URL based on their role after login | |
* | |
* @param string $redirect | |
* @param object $user | |
* @return string | |
*/ | |
function wc_custom_user_redirect( $redirect, $user ) { | |
// Get the first of all the roles assigned to the user |
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 | |
/** | |
* Autocomplete Paid Orders (WC 2.2+) | |
*/ | |
add_filter( 'woocommerce_payment_complete_order_status', 'bryce_wc_autocomplete_paid_paypal_orders' ); | |
function bryce_wc_autocomplete_paid_paypal_orders( $order_status, $order_id ) { | |
$order = wc_get_order( $order_id ); | |
if ( $order->payment_method == 'paypal' ) { | |
if ( $order_status == 'processing' && ( $order->status == 'on-hold' || $order->status == 'pending' || $order->status == 'failed' ) ) { |
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
jQuery('.ninja-forms-form').on('submitResponse', function(e, response) { | |
var $popup = jQuery('#pum-123'), | |
errors = response.errors; | |
if (errors === false) { | |
$popup.popmake('open'); | |
} | |
}); |
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 edd_popup_terms_agreement() { | |
if ( edd_get_option( 'show_agree_to_terms', false ) ) { | |
$popup_id = '123'; | |
$agree_text = edd_get_option( 'agree_text', '' ); | |
$agree_label = edd_get_option( 'agree_label', __( 'Agree to Terms?', 'easy-digital-downloads' ) ); | |
?> | |
<fieldset id="edd_terms_agreement"> | |
<div id="edd_terms" style="display:none;"> |
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 | |
/** | |
* Helper function to get sanitized field | |
* and also normalize values. | |
* | |
* @param $field_key | |
* @param bool $post_id | |
* @param bool $format_value | |
* @param string $sanitization_method esc_html / esc_attr or NULL for none | |
* @return array|bool|string |
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
/** | |
* Optimize WooCommerce Scripts | |
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages. | |
*/ | |
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 ); | |
function child_manage_woocommerce_styles() { | |
//remove generator meta tag | |
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) ); |
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
// Define which products we should hide the subscription text for | |
function should_hide_subscription_text($product){ | |
$is_subscription = (get_class($product) == 'WC_Product_Variable_Subscription'); | |
$has_price = (intval($product->subscription_price)>0); | |
$has_fee = (intval($product->subscription_sign_up_fee)>0); | |
if($is_subscription && $has_price && !$has_fee){ | |
return true; | |
} else { | |
return false; | |
} |
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( 'loop_shop_columns', 'wc_loop_shop_columns', 1, 10 ); | |
/* | |
* Return a new number of maximum columns for shop archives | |
* @param int Original value | |
* @return int New number of columns | |
*/ | |
function wc_loop_shop_columns( $number_columns ) { |