Manually run WooCommerce DB updater? - wordpress

On a WordPress site, we tried updating the WooCommerce Subscriptions plugin. It got part way, but then went inactive with this message:
WooCommerce Subscriptions is inactive. This version of Subscriptions requires WooCommerce 2.3 or newer. Please update WooCommerce to version 2.3 or newer
We're running WooCommerce 2.5.3 ... so already newer than 2.3.
Putting in a ticket with WooCommerce yields this message:
It looks like your WooCommerce database needs updating! Run the Database Updater in your WordPress admin. You can still submit the ticket below.
In the Woocommerce area there is a System Status report area. It shows:
Database
WC Database Version:
woocommerce_sessions ✔
That's a blank by WC Database Version.
Where is the WC Database version stored? Can we update that? Or manually run the DB Updater?
Thanks!

If you want to manually trigger a WooCommerce data update from the CMS, you can use this url:
wp-admin/admin.php?page=wc-settings&do_update_woocommerce=1

I tried the answers in this thread including the URL trick, but as of August 2019 they didn't seem to work and force the Woo update.
I have found the best way to force a WooCommerce update is via WP CLI and running the following command:
wp wc update

OK, actually, between the IT manager and me, I think we figured this out.
woocommerce-subscriptions.php checks the woocommerce_db_version option near the top of the file.
if ( ! is_woocommerce_active() || version_compare( get_option( 'woocommerce_db_version' ), '2.3', '<' ) ) {
add_action( 'admin_notices', 'WC_Subscriptions::woocommerce_inactive_notice' );
return;
}
get_option is a means of checking the wp_options table.
https://codex.wordpress.org/Function_Reference/get_option
And the woocommerce_db_version option was missing. So ... an insert statement got it behaving!
insert into wp_options (option_name, option_value, autoload) Values ('woocommerce_db_version', '2.5.3', 'yes');

I had the same problem. I checked the MySQL wp_options table and the Woocommerce version is called woocommerce_version, not woocommerce_db_version. So I changed:
if ( ! is_woocommerce_active() || version_compare( get_option( 'woocommerce_db_version' ), '2.3', '<' ) ) {
add_action( 'admin_notices', 'WC_Subscriptions::woocommerce_inactive_notice' );
return;
}
to the following:
if ( ! is_woocommerce_active() || version_compare( get_option( 'woocommerce_version' ), '2.3', '<' ) ) {
add_action( 'admin_notices', 'WC_Subscriptions::woocommerce_inactive_notice' );
return;
}
This solved the problem for me.
...JohnDF

Related

WooCommerce: Wrong Order Status Updated [duplicate]

When I try to programmatically update an order during a WP_Ajax hook. IE.
$order = wc_create_order($order_data);
$order->add_product( get_product( $membership_product_ids[0] ), 1 );
$order->set_address( $address, 'billing' );
$order->set_address( $address, 'shipping' );
$order_id = $order->id;
$order->update_status('completed');
I get the following errors:
Warning: DOMXPath::query(): Invalid expression in /wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php on line 299
Warning: DOMXPath::query(): Invalid expression in /wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php on line 299
Warning: Invalid argument supplied for foreach() in /wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php on line 302
Warning: DOMXPath::query(): Invalid expression in /wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php on line 299
Warning: DOMXPath::query(): Invalid expression in /wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php on line 299
Warning: Invalid argument supplied for foreach() in /wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php on line 302
If I remove that update_status function it does not errors.
The errors you are seeing are coming from the notification system. Your code appears able to update the status just fine. The Emogrify Class is used to generate inline CSS in an HTML template. You are likely seeing these errors because either A) you have overridden the "Completed order" email template and have created a parsing error or B) there is a WooCommerce add-on that is conflicting in some way with what you are doing.
To correct the issue, the first step will be to verify that it is the notification system by going into the admin under WooCommerce->Settings->Email->Completed order and un-checking the "Enable this email notification" box. Then save that and retest.
If your error goes away, then check your theme directory for an override of that template. It would be in <themename>/woocommerce/emails/customer-completed-order.php. If you have one, them rename it so it will not override anymore and reactivate the "Completed order" notification and see if using the default template corrects the issue.
If the issue persists with the default email notification template, then disable all of the WooCommerce add-ons you might have installed and retest. At this point, if it is working, you can re-enable them one-by-one until the issue returns. Once you have found the offending add-on, you will need to either adjust your code to allow for the add-on to not cause an issue or contact the add-on developer to address you issue.
I am not sure but you could try this trick using new WC_Order( $order_id );, to avoid the error:
// global $woocommerce; // in case of need…
$order = wc_create_order($order_data);
$order_id = $order->id; // moving this here
$_order = new WC_Order( $order_id ); // here
$_order->add_product( get_product( $membership_product_ids[0] ), 1 );
$_order->set_address( $address, 'billing' );
$_order->set_address( $address, 'shipping' );
$_order->update_status('completed');
I agree this is a strange issue.
As it is rare issue, you'd better manually open:
/wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php
and before line 299, insert these lines, and see what you will get:
var_dump($value);
var_dump($this->translateCssToXpath($value['selector']));
var_dump($xpath->query($this->translateCssToXpath($value['selector'])));
I figured this out by trying a range of different hooks, the issue was that the hook I was using to create the order happened before woocommerce initialized that what caused this issue.

