Woocommerce - 无法删除产品变化 [英] Woocommerce - Cannot delete a product variation

查看:155
本文介绍了Woocommerce - 无法删除产品变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用WooCommerce 2.6.1

我无法删除产品差异化的变量产品:成绩仍然是在Ajax调用后的数据库。 看来Ajax调用不经过:把error_log中(的print_r('remove_variation',真));不输出任何东西(类-WC-ajax.php线387)。 该行动在类的构造函数中添加。该功能公共职能remove_variation()是不调用。

有没有人有同样的问题,并找到了一种方法,使工作?

解决方案

  / **
*垃圾的变化,不会永久删除。
*
*此钩到
*劫持WooCommerce的WC_AJAX :: remove_variation()删除变垃圾箱的变化,如果它是通过AJAX功能订阅变化
* /
公共静态函数remove_variations(){

如果(使用isset($ _ POST ['variation_id'])){//删除单个变异
error_log中(here3);

check_ajax_referer('删除-变化,安全);
$ variation_ids =阵列($ _ POST ['variation_id']);
error_log中($ _ POST ['variation_id']);

}其他{//删除多个变体
error_log中(here4);

check_ajax_referer('删除-变化,安全);
$ variation_ids =(阵列)$ _ POST ['variation_ids'];

}

的foreach($ variation_ids为$ variation_id){

$ variation_post = get_post($ variation_id);
error_log中(的print_r($ variation_post,));

如果($ variation_post&功放;&安培; $ variation_post-> post_type =='product_variation'){

$ variation_product = get_product($ variation_id);

如果($ variation_product&安培;&安培; $ variation_product-> is_type('subscription_variation')){
wp_trash_post($ variation_id);
}
}
}
死();
}
 

删除和放大器;&安培; $ variation_product-> is_type('subscription_variation),以解决未删除的变化的问题​​。 http://support.woothemes.com/requests/162693 应该提供一个补丁,问题一直报道

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.

Has anyone had the same issue, and found a way to make it work?

解决方案

/**
* 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' ) to solve the problem of un-deletable variations. http://support.woothemes.com/requests/162693 should provide a patch, issue has been reported.

这篇关于Woocommerce - 无法删除产品变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