greencode
Forum Replies Created
-
Forum: Plugins
In reply to: [LiteSpeed Cache] Premmerce Permalink Manager Issues with Litespeed@litetim Frustratingly it’s happening completely randomly. The report number is MVMRMIVG
Hi @janilyn409. I’ve tested with WooCommerce 9.8.5 and the latest version of your plugin 1.0.5 and everything appears to be working as it should. Thanks for resolving the issue. Very much appreciated.
Forum: Plugins
In reply to: [Friendly User Agent for WooCommerce] HPOS compatibility@windischweb @katmac_aus With the help of ChatGPT and Claude.ai I’ve managed to make this HPOS compatible. If you’re comfortable editing the plugin files then replace all of the content in the woo-friendly-user-agent.php file with this
<?php
/**
* Plugin Name: Friendly User Agent for WooCommerce
* Plugin URI:
* Description: Show the order user agent in a user friendly view on the orders page.
* Version: 1.4.0
* Tested up to: 6.5
* Requires PHP: 5.6
* WC requires at least: 3.0.0
* WC tested up to: 8.0.0
* Author: Blaze Concepts
* Author URI: https://www.blazeconcepts.co.uk/
*
* Text Domain: woo-friendly-user-agent
*
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Declare HPOS compatibility
*/
add_action( 'before_woocommerce_init', function() {
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
} );
/**
* Enable Languages
*
* @return void
*/
add_action( 'init', 'blz_fua_load_plugin_textdomain' );
function blz_fua_load_plugin_textdomain() {
$domain = 'woo-friendly-user-agent';
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
include_once dirname( __FILE__ ) . '/parse-user-agent.php';
/**
* Add Friendly User Agent to single order page
*
* @param [object] $order
* @return void
*/
add_action( 'woocommerce_admin_order_data_after_billing_address', 'blz_fua_show_user_agent_admin_order' );
function blz_fua_show_user_agent_admin_order($order) {
$agent = $order->get_customer_user_agent();
if ( !isset($agent) || empty($agent) ) {
// Not set don't output
} else {
echo '<div class="single_order_ua"><strong>'.__('Customer User Agent','woo-friendly-user-agent').':</strong><br> '.blz_fua_getFriendlyAgent($agent).'</div>';
}
}
/**
* Add Friendly User Agent column to orders list page (legacy tables)
*
* @param [array] $columns
* @return $new_columns
*/
add_filter('manage_edit-shop_order_columns', 'blz_fua_add_order_agent_column_header', 20);
function blz_fua_add_order_agent_column_header( $columns ) {
$new_columns = array();
foreach ( $columns as $column_name => $column_info ) {
$new_columns[ $column_name ] = $column_info;
if ( 'order_total' === $column_name ) {
$new_columns['order_agent'] = __( 'User Agent', 'woo-friendly-user-agent' );
}
}
return $new_columns;
}
/**
* Add Friendly User Agent column to orders list page (HPOS)
*/
add_filter( 'woocommerce_shop_order_list_table_columns', 'blz_fua_add_order_agent_column_header_hpos', 20 );
function blz_fua_add_order_agent_column_header_hpos( $columns ) {
$new_columns = array();
foreach ( $columns as $column_name => $column_info ) {
$new_columns[ $column_name ] = $column_info;
if ( 'total' === $column_name ) {
$new_columns['order_agent'] = __( 'User Agent', 'woo-friendly-user-agent' );
}
}
return $new_columns;
}
/**
* Display Friendly User Agent in column on orders list page (legacy tables)
*
* @param [string] $column
* @return void
*/
add_action('manage_shop_order_posts_custom_column', 'blz_fua_add_order_agent_column_content');
function blz_fua_add_order_agent_column_content( $column ) {
global $post;
if ( 'order_agent' === $column ) {
$order = wc_get_order( $post->ID );
$agent = $order->get_customer_user_agent();
if ( !isset($agent) || empty($agent) ) {
$output = __('Not set','woo-friendly-user-agent');
} else {
$output = blz_fua_getFriendlyAgent($agent);
}
echo $output;
}
}
/**
* Display Friendly User Agent in column on orders list page (HPOS)
*/
add_action( 'manage_woocommerce_page_wc-orders_custom_column', 'blz_fua_add_order_agent_column_content_hpos', 10, 2 );
function blz_fua_add_order_agent_column_content_hpos( $column, $order ) {
if ( 'order_agent' === $column ) {
$agent = $order->get_customer_user_agent();
if ( !isset($agent) || empty($agent) ) {
$output = __('Not set','woo-friendly-user-agent');
} else {
$output = blz_fua_getFriendlyAgent($agent);
}
echo $output;
}
}
/**
* Get Friendly User Agent and return output
*
* @param [string] $agent
* @return $output
*/
function blz_fua_getFriendlyAgent($agent) {
$friendlyagent = blz_fua_parse_user_agent($agent);
$output = '';
if(isset($friendlyagent['platform']) && !empty($friendlyagent['platform'])){
$output .= __('Platform','woo-friendly-user-agent').': '.$friendlyagent['platform'];
} else {
$output .= __('Platform: Not known','woo-friendly-user-agent');
}
if(isset($friendlyagent['imgplatform']) && !empty($friendlyagent['imgplatform'])){
$output .= '<img src="'.$friendlyagent['imgplatform'].'" width="15" height="15" />';
}
$output .= '<br>';
if(isset($friendlyagent['browser']) && !empty($friendlyagent['browser'])){
$output .= __('Browser','woo-friendly-user-agent').': '.$friendlyagent['browser'];
} else {
$output .= __('Browser: Not known','woo-friendly-user-agent');
}
if(isset($friendlyagent['imgbrowser']) && !empty($friendlyagent['imgbrowser'])){
$output .= '<img src="'.$friendlyagent['imgbrowser'].'" width="15" height="15" />';
}
$output .= '<br>';
if(isset($friendlyagent['version']) && !empty($friendlyagent['version'])){
$output .= __('Version','woo-friendly-user-agent').': '.$friendlyagent['version'];
}
return $output;
}
/**
* Add admin CSS
*
* @return void
*/
add_action( 'admin_print_styles', 'blz_fua_add_order_agent_column_style' );
function blz_fua_add_order_agent_column_style() {
$css = '.post-type-shop_order .wp-list-table td.column-order_agent,
.woocommerce-page.page-wc-orders .wp-list-table .order_agent.column-order_agent {
width: 9%;
line-height: 20px;
}
.post-type-shop_order .wp-list-table td.column-order_agent img,
.woocommerce-page.page-wc-orders .wp-list-table .order_agent.column-order_agent img {
vertical-align: middle;
margin-left: 5px;
}
.post-type-shop_order .single_order_ua,
.woocommerce-page.page-wc-orders .single_order_ua {
line-height: 20px;
}
.post-type-shop_order .single_order_ua img,
.woocommerce-page.page-wc-orders .single_order_ua img {
vertical-align: middle;
margin-left: 5px;
}';
wp_add_inline_style( 'woocommerce_admin_styles', $css );
}Basically added Added HPOS Compatibility Declaration
add_action( 'before_woocommerce_init', function() {
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
} );Added Support for HPOS Order List Columns
add_filter( 'woocommerce_shop_order_list_table_columns', 'blz_fua_add_order_agent_column_header_hpos', 20 );Added HPOS Order Column Content Handler
add_action( 'manage_woocommerce_page_wc-orders_custom_column', 'blz_fua_add_order_agent_column_content_hpos', 10, 2 );And Updated CSS for HPOS Compatibility (Added CSS selectors to target both traditional and HPOS order list views). Updated Version Number and WC Tested Up To (Increased version to 1.4.0 and updated WC tested up to 8.0.0)
Forum: Plugins
In reply to: [WooCommerce] Fatal error BlockPatterns.php:251Hi @lovingbro Thanks for this but it’s not just sites that disable the Legacy REST API plugin as other users are reporting i.e. some users are reporting the issue after making no updates or deactivating any plugins! I’ll keep an eye on the github you linked to.
Forum: Plugins
In reply to: [WooCommerce] Fatal errorIt’ll be the same as the other people that have reported this issue. See other posts in this support forum.
Forum: Plugins
In reply to: [WooCommerce] Fatal error BlockPatterns.php:251@mosesmedh Thanks for the quick update. Looking forward to a permanent resolution.
Forum: Plugins
In reply to: [WooCommerce] Fatal error BlockPatterns.php:251There’s a lot of people reporting it now on GitHub
Forum: Plugins
In reply to: [WooCommerce] Fatal error BlockPatterns.php:251Edit the code here
wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.phpReplace this
if ( strpos( $category['title'], $prefix ) !== false ) {with this
if ( isset( $category['title'] ) && is_string( $category['title'] ) && strpos( $category['title'], $prefix ) !== false ) {Hi. Any news on when an update will be released as I’d really like to get woocommerce onto the latest version but unable to do so until this is fixed. Thanks.
Hi. I’ve managed to fix the issue. If you have “Hide shipping costs until an address is entered” checked then it doesn’t work. This has to be unchecked. For others that encounter this issue the setting is located: WooCommerce > Settings > Shipping > Shipping Settings – Calculcation
Having the same issue. Hopefully a fix will come soon.
@janilyn409 thanks for this. I’ll look forward to the update. I’ll stay on 9.7.1. for now.
I can confirm that it has broken in 9.8.1. I’ve reverted back to 9.7.1 and that works okay.
@amjadali688 apologies, I thought I’d replied. Thanks for your help with this. This worked perfectly. Great plugin btw.
@adamewww Thanks for the quick response. I’ve increased that to 60 seconds, so i’ll see how that goes.