/**
* 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();
}
除去& & $ variation_product-> is_type( 'subscription_variation')來解決未刪除的變化的問題。 http://support.woothemes.com/requests/162693應提供補丁,已報告問題。
看來WooCommerce訂閱插件是原因。 – user3480616
我會建議將此提交給Woo支持,以便他們可以修復它。 – helgatheviking
完成了。這個支持一週沒有反應,我在這裏發佈後,他們神奇地醒了過來。儘管如此,我最終還是在調試自己,因爲他們對我的結論表示懷疑。所以我指出了問題所在(請參閱下面的答案),並且現在努力完成了,他們應該能夠提供補丁。注意:這是一個商業插件,我不應該被迫做出貢獻。 – user3480616