Getting error call_user_func_array() expects parameter 1

Currently i install wordpress in local system with jupitex theme . But after add sales price value i am getting below error in "class-wp-hook.php" file.
"call_user_func_array() expects parameter 1 to be a valid callback, function 'jupiterx_wc_product_page_custom_sale_badge' not found or invalid function name in";
frondend working fine . but in elementor backend i am getting this error.
If anyone have idea then let me know what is exact issue.
I checked the theme code the issue is with the theme. Actually they are not passing any parameters in this filter
add_filter( 'woocommerce_sale_flash', 'jupiterx_wc_product_page_custom_sale_badge' );
But on woocommerce.php template they have added $output as function parameter which doesn't exist
function jupiterx_wc_product_page_custom_sale_badge( $output ) {
$output = str_replace( 'onsale', 'onsale jupiterx-sale-badge', $output );
return $output;
}
You can ask the theme developer to resolve the issue because even if i resolve the issue it will be gone once you update the theme.
Reinstall theme to the latest version & check as well

Parse error: syntax error, unexpected '[' in /wp-content/plugins/woocommerce-simply-order-export/main.php

Godaddy migrated my server and I have a site on wordpress / woocommerce that has the woocommerce-simply-order-export plugin. After the migration the site is generating this error:
Parse error: syntax error, unexpected '[' in /fakepath/wp-content/plugins/woocommerce-simply-order-export/main.php
The problem is when I install the site on my local server (with the same code), the website runs without problem.
I have tried renaming the plugin so that the site does not use it, but the server does not generate any response when compiling being empty, without any line of code when compiling the HTML
Any help about what may be happening?
Probably you have different versions of PHP. go to that file, and try replacing
$whatever = [];
with
$whatever = array();
[] notation for arrays isn't supported in older versions of PHP < 5.4
Also, if this is not the case, it could be that you need to deactivate/activate woocommerce as this plugin checks if Woocommerce is enabled.
From woocommerce-simply-order-export/main.php
if (
in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) )
&& ( -1 !== version_compare( get_plugin_data( WP_PLUGIN_DIR.'/woocommerce/woocommerce.php' )['Version'], '3.0.0' ) )
) { ...

Algolia search index fail

I have installed Algolia search plugin 1.7.0 in my WordPress site. I have also set it up and when I go into indexing the following shows up:
wp_remote_post() failed, indexing won't work. Checkout the logs for more details.
URL called: http://45.77.12.19/wp-admin/admin-post.php
Array
(
[headers] => Requests_Utility_CaseInsensitiveDictionary Object
(
[data:protected] => Array
(
[server] => nginx/1.12.0
[date] => Tue, 25 Apr 2017 02:23:09 GMT
[content-type] => text/html
[content-length] => 195
[www-authenticate] => Basic realm="Restricted"
)
)
401 Authorization Required
I have tried to add define( 'ALGOLIA_LOOPBACK_HTTP', true ) in the wp-config.php file and followed other steps explained:
https://community.algolia.com/wordpress/frequently-asked-questions.html
I am at a dead end and unsure of what to do now as the algolia indexing won't happen. How can I resolve this?
The Algolia plugin for WordPress needs to be able to access the admin interface over HTTP or HTTPS.
This is the way it creates a loop to deal with the pending tasks.
According to your logs: 'Basic realm="Restricted"', your admin seems protected behind Basic Auth (htpasswd).
To make the queue work in your case, you should provide the plugin with the credentials.
Here is what you need to add to the functions.php file of your active theme.
<?php
// In your current active theme functions.php.
define( 'MY_USERNAME', 'test' );
define( 'MY_PASSWORD', 'test' );
function custom_loopback_request_args( array $request_args ) {
$request_args['headers']['Authorization'] = 'Basic ' . base64_encode( MY_USERNAME . ':' . MY_PASSWORD );
return $request_args;
}
add_filter( 'algolia_loopback_request_args', 'custom_loopback_request_args' );
Note that this will probably change in the upcoming weeks as we are working towards removing that logic.

How to access magento Session in wordpress?

I have read many questions similar to this,
but found no answer
i have to display customer name and cart items in wordpress blog
I have installed Mage Enabler .but always it is showing Invalid Url.
what can be valid url for local pc?
so i also have done like,
require_once ("../app/Mage.php");
umask(0);
Mage::app();
Mage::getSingleton("core/session", array('name' => 'frontend'));
$session = Mage::getSingleton("customer/session");
if($session->isLoggedIn())
{echo "YES";}
else {echo "NO";}
I always get "NO" .. :(
Can anyone please help me how to access magento session in wordpress
Instead of:
$session = Mage::getSingleton("customer/session");
Try:
$session=Mage::getSingleton('customer/session', array('name'=>'frontend') );
Good luck

Resources