Skip to content

Instantly share code, notes, and snippets.

View PluginRepublicSupport's full-sized avatar

PluginRepublicSupport

View GitHub Profile
@PluginRepublicSupport
PluginRepublicSupport / wcfad_pewc_adjust_field_prices.php
Created October 24, 2023 08:07
If both Product Add-Ons Ultimate and Fees and Discounts are installed, and "Apply User Role Pricing to add-on field prices" is enabled, you can override this on a per-field basis using the "wcfad_pewc_adjust_field_prices" filter
<?php
add_filter( 'wcfad_pewc_adjust_field_prices', 'custom_wcfad_pewc_adjust_field_prices', 10, 3 );
function custom_wcfad_pewc_adjust_field_prices( $adjust, $item, $product_id ) {
// if field price is a percentage of the product price, do not adjust
if ( $item['field_percentage'] ) {
$adjust = false;
}
return $adjust;
}
@PluginRepublicSupport
PluginRepublicSupport / pewc_grid_variation_products.php
Created October 4, 2023 13:23
Enable the grid for specific products
<?php
function custom_enable_variations_grid($enable, $product_id) {
// Add your specific product IDs here
$specific_product_ids = array(234,324,336); // Replace with your product IDs
if (in_array($product_id, $specific_product_ids)) {
return true; // Enable the grid for specific products
}
@PluginRepublicSupport
PluginRepublicSupport / pewc_show_add-ons_before_variation.php
Created September 14, 2023 15:37
Show product-addon fields before WooCommerce product variations
<?php
function tester_remove_fields_from_before_button() {
global $product;
if ( $product->get_type() == 'variable' ) {
remove_action( 'woocommerce_before_add_to_cart_button', 'pewc_product_extra_fields' );
@PluginRepublicSupport
PluginRepublicSupport / wcdpp_tutorlms.php
Last active September 4, 2023 08:56
Some compatibility functions between Deposits and Part Payments and Tutor LMS
<?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
@PluginRepublicSupport
PluginRepublicSupport / wcmo_wpml_allow_login_page.php
Last active September 1, 2023 09:41
Allow the translated version of a login page to be viewed
<?php
function custom_wcmo_is_content_restricted( $is_restricted, $restricted_content ) {
if ( $is_restricted ) {
// if Restriction Method is User Role, get the value of "If Restricted, Redirect To", usually the login page
$redirect_page = get_option( 'wcmo_redirect_restricted', false );
if ( $redirect_page ) {
// get the translated ID for the login page using WPML's filter
$redirect_page_translated = apply_filters( 'wpml_object_id', $redirect_page, 'page', false );
if ( get_the_ID() == $redirect_page_translated ) {
// we are on the translated page, allow this
@PluginRepublicSupport
PluginRepublicSupport / prefix_translate_reg_fields.php
Last active August 28, 2023 14:16
Translate Members Only Field
<?php
add_filter( 'wcmo_registration_fields', function( $fields ) {
foreach ( $fields as $key => $field ) {
switch ( $key ) {
case "first_name":
$fields[$key]["label"] = "Voornaam";
break;
case "last_name":
<?php
function prefix_required_quote_fields( $fields ) {
$fields['phone']['required'] = true;
return $fields;
}
@PluginRepublicSupport
PluginRepublicSupport / hide_empty_child_product_category.php
Created July 28, 2023 07:14
Hide child products' category if it's empty
<?php
/*** Hide child product category if it's empty ***/
add_filter( 'pewc_filter_item_start_list', function( $item, $group, $group_id, $post_id ) {
if ( $item['field_type'] == "product-categories" && empty( $item['child_products'] ) ) {
return false;
}
@PluginRepublicSupport
PluginRepublicSupport / pewc_cart_calc_field.php
Last active July 18, 2023 14:51
Currency Symbol for Calculation Fields
<?php
/** Add the default currency field to calculation values in cart **/
add_filter( 'pewc_filter_item_value_in_cart', function( $field_value, $field ) {
if ( $field['type'] == "calculation" ) {
$field_value = get_woocommerce_currency_symbol() . $field_value;
}
return $field_value;
}, 10, 2 );
@PluginRepublicSupport
PluginRepublicSupport / checkbox_columns_count.css
Created July 18, 2023 14:26
Checkbox & Radio Image Mobile Device Columns
/** Show 4 columns on iPad, Tablets **/
@media (min-width: 481px) and (max-width: 768px){
.pewc-radio-images-wrapper .pewc-radio-image-wrapper, .pewc-checkboxes-images-wrapper .pewc-checkbox-image-wrapper {
width: 25%;
}
}
/** Show 4 columns on Mobile devices **/