私はwoocommerceを使用しています。 "https://woocommerce.com/products/print-invoices-packing-lists/"で入手可能な&梱包リスト&梱包リストを使用しています。WooCommerce - Transpose CartループをPDF請求書の注文ループ
function bbloomer_wc_discount_total() {
global $woocommerce;
$cart_subtotal = $woocommerce->cart->cart_contents;
$discount_total = 0;
foreach ($woocommerce->cart->cart_contents as $product_data) {
if ($product_data['variation_id'] > 0) {
$product = wc_get_product($product_data['variation_id']);
} else {
$product = wc_get_product($product_data['product_id']);
}
if (!empty($product->sale_price)) {
$discount = ($product->regular_price - $product->sale_price) * $product_data['quantity'];
$discount_total += $discount;
}
}
if ($discount_total > 0) {
echo '<tr class="cart-discount">
<th>'. __('Total Saving :', 'woocommerce') .'</th>
<td data-title=" '. __('Total Saving :', 'woocommerce') .' ">'
. wc_price($discount_total+$woocommerce->cart->discount_cart) .'</td>
</tr>';
}
}
add_action('woocommerce_cart_totals_after_order_total', 'bbloomer_wc_discount_total');
add_action('woocommerce_review_order_after_order_total', 'bbloomer_wc_discount_total');
woocommerceカートの内容に基づいて、この機能:表示woocommerceカート内の合計保存私はこのコードを使用し、完璧に動作してい&チェックアウトページの場合 。 私は印刷請求書によって生成されたHTML請求書での総貯蓄を表示するにはどうすればよいのようなプラグインのフックに(代わりにカートの内容の順序に基づいて)プラグイン&パッキングリスト:
add_action('wc_pip_after_header', 'bbloomer_wc_discount_total'); add_action('wc_pip_document_header', 'bbloomer_wc_discount_total');
ご回答いただきありがとうございます。 私のテンプレートのmy functions.phpにこのコードが追加され、Woocommerceピッププラグインを使用してHTML請求書ページに表示されます:致命的なエラー:ブール値のget_items()を呼び出すメンバー関数への呼び出し – Mani
こんにちは、ありがとうあなたの回答では、私は「WooCommerce Print Invoices&Packing Lists」を使用しています。これは私がダウンロードできるプラグインです:https://www.dropbox.com/s/7mmsuh7o0tjaa45/woocommerce-pip.zip?dl=0これはHooks refrenceです:https://docs.woocommerce.com/document/woocommerce-print-invoices-packing-lists-developer-reference/。どのようなコードを私のfunctions.phpに追加して、Html請求書に合計保存を表示することができますか?どうもありがとうございました ! – Mani
ありがとう、私のfunctions.phpにあなたのコードを追加することはできますか?私はあなたのコードをどのように使用できますか?ありがとうございました – Mani