delaitec
Forum Replies Created
-
Hi again,
I have successfully fixed the “Deprecated” error by refactoring the plugin’s code to comply with the new WooCommerce 10.4 requirements. I am sharing the solution here so you can include it in the next official update.
The Issue:
The function wc_enqueue_js() is deprecated. Also, calling script enqueues inside the init hook is no longer the recommended practice for inline scripts in recent WordPress/WooCommerce versions.The Fix:
Acess this file:
wp-content/plugins/quantity-field-on-shop-page-for-woocommerce/wc-quantity-field-shop-page.phpMoved the script-related actions from the init hook to the wp_enqueue_scripts hook.
Replaced all wc_enqueue_js calls with wp_add_inline_script.
Modified Code Snippet:
// 1. Updated the constructor hooks:
add_action( 'wp_enqueue_scripts', array( $this, 'woa_quantity_handler' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'woa_confirm_add' ) );
// 2. Updated the handler function:
public function woa_quantity_handler() {
$js = '
jQuery(function($) {
$("form.cart").on("change", "input.qty", function() {
$(this.form).find("[data-quantity]").attr("data-quantity", this.value);
});
$(document.body).on("adding_to_cart", function() {
$("a.added_to_cart").remove();
});
});';
wp_add_inline_script( 'jquery', $js );
}
// 3. Updated the confirmation function:
public function woa_confirm_add() {
$js = '
jQuery(document.body).on("added_to_cart", function( data ) {
jQuery(".added_to_cart").after("<p class=\'confirm_add\'>Item Added</p>");
});';
wp_add_inline_script( 'jquery', $js );
}This solution stops the “Deprecated” warnings and ensures full compatibility with the latest versions of WordPress and WooCommerce.
And bellow, The full fixed code:<?php
/*
Plugin Name: Quantity Field on Shop Page for WooCommerce
Plugin URI: http://wooassist.com
Description: Adds a ‘Quantity Field’ on the shop and category pages of your Woocommerce store. This allows the user to change the quantity of a product before adding it to the cart.
Version: 1.4.3
Author: Wooassist
Author URI: http://wooassist.com
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'woa_wqfsp' ) ) :
class woa_wqfsp {
/**
* @var The single instance of the class
*/
private static $_instance = null;
/**
* Main woa_wqfsp Instance
*
* Ensures only one instance of WooCommerce is loaded or can be loaded.
* * @static
* @see woa_wqfsp()
* @return woa_wqfsp main instance
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* woa_wqfsp Constructor.
*/
public function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'woa_add_quantity_style' ) );
// IMPORTANTE: Alterado de 'init' para 'wp_enqueue_scripts' para suportar wp_add_inline_script
add_action( 'wp_enqueue_scripts', array( $this, 'woa_quantity_handler' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'woa_confirm_add' ) );
add_filter( 'woocommerce_loop_add_to_cart_link', array( $this, 'woa_add_quantity_fields' ), 10, 2 );
add_filter( 'woocommerce_quantity_input_args', array( $this, 'woa_woocommerce_quantity_input_args' ), 10, 2 );
}
/**
* Add quantity fields.
*/
public function woa_add_quantity_fields($html, $product) {
//add quantity field only to simple products
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
//rewrite form code for add to cart button
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" data-quantity="1" data-product_id="' . $product->get_id() . '" class="button alt ajax_add_to_cart add_to_cart_button product_type_simple">' . esc_html( $product->add_to_cart_text() ) . '</button>';
$html .= '</form>';
}
return $html;
}
/**
* Adjust the quantity input values
*/
function woa_woocommerce_quantity_input_args( $args, $product ) {
if ( is_singular( 'product' ) && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$args['input_value'] = 1; // Starting value (we only want to affect product pages, not cart)
}
$args['max_value'] = $product->get_stock_quantity(); // Maximum value
$args['min_value'] = 0; // Minimum value
$args['step'] = 1; // Quantity steps
return $args;
}
/**
* woa_wqfsp add stylesheet for quantity field.
*/
public function woa_add_quantity_style() {
wp_enqueue_style( 'WQFSP_style', plugins_url( '/css/style.css', __FILE__ ) );
}
/**
* add AJAX support.
* synchs quantity field
* CORRIGIDO: Substituído wc_enqueue_js por wp_add_inline_script
*/
public function woa_quantity_handler() {
$js = '
jQuery(function($) {
$("form.cart").on("change", "input.qty", function() {
$(this.form).find("[data-quantity]").attr("data-quantity", this.value);
});
$(document.body).on("adding_to_cart", function() {
$("a.added_to_cart").remove();
});
});';
wp_add_inline_script( 'jquery', $js );
}
/**
* add checkmark
* CORRIGIDO: Substituído wc_enqueue_js por wp_add_inline_script
*/
public function woa_confirm_add() {
$js = '
jQuery(document.body).on("added_to_cart", function( data ) {
jQuery(".added_to_cart").after("<p class=\'confirm_add\'>Item Added</p>");
});';
wp_add_inline_script( 'jquery', $js );
}
}
endif; // ! class_exists()
/**
* Returns the main instance of woa_wqfsp.
*/
function woa_wqfsp_run() {
return woa_wqfsp::instance();
}
/**
* WC Detection
*/
if ( ! function_exists( 'woa_is_woocommerce_active' ) ) {
function woa_is_woocommerce_active() {
$active_plugins = (array) get_option( 'active_plugins', array() );
if ( is_multisite() ) {
$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
}
return in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins ) ;
}
}
/*
* Initialize
*/
if ( woa_is_woocommerce_active() ) {
woa_wqfsp_run();
}Hello. Thanks for the help of all.
I reviewed the settings and realized that the host address was the site domain, not mail.dominio.com
And the domain was with Proxi active in Cloudflare, which does not let the email work correctly.
So I moved to mail.Dominium.
with and disabled the proxy in all DNS records related to emailI am following to see if any error occurs again.
If I come back, I come here and inform you.
Please leave the topic open for a while.
Forum: Fixing WordPress
In reply to: WordPress database error Unknown column ‘insertionMethod’Hello @gappiah
The name of the file are:
cpuser_test.184338444958.sql.gz
This is a backup of my site database.
And the file are saved on cpanel root: (/home/cpuser/)
Not on the site folder, or public_html folder, is on main root.Forum: Plugins
In reply to: [WooCommerce] I would like to disconnect 2 sites from woocommerce.See, I no longer have Woocommerce installed on these sites.
I have no way to follow these steps.
Forum: Plugins
In reply to: [WooCommerce] I can’t connect to the Woocommerce App my cloned siteHello.
Could you help me with one last thing?I would like to connect a second store to the app.
But I don’t see the option to make a second connection.
How do I do it?
NOTE: Before I had 2 stores connected, and to solve the problem, I disconnected them all.
Now, I connected the first one, filling in the store address, username and password,
but I don’t see an option to connect the second store.Sorry for the confusion.
There are only 2 sites:
Original: mydomain.com/site
Clone: loja.mydomain.com/site
The site that is not connecting to jetpack is the ORIGINAL site (mydomain.com/site)
Note that to access any of my sites, you don’t need to type “/site” at the end, I’ve already made the adjustments to hide this from the URL.
About sending the domains, I prefer to send them via private message: But look, I also asked for help on github, and I already sent the domains and information in this same form that you sent me at Jeremy Herve’s request. Can you find it there? Or do you want me to send it again?
Have a great day!
Taking advantage. All my sites are installed in subdirectories “…/site” and I have never had problems activating jetpack. The clone site that is in a subdomain also connected normally.
The problem is in the ORIGINAL Site, which I cloned. It no longer connects to jetpack.
See what I said about the blog token validation failure message, this could be the cause, or something on the jetpack server.
Hello.
I don’t know if you understood correctly.
After you made the adjustment there, something happened
I went to check my sites, and the “clone site” that was already connected and working, showed the message “again” saying that there were 2 Jetpack connections.
I had to check again that I wanted to migrate the data to it from the original site to the clone (subdomain) and it connected again.
The original site, which is the problematic one, continues to have the problem and does not connect to Jetpack. (I uninstalled and reinstalled it) but without success.
Understand, the problem is occurring on the original site, which is not in the subdomain.
It is this site that does not connect to Jetpack.
The problem persists.
Thanks
Forum: Plugins
In reply to: [WooCommerce] I can’t connect to the Woocommerce App my cloned siteNo specific error appears.
I enter the login details.
Website address
User
PasswordAnd I get the message:
“Unable to log in to your store
An error occurred“However, today, He offered me the option to log into the website using a web browser built into the Woocommerce app itself, so after logging in I could click on approve the connection.
I managed to approve it that way.
Thanks for the help.
An update:
This link:
https://mysite.com/site/xmlrpc.php
It’s working.
I thought it wasn’t because my website is in the “/site” folder and I hadn’t added this part to the url when I initially tested it.I received the message:
XML-RPC server accepts POST requests only.Correctly.
I did some more tests,
I deactivated ALL plugins.
I disabled and uninstalled Jetpack.
Deletes all Jetpack tablesI tested it on the website https://jptools.wordpress.com/debug/
With the jetpack uninstalled, and all its entries removed from the database.
and I received this message:
After this, I installed and activated the jetpack, “but didn’t try to connect” and received this message:

