WooCommerce可变产品,如何获得所选产品的正确价格?

时间:2019-03-17 09:49:32

标签: php wordpress woocommerce

我需要帮助来解决我的代码问题。

我尝试添加带有钩子<?php if(isset($_POST['email'])) { $name =$_POST["name"]; $from =$_POST["email"]; $phone=$_POST["phone"]; $comment=$_POST["comment"]; $subject=$_POST["subject"]; // Email Receiver Address $receiver="info@1230.co"; $subject="Website Contact Form"; $message = " <html> <head> <title>Website Contact Form</title> </head> <body> <table width='50%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td colspan='2' align='center' valign='top'><img style=' margin-top: 15px; ' src='img/logo-forms.png' ></td> </tr> <tr> <td width='50%' align='right'>&nbsp;</td> <td align='left'>&nbsp;</td> </tr> <tr> <td align='right' valign='top' style='border-top:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 5px 7px 0;'>Name:</td> <td align='left' valign='top' style='border-top:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 0 7px 5px;'>".$name."</td> </tr> <tr> <td align='right' valign='top' style='border-top:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 5px 7px 0;'>Email:</td> <td align='left' valign='top' style='border-top:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 0 7px 5px;'>".$from."</td> </tr> <tr> <td align='right' valign='top' style='border-top:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 5px 7px 0;'>Phone:</td> <td align='left' valign='top' style='border-top:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 0 7px 5px;'>".$phone."</td> </tr> <tr> <td align='right' valign='top' style='border-top:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 5px 7px 0;'>Subject:</td> <td align='left' valign='top' style='border-top:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 0 7px 5px;'>".$subject."</td> </tr> <tr> <td align='right' valign='top' style='border-top:1px solid #dfdfdf; border-bottom:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 5px 7px 0;'>Message:</td> <td align='left' valign='top' style='border-top:1px solid #dfdfdf; border-bottom:1px solid #dfdfdf; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000; padding:7px 0 7px 5px;'>".nl2br($comment)."</td> </tr> </table> </body> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; // More headers $headers .= 'From: <'.$from.'>' . "\r\n"; if(mail($receiver,$subject,$message,$headers)) { //Success Message echo "The message has been sent!"; } else { //Fail Message echo "The message could not been sent!"; } } ?> 的自定义价格。该功能在简单产品上很好。但是,当我使用可变产品进行测试并选择属性时,WooCommerce无法给出所选属性的正确价格。

这是我的代码:

woocommerce_get_price_html

代码显示类似this

的输出

我想在标题底部显示价格范围,并在选择选项的底部显示所选属性的正确价格。

我花了4个多小时来修复此错误,但仍然遇到问题。 对解决此错误有帮助吗?谢谢

0 个答案:

没有答案