このワードプレスプラグインを持っているので、のフリーカムがダウンロードされたときに、「カートに追加」ボタンが隠れてダウンロードボタンが追加されます。woocommerce買収した商品機能をプラグインに追加する
しかし、私はこのプラグインにもう1つの機能を追加したいと思います。
私はwc_customer_bought_product($customer_email, $user_id, $the_product)
woocommerce機能を使用しようとしています。
しかし、それは動作していないようです。
//Returns true if the product/variation is free, downloadable and vitual.
//Added by me: OR return true too if product was bought
function dfd_is_virtual_free_download_product($post) {
global $woocommerce, $product;
$user_id = get_current_user_id();
$current_user= wp_get_current_user();
$customer_email = $current_user->email;
$current_product = $product->id;
if (empty($post)) return false;
$the_product = get_product($post);
if (!$the_product) {
//its not a product or product not found
return false;
}
$is_virtual = $the_product->is_virtual();
$price = $the_product->regular_price;
$sale_price = $the_product->sale_price;
$is_downloadable = $the_product->is_downloadable();
if ($sale_price == "0" || $sale_price == "0.00" || wc_customer_bought_product($customer_email, $user_id, $current_product)){
$price = $sale_price;
}
if($price == 0 && $is_virtual == 1 && $is_downloadable == 1){
return true;
}
return false;
}
ありがとうございましたが、うまくいきませんでした。私はまだ同じ結果を得ています。 –
私の回答を編集しました – barbocc