Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter ridle

    (@ridle)

    @mlwilkerson

    Yes that seemed to do the trick to fix it on this end.

    Thread Starter ridle

    (@ridle)

    @mlwilkerson

    Any update on this?

    Thread Starter ridle

    (@ridle)

    @mlwilkerson

    Yes I mean the button ‘Add Font Awesome’. We make use of the WYSIWYG ACF field within a ACF flexible content field.

    I just confirmed 4.5.0 did work just fine, the issue started at 5.0

    I don’t have any console log errors anymore.

    Thread Starter ridle

    (@ridle)

    While this DOES get rid of the message, the buttons still doesn’t work sadly.

    I also reinstalled the plugin from scratch.

    Hey,

    I had the exact same problem. But the funny thing is, it actually DOES save it in the correct order. It just doesn’t show in the back-end.

    I went digging into the code and made a temporary fix. Let me know if it works for you too.

    There needs to come an official update ofcourse later on.

    Change the file to the code below /rearrange-woocommerce-products/views/template-parts/-tab-all-products.php


    <?php
    /**
    * List all products with PHP sorting after query.
    *
    * @package ReWooProducts
    */

    if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
    }

    $args = array(
    'post_type' => array( 'product' ),
    'posts_per_page' => '-1',
    'post_status' => array( 'publish' ),
    );

    // If a term_id is provided, limit to that category.
    if ( isset( $_GET['term_id'] ) && ! empty( $_GET['term_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
    $term_id = sanitize_text_field( wp_unslash( $_GET['term_id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification

    $args['tax_query'] = array(
    array(
    'taxonomy' => 'product_cat',
    'terms' => array( $term_id ),
    'field' => 'id',
    'operator' => 'IN',
    ),
    );
    // Remove WP_Query ordering so we can handle it with PHP.
    // (Alternatively, you can leave ordering here if it helps pre-sort but it might not be enough.)
    } else {
    $args['orderby'] = array(
    'menu_order' => 'ASC',
    'title' => 'ASC',
    );
    }

    $products = new WP_Query( $args );

    $sorted_items = array();

    // Build an array of items with the needed sort values.
    if ( $products->have_posts() ) {
    while ( $products->have_posts() ) {
    $products->the_post();
    global $post;

    // Initialize a default sort order.
    $sortorder = 0;
    if ( isset( $term_id ) ) {
    // Define the meta key based on term_id.
    $meta_key = 'rwpp_sortorder_' . $term_id;
    $meta_val = get_post_meta( $post->ID, $meta_key, true );
    $sortorder = ( '' !== $meta_val ) ? intval( $meta_val ) : 0;
    }

    // Also grab menu order and title as fallback sort criteria.
    $menu_order = intval( $post->menu_order );
    $title = get_the_title( $post->ID );

    $sorted_items[] = array(
    'post' => $post,
    'sortorder' => $sortorder,
    'menu_order' => $menu_order,
    'title' => $title,
    );
    }
    wp_reset_postdata();
    }

    // Now sort the array using PHP's usort.
    // The sort order is: sortorder (meta) first, then menu_order, then title.
    usort( $sorted_items, function( $a, $b ) {
    if ( $a['sortorder'] !== $b['sortorder'] ) {
    return $a['sortorder'] - $b['sortorder'];
    }
    if ( $a['menu_order'] !== $b['menu_order'] ) {
    return $a['menu_order'] - $b['menu_order'];
    }
    return strcmp( $a['title'], $b['title'] );
    });
    ?>

    <div id="rwpp-products-list">
    <?php
    $serial_no = 1;
    foreach ( $sorted_items as $item ) {
    $post = $item['post'];
    setup_postdata( $post );
    $product = wc_get_product( $post->ID );
    include '-product.php';
    $serial_no++;
    }
    ?>
    </div>

    <button id="rwpp-save-orders" class="button-primary">
    <?php esc_html_e( 'Save Changes', 'rearrange-woocommerce-products' ); ?>
    </button>

    <div id="rwpp-response"></div>
    <?php wp_reset_postdata(); ?>
    Thread Starter ridle

    (@ridle)

    Also some console log info:

    stack trace: 0 /public_html/inhoud/plugins/font-awesome/includes/class-fontawesome-svg-styles-manager.php(223): FortAwesomeFontAwesome_SVG_Styles_Manager->selfhost_asset_full_path() 1 /public_html/inhoud/plugins/font-awesome/includes/class-fontawesome.php(1042): FortAwesomeFontAwesome_SVG_Styles_Manager->is_svg_stylesheet_present() 2 /public_html/inhoud/plugins/font-awesome/includes/class-fontawesome.php(386): FortAwesomeFontAwesome->initialize_admin() 3 /public_html/inhoud/plugins/font-awesome/font-awesome-init.php(71): FortAwesomeFontAwesome->init() 4 /public_html/inhoud/plugins/font-awesome/font-awesome.php(207): require(‘…’) 5 /public_html/wp-includes/class-wp-hook.php(324): FortAwesomeFontAwesome_Loader->init_plugin() 6 /public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() 7 /public_html/wp-includes/plugin.php(517): WP_Hook->do_action() 8 /public_html/wp-settings.php(704): do_action() 9 /public_html/wp-config.php(218): require_once(‘…’) 10 /public_html/wp-load.php(50): require_once(‘…’) 11 /public_html/wp-admin/admin.php(34): require_once(‘…’) 12 /public_html/wp-admin/edit.php(10): require_once(‘…’) 13 {main}

    edit.php?post_type=page:897 php version: 8.3.13
    WordPress version: 6.7.2
    multisite: false
    is_network_admin: false

    Thread Starter ridle

    (@ridle)

    Hello,

    Thank you, I have no more errors now, now I can complete my code.

Viewing 7 replies - 1 through 7 (of 7 total)