Mar*_*rek 1 php pdf wordpress woocommerce tax
使用 WooCommerce 和WooCommerce PDF 发票和装箱单插件时,我遇到了问题。生成 PDF 发票时,会显示两次税费:

我需要删除这个重复项,使其看起来像这样:
我知道有一些高级插件具有大量功能,但我不能再购买高级插件了,因为在其他插件上投入了太多。
所以我需要做一点改变。我找不到任何解决方案。
有人能帮我吗?
\n\n\n@update \xe2\x80\x94工作且功能齐全
\n
是的,您可以编辑默认模板以满足您的需求,而无需购买高级模板,但您需要在活动的子主题或主题内(如果它尚不存在):
\n\nwoocommerceplugins>>复制woocommerce-pdf-invoices-packing-slipstemplatespdf到这个新创建的文件woocommerce夹。pdf文件夹中,simple使用类似(或任何您想要的)的名称重命名子文件夹。custom1 custom1pdf 模板,进入管理后端:WooCommerce>> PDF InvoicesTemplate (选项卡),选择custom1* 并 **保存。现在,在您的活动主题中>>>woocommerce您可以自定义包含pdf的custom1模板文件以满足您的需求。
\n\n\n获取双重征税显示的簧片:问题出在
\nforeach循环中。
1. 检索 VAT 重复值的 slug(键名称):
\n正如您所说,在该循环中添加一些内容会使其在每个显示的元素中重现。
在这里,我们将key在相应的后面显示名称或别名values:
<?php foreach( $wpo_wcpdf->get_woocommerce_totals() as $key => $total ) : ?>\n <tr class="<?php echo $key; ?>">\n <td class="no-borders"></td>\n <!-- we display the index value in here, below. -->\n <th class="description"><?php echo $total[\'label\'] . " (The key is \'" . $key . "\') " ;?></th> \n <td class="price"><span class="totals-price"><?php echo $total[\'value\']; ?></span></td>\n </tr>\n<?php endforeach; ?>\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\n现在,如果您生成 pdf 发票,您将在每一行获得不同的
\n$key名称或名称(就在相应的值之后)。
2.在循环中添加条件以避免显示重复:
现在您知道了重复元素的key名称if(),您可以使用其中的语句对循环进行操作。您必须替换为重复项目的\'the_key_name\'真实key姓名:
<?php foreach( $wpo_wcpdf->get_woocommerce_totals() as $key => $total ) :\n // As long as $key is NOT \'the_key_name\' the item line is displayed\n if ($key != \'the_key_name\'){ ?>\n <tr class="<?php echo $key; ?>">\n <td class="no-borders"></td>\n <th class="description"><?php echo $total[\'label\']</th> \n <td class="price"><span class="totals-price"><?php echo $total[\'value\']; ?></span></td>\n </tr>\n <?php }\nendforeach; ?>\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\n现在,如果您生成 pdf 发票,重复的项目已完全从其中消失。
\n
等 voil\xc3\xa0\xe2\x80\xa6 Bon app\xc3\xa9tit :)
\n| 归档时间: |
|
| 查看次数: |
8427 次 |
| 最近记录: |