Brad Dalton
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Hide out of stock products when using ‘sorting’ in categoryAdd this PHP code to the end of your child themes functions file or custom code snippets plugin.
add_action( 'woocommerce_product_query', 'wpsites_hide_out_of_stock_products_on_specific_sorting', 10, 2 );
function wpsites_hide_out_of_stock_products_on_specific_sorting( $query ) {
if ( ! is_admin() && $query->is_main_query() && is_shop() || is_product_category() ) {
$orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : '';
if ( in_array( $orderby, array( 'price', 'popularity' ) ) ) {
$query->set( 'meta_query', array_merge( $query->get( 'meta_query' ), array(
array(
'key' => '_stock_status',
'value' => 'instock',
'compare' => '='
)
) ) );
}
}
}Forum: Plugins
In reply to: [Download Monitor] PHP Warning: session_start(): Session cannot be startedThanks. Good job!
Forum: Plugins
In reply to: [WooCommerce] Invalid Download Links After MigrationResolved using Search and replace. Must have broken after the site got mapped to the wpcomstaging.com as it was on there for a few days and i published 13 posts/products.
Forum: Plugins
In reply to: [WooCommerce] Invalid Download Links After MigrationHere’s another problem.
When you migrated wpsites.net to staging and then to wpsites.net, downloads links like this became broken.
/nas/content/live/wpsitesstg/wp-content/uploads/dlm_uploads/2024/08/2024-block-child.zip
should be
https://wpsites.net/wp-content/uploads/dlm_uploads/2024/09/2024-block-child.zip
It’s still showing. If so, there should be an ‘x’ icon on the right side that will permanently dismiss that banner.
This is not true. It never permanently removes.
Forum: Plugins
In reply to: [WooCommerce] Invalid Download Links After MigrationUpdate. Not fixed but. Found a problem. When migrating from wpsites.net to wpsitesnet.wpcomstaging.com and then changing the Primary site address from staging to wpsites.net here wordpress.com/domains/manage/wpsites.net, the links to the download directories did not change from wpsitesnet.wpcomstaging.com to wpsites.net causing the invalid links.
Any guidance on bulk changing these links would be appreciated. Maybe an SQL query or something else? Thank You.
P.S Your migration team might be interested in this.
- This reply was modified 4 weeks ago by Brad Dalton.
- This reply was modified 4 weeks ago by Brad Dalton.
- This reply was modified 4 weeks ago by Brad Dalton.
Forum: Plugins
In reply to: [Download Monitor] PHP Warning: session_start(): Session cannot be startedOnly that one for your plugin.
Forum: Plugins
In reply to: [Limit Login Attempts Reloaded] Plugin ErrorsYes, only installed it a few hours ago and saw the errors.
Forum: Plugins
In reply to: [WooCommerce] Looking for a pluginYou can use code in your child themes functions file like this:
add_action( 'woocommerce_before_add_to_cart_button', 'custom_product_addons', 10 );
function custom_product_addons() {
global $product;
$product_price = $product->get_price(); // Base price of the product.
?>
<div id="product-warranty-addons">
<p>Select Additional Warranty:</p>
<button type="button" class="warranty-addon" data-addon="15" data-price="<?php echo esc_attr( $product_price ); ?>">
Additional 4-Month Warranty (+15%)
</button>
<button type="button" class="warranty-addon" data-addon="30" data-price="<?php echo esc_attr( $product_price ); ?>">
Additional 8-Month Warranty (+30%)
</button>
</div>
<input type="hidden" id="addon_price_value" name="addon_price_value" value="0">
<?php
}
add_action( 'wp_footer', 'custom_product_addons_script' );
function custom_product_addons_script() {
if ( is_product() ) { ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('.warranty-addon').on('click', function() {
var addonPercentage = $(this).data('addon');
var basePrice = parseFloat($(this).data('price'));
var addonPrice = (addonPercentage / 100) * basePrice;
var totalPrice = basePrice + addonPrice;
// Update price display on the product page
$('.woocommerce-Price-amount').text('€' + totalPrice.toFixed(2));
// Set hidden input value for addon price
$('#addon_price_value').val(addonPrice.toFixed(2));
});
});
</script>
<?php }
}
add_filter( 'woocommerce_add_cart_item_data', 'custom_add_cart_item_data', 10, 2 );
function custom_add_cart_item_data( $cart_item_data, $product_id ) {
if( isset( $_POST['addon_price_value'] ) ) {
$cart_item_data['addon_price'] = sanitize_text_field( $_POST['addon_price_value'] );
$cart_item_data['unique_key'] = md5( microtime().rand() ); // To avoid merging of items
}
return $cart_item_data;
}
add_action( 'woocommerce_before_calculate_totals', 'custom_addon_price_to_cart' );
function custom_addon_price_to_cart( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return;
}
// Adjust the product price
foreach ( $cart->get_cart() as $cart_item ) {
if( isset( $cart_item['addon_price'] ) ) {
$cart_item['data']->set_price( $cart_item['data']->get_price() + $cart_item['addon_price'] );
}
}
}I did work this out. thank you.
Forum: Plugins
In reply to: [Advanced Google reCAPTCHA] Showing on Checkout Page When Shouldn’tThe problem is, the captcha is disabling the login button on the checkout page and the remember checkbox also cannot be checked so login is not possible on the checkout page.
Please send a copy to [email protected]
Do you have a function to get the id foreach slide?
get_favorites_button($slide_id);
Thank You.
Forum: Plugins
In reply to: [WooCommerce] modifying the product ratings blockI never provided any working code. The CSS rule i posted is an example which needs to be modified to include the class you want to target. You’ll also need to use the same rule to target the same class for elements on desktops as well as mobile devices and change the value for grid-template-columns: from 1fr on mobiles to another value on desktops.
I’ve used this method dozens of times.