• amirhmoradi

    (@amirhmoradi)


    Hi team,

    In reviewx, you have a partial file overwriting woocommerce’s default order table (wp-content/plugins/reviewx/partials/storefront/myaccount/order-table.php) but this template is deprecated and troublesome in major ways:

    • it has inconsistent content (each order is duplicated in multiple lines for each of its items)
    • is set to version 7.0.1, and we are already in Woocommerce 8.5.0
    • it does not use woo’s best practices
    • it runs business logic in the template partial !!
    • it slows down the user’s “My Orders” page.

    Here are what I suggest for a long term solution:

    -> Instead of having this partial, use woo’s filters and hooks to integrate your features. More below.

    -> Add Only ONE order column (using woo’s filter woocommerce_account_orders_columns, I saw you use it already, needs cleaing) that would have as content for each order a simple ul list of product names with a review action (you can also add a tooltip to show the product image on hover, but not required). Example:

    -> Manage order actions using woo’s filter woocommerce_my_account_my_orders_actions

    -> Migrate all business logic (calculations) in another place in your plugin and get the data via async ajax call so your plugin would not slow down the user’s “My Orders” page.

    -> avoid adding your css classes or ids to partials and templates. Use specific and precise selectors using existing native classes and make sure to load your style files ONLY when absolutely required to not impact performance.

    Best.

    PS: I believe ChatGPT would be very helpful fixing all the points in couple of minutes with your expertise ?? Here is the start of a conversation I had with it on the matter: https://chat.openai.com/share/aa69952c-dbbc-4822-afc0-934147f33e60

    • This topic was modified 9 months ago by amirhmoradi. Reason: add chatgpt chat link
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Sabbir Mahmud

    (@sadhinsabbir)

    Hey @amirhmoradi,

    Thanks for bringing the issue with our notice with the solution! You’re a true superhero for ReviewX man!

    It will be fixed soon and I will get back to you with the updates.

    Warm regards!

    Thread Starter amirhmoradi

    (@amirhmoradi)

    Hi ??

    Here is what i achieved as a result trying to fix the my orders page, there are still lots of room for improvements, but the basics are there:

    Here is the code snippet to make it happen until a fix is provided by ReviewX team. (the code can be added to the theme’s functions.php or using a code snippet plugin):

    
    // Add the Column
    add_filter('woocommerce_account_orders_columns', function ($columns) {
        // Add a new column for reviews after the order status column
        $new_columns = [];
    
        foreach ($columns as $key => $name) {
            $new_columns[$key] = $name;
            if ('order-status' === $key) {
                // Add the custom column for reviews
                $new_columns['order-reviews'] = __('Product Reviews', 'reviewx');
            }
        }
    
        return $new_columns;
    });
    
    // Populate the Column
    add_action('woocommerce_my_account_my_orders_column_order-reviews', function ($order) {
        echo '<ul>';
    
        // Initialize an array to track which products have been processed.
        $processed_products = [];
    
        foreach ($order->get_items() as $item_id => $item) {
            $product = $item->get_product();
            $product_id = $product->get_id();
    
            // Skip if the product has already been processed.
            if (in_array($product_id, $processed_products)) {
                continue;
            }
    
            // Add the product ID to the array to avoid processing it again.
            $processed_products[] = $product_id;
    
            // Uncomment the line below to enable checking if the product has been reviewed.
            $bAlreadyReviewed = \ReviewX_Helper::check_already_reviewed($product_id, get_current_user_id(), $order->get_id());
    
            echo '<li>' . esc_html($product->get_name());
            
            if ($bAlreadyReviewed) {
                echo ' (<a style="font-size:0.8em;" class="rx_my_account_view_review rx-btn btn-primary btn-sm rx-form-primary-btn btn-review review-off btn-info rx-order-btn " href="'
                    . esc_url(get_permalink($product_id))
                    . '#tab-reviews" target="_blank">'
                    . esc_html__('View review', 'reviewx')
                    . '</a>)';
            } else {
                echo ' (<a style="font-size:0.8em;" class="rx_my_account_submit_review rx-btn btn-primary btn-sm rx-form-primary-btn btn-review review-on btn-info rx-order-btn " '
                    . ' data-product_id="' . $product_id . ' "'
                    . ' data-order="1"' 
                    . ' data-order_status="' . esc_html__(wc_get_order_status_name($order->get_status()), 'woocommerce') . '"'
                    . ' data-order_id="' . $order->get_id() . '"'
                    . ' data-order_url="' . esc_url($order->get_view_order_url()) . '"'
                    . ' data-product_url="' . get_permalink($product_id) . '"'
                    . ' data-product_img="' . esc_url(wp_get_attachment_image_url($product->get_image_id(), 'thumbnail')) . '"'
                    . ' data-product_name="' . $product->get_name() . '"'
                    . ' data-product_quantity="' . $item->get_quantity() . '"'
                    . ' data-product_price="' . $item->get_subtotal() . '"'
                    .' >'
                    . esc_html__('Submit review', 'reviewx')
                    . '</a>)';
            }
            echo '</li>';
        }
    // Dirty fix for styles and hide and show of the review box...
        echo '</ul>';
    	echo '<script>
    	jQuery(document).ready( function() {
    	jQuery(".review-on").on("click", function(){
    	  jQuery(".woocommerce-orders-table").hide();
    	});
    	jQuery(".rx-cancel").on("click", function(){
    	  jQuery(".woocommerce-orders-table").show();
    	});
    	});</script>';
    	echo '<style>
    	.rx-form-btn{
    	    background-color: #fff;
    		border: 1px solid #aaa;
    		border-radius: 10px;
    	}
    	.rx-form-btn:hover{
    	    color:#000!important;
    	}
    	</style>';
    });
    
    // Include the review form in my orders page using hooks.
    function ax_wc_reviewx_custom_myorderpagemods(){
    	/**
         * Get and show value from admin setting page
         */
        $settings                   = \ReviewX\Controllers\Admin\Core\ReviewxMetaBox::get_option_settings();
        $review_criteria            = $settings->review_criteria;    
        $allow_review_title         = get_option('_rx_option_allow_review_title');  
        $allow_img                  = get_option( '_rx_option_allow_img' );
        $allow_recommendation       = get_option( '_rx_option_allow_recommendation' );
        $rating_style               = $settings->rating_style;
        $allow_video                = get_option( '_rx_option_allow_video' );
        $video_source               = get_option( '_rx_option_video_source' );    
        $allow_anonymouse           = get_option( '_rx_option_allow_anonymouse' );   
    
        /**
         * Show product review from from my account page
         */
        include('/var/www/wp-content/plugins/reviewx/partials/storefront/myaccount/add-review.php');
    
        /*=================================
        *
        * Load review edit template
        *
        *==================================*/
        echo apply_filters( 'rx_edit_review_form', '' );
    }
    add_action('woocommerce_after_account_orders','ax_wc_reviewx_custom_myorderpagemods',100);

    In the list of improvements to add ( @sadhinsabbir ):

    • Add a “My Reviews” menu to be able to manage all my reviews (as a customer), from a new page in my account’s dashboard… As seller, in this new page I would show incentives for my users to review products (coupons, goodies…) as well as provide direct customer support access scenarios.
    • The relation between a given review and an order shall be loosened to allow knowing if a review has ever been given by a user for a product_id, independent of its order_id (see \ReviewX_Helper::check_already_reviewed($product_id, get_current_user_id(), $order->get_id())).
    • Showing all order details in the review collection box on my orders page seems useless to me as it only brings confusing info to the user. Only a small box showing the product image + name + short truncated description + a “Buy Again” call to action button would be great enough. –> Keep the focus on review + sales.
    Plugin Contributor Sabbir Mahmud

    (@sadhinsabbir)

    Hi @amirhmoradi,

    Please accept my sincerest gratitude for the help and your valuable time. I really appreciate it.
    We will implement the fix ASAP and will release a new version of the plugin within next week.

    Regarding the improvements you have suggested, we have started developing a brand new ReviewX from scratch that will 100X more powerful comparing to the current ReviewX plugin. I have already forwarded your suggestion to the feature R&D team and I hope they will implement your suggested improvements gradually.

    Team ReviewX is grateful to you and hopefully you will always support us by providing feedbacks.

    Warm regards ??

    any update on this update?
    https://prnt.sc/aJY-cu0wgdPh

    • This reply was modified 8 months, 2 weeks ago by sviceyyj. Reason: adding screen shot
    Plugin Contributor Sabbir Mahmud

    (@sadhinsabbir)

    Hi @sviceyyj,

    We will release an update with the fix on next week. Hopefully on Tuesday.
    Thanks for your immense patience and support for ReviewX.

    In the meantime if you need assistance with anything else, feel free to let us know.

    Warm regards,
    Sabbir, Team ReviewX

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘My Account Template Issue’ is closed to new replies.