woocommerce offtopic – Function to recalculate shipping costs on subscriptions after renewal with Automatewoo

I’ve got a funky plugin that was custom made that adds a new random product from a group that a customer subscribes to.

Problem is, that the shipping doesn’t change depending on which product is selected, it stays with whatever was chosen initially.

Rather than paying more money to redevelop something that might already exist, is there any code that will recalculate shipping costs based on the item in the subscription? I have automatewoo, so could use a custom function from that and run it after a subscription payment has completed, I just don’t know how to code it.

Any support appreciated!


woocommerce offtopic – Is it safe to delete from db orphaned posts i.e. whose post_parent no longer exists?

I inherited a couple of WP + WooCommerce shops with roughly 30,000 products for sale each, and a wp_postmeta which is over a million lines. The former webmasters ran away.

In an effort to clean up old stuff, I noticed a post_parent field in wp_posts, and queried the database for orphans:

SELECT ID FROM wp_posts WHERE NOT post_parent IN 
  (SELECT ID FROM wp_posts) AND post_parent>0 

and found thousands of records.
All of these records have a post_parent which no longer exists.

Just out of curiosity, I checked wp_postmeta:

SELECT * FROM wp_postmeta where post_id in
  (SELECT ID FROM wp_posts where not post_parent in 
     (select ID from wp_posts) and post_parent>0 ) 

and found 60,000 records.

Is it safe to delete them, along with any references from the tables wp_postmeta, wp_comments, wp_commentmeta, wp_term_relationships, wp_wc_product_meta_lookup ?

Else, can you suggest a strategy to clean up the database from spurious data?

woocommerce offtopic – Problem with showing more than 2k variations

I have product with 2430 variations (don’t ask is it necessary, contact lenses have a lot of variations, and shop owner insist in one product).
In front end, all possible variations are loaded in combo boxes, so buyer can choose non-existing combination instead of only existing combinations.

Any ideas will be appreciated.
Thanks in advance.


Current environment:
WP 5.7,
Woocommerce 5.1.0,
Shopkeeper theme,
PHP 7.3

Till now i have tried with this (one by one) to make it work:

  • Disabled all plugins
  • Variation swatches plugin (tried with Ajax trashold 1 and 80)
  • Try with default theme
  • Changed PHP from 7.0 to 7.4
  • Changing max_execution_time in PHP.ini up to 25000
  • Adding code to theme’s functions.php
function wc_ajax_variation_threshold_modify( $threshold, $product )
  $threshold = 2500;
  return  $threshold;

add_filter( 'woocommerce_ajax_variation_threshold', 'wc_ajax_variation_threshold_modify', 10, 2 );```

woocommerce offtopic – pincode validation on checkout

I am looking for a plugin that allows me to ask for a user verification code in the woocommerce checkout, and therefore if the code is in the database, the purchase cannot be done

since i can’t find a plugin, i was thinking of using a code in functions.php where i include the pin code valid for purchases i could try to use this code for the input field CODEPIN

add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
function my_custom_checkout_field_process() {
    global $woocommerce;

   //instead of billing_postecode I put codepin
  if ( ! (preg_match('/^(0-9){6}$/D', $_POST('billing_postcode') ))){
        wc_add_notice( "Incorrect Zip code! Please enter correct number."  ,'error' );

woocommerce offtopic – How to get ACF values to be read in WooCommere email-order-items.php ? (if else not working too)

I have been spending hours modifying the email-order-items.php in my WooCommerce theme. I need to show values m2 and pcs just after qty number in email quantity table based on ACF product option. Here is the code. Only the last if elseif ($per_unit_or_square == 'blank') {} is being printed, which maked me think I have done something wrong there.

I am just self-learning php, so sorry if there is something ridicously wrong in my code (it might be something with so many if elseif’s):

$qty          = $item->get_quantity();
$qty77        = wc_format_decimal($item->get_quantity(), 3 ); // quantity with decimal value
$refunded_qty = $order->get_qty_refunded_for_item( $item_id );

global $post;
global $product;
$product = $item->get_product();
$per_unit_or_square = get_field('pricem2_or_priceunit_', $product->get_id());

if (!empty($per_unit_or_square)) {
    if ($per_unit_or_square == 'm2') {
        if ( $refunded_qty ) {
                $qty_display = '<del>' . esc_html( $qty77 ) . '</del> <ins>' . esc_html( $qty77 - ( $refunded_qty * -1 ) ) . '</ins>';
            } else {
                $qty_display = esc_html( $qty77 );  
        echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', '<span>' . $qty_display. '&nbsp;m<sup>2</sup></span>', $item ) );
elseif ($per_unit_or_square == 'unit') { 
        if ( $refunded_qty ) {
                $qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>';
            } else {
                $qty_display = esc_html( $qty );
        echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', '<span>' . $qty_display. '&nbsp;pcs</span>', $item ) );
elseif ($per_unit_or_square == 'blank') {
if ( $refunded_qty ) {
                $qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>';
            } else {
                $qty_display = esc_html( $qty );
        echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $qty_display, $item ) );


woocommerce offtopic – Help with an API implementation

its is a woocommerce website which is quite simple. The problem is they have a shipping company’s API integrated into the website which has been hardcoded into the website in the child theme’s functions.php website. This API is going to be deprecated by the end of next month. The new code for the new API implementation is already done by the previous developer and he has left comments stating to commenting out the old API integration code and uncommenting new code to make it live. Can anyone please tell me which functions to comment out and which ones to uncomment?? The shipping API is

Any help is appreciated and will be compensated if necessary

see the new API code and old API code in the attachments

woocommerce offtopic – Plugin to increase 25% products

I want to increase price of all my products by 25%. But i want to do this all the time even with new products.

If I insert a product with price of 100 i want that it appear with 125 there is any plugin for this?

P.S I don’t want to this be visible to clients like an extra fee.

WordPress WooCommerce

woocommerce offtopic – Auto-move (scroll) product thumbnails on product page image slider

I’ve got a problem with the product image slider on the product page.
I used flex to display thumbnails in one row. There are 5 thumbnails in a row. Images move correctly using direction arrows.
How to set up auto-scroll to the next thumbnail in a row? Now it moves (main image changing) but 5 thumbnails in a row are still static.
I set overflow-x to auto, so you can see there are the next images in a row.

Basic code:

div.product div.images .flex-control-thumbs {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 50px;

div.product div.images .flex-control-thumbs li {
    display: flex;
    overflow-x: visible;
    flex: 1 0 20%;

My test site – you can see how it works:

Off-Topic Hub – Grand Opening! | Forum Promotion