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 | |
/** | |
* Set all groups to open (or closed ) in an accordion | |
*/ | |
function prefix_filter_initial_accordion_states( $state, $post_id ) { | |
// return 'closed'; // Uncomment this out and comment the line below to set all groups to closed | |
return 'open'; | |
} | |
add_filter( 'pewc_filter_initial_accordion_states', 'prefix_filter_initial_accordion_states', 10, 2 ); |
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 | |
/** | |
* Duplicates groups and fields for translated products. Original product should have duplicated groups and fields by this time. | |
*/ | |
function pewc_product_duplicate_polylang( $duplicate, $product ) { | |
// check that this function exists | |
if ( function_exists( 'pll_get_post_translations' ) ) { | |
$new_id = $duplicate->get_id(); | |
$old_id = $product->get_id(); | |
$new_trs = pll_get_post_translations( $new_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
<?php | |
/** | |
* This function updates a 'tutor_enrolled' post type after it is created by a scheduled order. Changing the status prevents them from being counted towards totals. | |
*/ | |
function wcdpp_tutor_after_enrolled( $course_id, $user_id, $enrolled_id ) { | |
// get the order_id attached to this tutor_enrolled record | |
$order_id = get_post_meta( $enrolled_id, '_tutor_enrolled_by_order_id', true ); | |
if ( $order_id ) { | |
// check if order is a scheduled order |
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( 'pewc_filter_product_extra_groups', function( $product_extra_groups, $post_id) { | |
if ( is_cart() || is_checkout() ) { | |
return $product_extra_groups; | |
} | |
if( ! is_object( wc_get_product( $post_id ) ) ) { | |
return $product_extra_groups; | |
} |
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 my_group_filter_title( $group_title, $group, $group_id ) { | |
$group_title = pewc_get_group_title( $group_id, $group, true ); | |
return '<h2>' . $group_title . '</h2>'; | |
} | |
add_filter( 'pewc_filter_group_title', 'my_group_filter_title', 10, 3 ); |
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 | |
/** | |
* Register a custom font with Text Preview | |
*/ | |
function prefix_register_custom_font( $fonts ) { | |
$fonts['font-1'] = 'Brush Script'; | |
$fonts['font-2'] = 'Arial'; | |
$fonts['font-3'] = 'Mermaid'; | |
$fonts['font-4'] = 'Angelina'; |
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
/** Center image wrappers **/ | |
.pewc-preset-style .pewc-radio-images-wrapper, .pewc-preset-style .pewc-checkboxes-images-wrapper{ | |
-webkit-justify-content: flex-start; | |
justify-content: flex-start; | |
margin: 0 -5px; | |
} | |
.pewc-preset-style .pewc-radio-image-wrapper, .pewc-preset-style .pewc-checkbox-image-wrapper { | |
margin: 0 5px; | |
} |
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 | |
/** Min selection check **/ | |
function min_checks( $notice, $label, $field_minchecks ) { | |
$notice = sprintf( | |
__( '%s requires MIN at least %s items to be selected', 'pewc' ), | |
esc_html( $label ), | |
$field_minchecks | |
); |
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 | |
/** | |
* Filter the step parameter in Name Your Price field | |
*/ | |
function prefix_number_field_step( $step, $item ) { | |
return 5; | |
} | |
add_filter( 'pewc_name_your_price_step', 'prefix_number_field_step', 10, 2 ); |
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('wp_footer', function() { | |
?> | |
<script> | |
jQuery(document).ready(function($) { | |
setTimeout(function() { | |
$('.pewc-has-extra-fields form.cart button.minus, .pewc-has-extra-fields form.cart button.plus').click(function(e) { | |
$(this).parent().find('.quantity input.qty').trigger('change'); | |
}); | |
}, 1000); |