• Resolved cryalex

    (@cryalex)


    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.

    https://wordpress.org/plugins/woocommerce/

Viewing 7 replies - 1 through 7 (of 7 total)
  • hoy

    (@whereskarlo)

    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.

    Thread Starter cryalex

    (@cryalex)

    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.

    hoy

    (@whereskarlo)

    Follow-up added

    hoy

    (@whereskarlo)

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

    Thread Starter cryalex

    (@cryalex)

    WooCommerce subscriptions plugin is the cause.

    Thread Starter cryalex

    (@cryalex)

    /**
    * 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
    error_log("here3");
    
    check_ajax_referer( 'delete-variation', 'security' );
    $variation_ids = array( $_POST['variation_id'] );
    error_log($_POST['variation_id']);
    
    } else { // removing multiple variations
    error_log("here4");
    
    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 );
    }
    }
    }
    die();
    }

    remove && $variation_product->is_type( ‘subscription_variation’ )

    Thread Starter cryalex

    (@cryalex)

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Cannot delete a product variation’ is closed to new replies.