fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

set_variation_status

Shai Adler

Hi

Is set_variation_status() no longer supported?

Tanvirul Haque

Hi Shai,

Could you please explain a bit more? I am sorry that I could not get your query.

Thank you

Shai Adler

Hi

I think we were able to find the source if the issue in our code

Shai Adler

Hi Again

Last May we installed the plugin and to achieve this type of display we implemented a script that updates post status to “private” for out of stock variation using wp_update_post

But as of Saturday the script crashes at this line.

What could be the reason? do we still need to work this way?

You can see a product page here

Tanvirul Haque

Hi Shai,

Could you disable our swatches plugin and check is it working without our plugin or not?

Thank you

Shai Adler

Hi

 

When disabled there is no issue

This is where it fails, but only when changing post status to ‘private’

$postarr = array(
‘ID’ => $id,
‘post_status’ => $var_status
);

switch($var_status){
case ‘publish’:
wp_update_post($postarr);
break;
case ‘private’:
$available_variations = $product->get_available_variations();
if (sizeof($available_variations) > 1){
wp_update_post($postarr);
}
break;
}

Tanvirul Haque

Hello Shai Adler,

I am sorry, I could not get your query clearly. Could you explain what is the purpose of this code?

Please kindly do a plugin compatibility check by doing these steps to identify the error :

=> Deactivate all of your additional plugins except WooCommerce and WooCommerce Variation Swatches Plugin.

=> See if the problem persists. If the issue is resolved, you can tell which plugin might be the culprit of this error by activating your additional plugins one by one.

If the plugin conflict check doesn’t help, please record me reproducing your issue using a tool like this? https://www.useloom.com
It helps me to figure out the issue quickly and squash it immediately.

And don’t forget to add your site login details in the site login details area. I’ll check what’s happening there.

You can add new users by going to Users > Add New set the user and password for us, set the role to admin, and set the info here.

And add your site URL, login username, and password in the site login area. Follow this guideline: https://www.useloom.com/share/27c1f2ac633c4060b2da883d946107d7

Hope to hear from you soon!

Thank you

Shai Adler

Hi

You can see in the attached image how we use variation swatch (since May 2019)

We manage stock on variation level, and to properly display out of stock variations the “enabled” checkbox of a variation has to be unchecked once it is out of stock (this was your explanation at the time)

So we have a script that uses  wp_update_post to change the post status of such items to “private” but for some reason, since Saturday, it crashes at this point

When we disabled your plugin the script runs without a problem

If there is a different way to configure Variation swatches than we don’t need the script at all

Tanvirul Haque

Hi Shai Adler,

Ok, Could you please record me reproducing your issue using tool like this? https://www.useloom.com
It helps me to quickly figure out the issue and squash it immediately.

Thank you

Shai Adler

Hi

Meanwhile, after further analysis,  we were able to locate the source

for some reason woocommerce get_available_variations stopped working, so we made some change not to use it anymore and this resolved the issue

Thanks for your support

 

Shai

Tanvirul Haque

Hello Shai Adler,

Glad to hear that your issue is now resolved.

By the way, stay safe and take care of your family. Hopefully, Covid-19 outbreak will end up soon.

Thanks