After it was installed, I also tried accessing the link:
https://mysite.com/xmlrpc.phpAnd I received the message:
Page not found
The page you are looking for doesn’t exist, or it has been moved.
Please try searching using the form below.
(I get this message on all my sites, and on all of them I can log in to the jetpack, only on this one I can’t, so this is not the problem)After this, I tried AGAIN to log into the jetpack, and received the same error as before.
Look:
NOTE:
After, uninstall Jetpack, and delete all tables,
the error that appeared on the WordPress Diagnostics screen no longer appears.I really don’t know what’s causing this
I believe there is a blockage on the Jetpack servers.
On the WordPress diagnostics page I get this error:
Connection Token Health [JETPACK]
A healthy connection ensures that essential Jetpack services like statistics and security are provided to your WordPress site.
Error Blog token validation failed.
Reconnect to Jetpack.
Reconnect JetpackI click on reconnect, but it doesn’t help, I get the same error:
“An error has occurred. Please try again.”Hello.
I don’t know what happened, but today when I opened the sites, they were all working normally.
I tested on all browsers.
I checked the versions of everything, nothing was updated.
I just did a test run on a completely new website.
I used the “Twenty Twenty-One” theme and disabled all plugins. I just left the “Jetpack” activated.
I created a simple contact form with 4 fields: NAME, EMAIL, DATE, MESSAGE.
01 – When I open the form in the OPERA Browser, it displays all fields aligned correctly.
The date selection field also works, displaying the list of days to select.
02 – When I open the EDGE and FIREFOX browsers, the fields are misaligned, and the DATE field does not work, it does not display the list of days to select.
FIREFOX:

EDGE:

PAGE: https://plug.site-coder.com/contato/WORDPRESS VERSION: 6.6.2
JETPACK VERSION: 13.9.1
THEME VERSION: 2.3
OPERA VERSION: LVL 6 (core: 114.0.5282.
123)
EDGE VERSION: 130.0.2849.56
FIREFOX VERSION: 131.0.3Hi Emily.
Thank you for help wordpress!