[resolved] Cannot delete a product variation (8 posts)

  1. cryalex
    Posted 2 years ago #

    Using WooCommerce 2.6.1

    I cannot delete a product variation for a variable product: the record is still in the database after the ajax call.
    It seems the ajax call doesn't go through: putting error_log(print_r('remove_variation', true)); doesn't output anything (line 387 in class-wc-ajax.php).
    The action is added in the constructor of the class. The function public function remove_variation() is just not called.


  2. whereskarlo
    Posted 2 years ago #

    I am having this problem as well. I don't trust WooCommerce updates anymore, they are totally unstable. Sure it's open source and freemium but for those who pays these bugs cost serious money.

  3. cryalex
    Posted 2 years ago #

    Hi whereskarlo,

    The thing is I am a premium user of WooCommerce, after buying several add-ons. Even that didn't make them more reactive: the issue I posted on their forum is still under approval after 1 week!

    Being a WordPress developer, it is a real issue for my clients.

    Anyway, thank you for your input. I will continue trying to debug, and post here - please do the same if you find anything, that would be highly appreciated.

  4. whereskarlo
    Posted 2 years ago #

    Follow-up added

  5. whereskarlo
    Posted 2 years ago #

    It seems to be related to stock management on the variation level, when i removed that at least I could see my variations.

  6. cryalex
    Posted 2 years ago #

    WooCommerce subscriptions plugin is the cause.

  7. cryalex
    Posted 2 years ago #

    * Trash a variation, don't delete it permanently.
    * This is hooked to
    * Hijack WooCommerce's WC_AJAX::remove_variation() "Delete Variation" Trash a variation if it is a subscription variation via ajax function
    public static function remove_variations() {
    if ( isset( $_POST['variation_id'] ) ) { // removing single variation
    check_ajax_referer( 'delete-variation', 'security' );
    $variation_ids = array( $_POST['variation_id'] );
    } else { // removing multiple variations
    check_ajax_referer( 'delete-variations', 'security' );
    $variation_ids = (array) $_POST['variation_ids'];
    foreach ( $variation_ids as $variation_id ) {
    $variation_post = get_post( $variation_id );
    error_log(print_r($variation_post, ));
    if ( $variation_post && $variation_post->post_type == 'product_variation' ) {
    $variation_product = get_product( $variation_id );
    if ( $variation_product && $variation_product->is_type( 'subscription_variation' ) ) {
    wp_trash_post( $variation_id );

    remove && $variation_product->is_type( 'subscription_variation' )

  8. cryalex
    Posted 2 years ago #

    http://support.woothemes.com/requests/162693 should provide a patch, issue has been reported.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic