Skip to content

Instantly share code, notes, and snippets.

View PluginRepublicSupport's full-sized avatar

PluginRepublicSupport

View GitHub Profile
@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 / 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 **/
@PluginRepublicSupport
PluginRepublicSupport / pewc_sticker_mule.php
Last active June 30, 2023 05:51
stickermule.com interface (die cut stickers)
<?php
add_filter( 'prefix_filter_field_option_name', function( $option_value, $key, $item, $product ) {
$qty_radio_field_id = 3153; // Quantity (Radio Group) field
if ( $item['field_id'] == $qty_radio_field_id ) {
$option_value .= '<span class="qty-discounted-price">
</span>';
$option_value .= '<span class="qty-percent-savings">
<?php
function prefix_pewc_products_for_cats_limit($limit) {
// Increase the limit to 120
$limit = 120;
return $limit;
}
add_filter('pewc_products_for_cats_limit', 'prefix_pewc_products_for_cats_limit');