Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在WooCommerce单一产品页面上用treshold显示每月分期付款价格_Php_Wordpress_Woocommerce_Product_Price - Fatal编程技术网

Php 在WooCommerce单一产品页面上用treshold显示每月分期付款价格

Php 在WooCommerce单一产品页面上用treshold显示每月分期付款价格,php,wordpress,woocommerce,product,price,Php,Wordpress,Woocommerce,Product,Price,我在我们的WordPress/WooCommerce系统上实现这一点时遇到了问题 我们设计了一种方法,用户可以在产品页面上看到每月分期付款的价格 add_action('woocommerce_前加_至_cart_表单','每月价格',5); 每月功能价格(){ 全球$产品; $price=$product->get_regular_price(); $months1=3; $months2=6; $months3=12; $months4=24; $price_per_month1=($pri

我在我们的WordPress/WooCommerce系统上实现这一点时遇到了问题

我们设计了一种方法,用户可以在产品页面上看到每月分期付款的价格

add_action('woocommerce_前加_至_cart_表单','每月价格',5);
每月功能价格(){
全球$产品;
$price=$product->get_regular_price();
$months1=3;
$months2=6;
$months3=12;
$months4=24;
$price_per_month1=($price/$months1);
$price_per_month2=($price/$months2);
$price_/月3=($price/$months3);
$price_/月4=($price/$months4);
回声“
插入标题
仅从以下地址支付:
整轮($price/3,2,整轮半个月)
整轮($price/6,2,整轮半个月)
整轮($price/12,2,整轮半个月)
整轮($price/24,2,整轮半个月)。”
插入页脚
"; }
我们想要的是,如果原始价格低于3000,代码就不运行。我应该为此使用什么代码?我尝试了一个基本的if/else程序,但没有成功


我也希望得到关于这段代码的反馈。我们正在寻找类似的东西,但这是我们看到的唯一可用的插件。表格在指定范围内每月自动计算,因此我决定自己编码。

而不是使用多个
if/else
条件,您可以使用and和a循环

对于阈值,您可以添加一个简单的
if
条件

所以你得到:

每月功能价格(){
全球$产品;
//是一种WC产品
如果(是($product,'WC\U product')){
//仅适用于“简单”产品
如果($product->是_类型('simple')){
//设定月份
$months=数组(3,6,12,24);
//特雷肖尔德
$treshold=3000;
//获得价格
$price=$product->get_regular_price();
//价格大于或等于特氏原价
如果($price>=$treshold){
回声';
回声“插入标题”;
回声“仅从支付:

”; //迭代数组 foreach(月份为$month){ 回音“PHP”.round($price/$month,2,PHP_round\u HALF\u UP)。'for'$month.'months

”; } 回显“插入页脚”

; 回声'; } } } } 添加行动(“添加到购物车表单之前的woocommerce”、“每月价格”,5);
请不要含糊其辞地提到您“尝试了一些东西”,而是向我们展示您实际尝试了什么,以及正确的问题描述。()那里已经有了价格,那么如果($price>=3000){…},那么将那里剩下的代码包装到
中有什么问题呢…?