当我将woomerce-2.3.13版本更改为woomerce-2.4.6时,出现此错误:
woomerce:SyntaxError:意外的令牌<
据我所知,当我在php文件上添加script标记(

最佳答案

在处理woomerce签出时,它要求网关返回一个数组(然后将其转换为JSON),告诉签出是否成功。从v1开始就这样了。
在2.4+中,这变得更加严格,因为响应必须是有效的JSON。响应中的任何其他内容(如HTML、notices或whitespace)都将使此JSON无效,您可能会看到以下行中的错误:

SyntaxError: Unexpected token

在这篇博客文章中查看调试方法https://mikejolley.com/2015/11/12/debugging-unexpected-token-in-woocommerce-2-4/
我按照博客文章上的所有说明操作,禁用了所有插件,结果发现JSON响应返回了一个错误,而不是格式正确的JSON。我的回答是:
<br />
<b>Notice</b>:  Use of undefined constant CURLOPT_SSLVERSION -     assumed 'CURLOPT_SSLVERSION' in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php</b> on line <b>57</b><br />
<br />
<b>Notice</b>:  Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php</b> on line <b>57</b><br />
<br />
<b>Notice</b>:  Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php</b> on line <b>57</b><br />
<br />
<b>Notice</b>:  Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php</b> on line <b>57</b><br />
<br />
<b>Notice</b>:  Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php</b> on line <b>57</b><br />
<br />
<b>Notice</b>:  Use of undefined constant CURLOPT_HTTPHEADER - assumed 'CURLOPT_HTTPHEADER' in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php</b> on line <b>57</b><br />
<br />
<b>Notice</b>:  Use of undefined constant CURLOPT_SSL_VERIFYHOST - assumed 'CURLOPT_SSL_VERIFYHOST' in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php</b> on line <b>57</b><br />
<br />
<b>Notice</b>:  Use of undefined constant CURLOPT_SSL_VERIFYPEER - assumed 'CURLOPT_SSL_VERIFYPEER' in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php</b> on line <b>57</b><br />
<br />
<b>Notice</b>:  Use of undefined constant CURLOPT_SSL_CIPHER_LIST - assumed 'CURLOPT_SSL_CIPHER_LIST' in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php</b> on line <b>57</b><br />
<br />
<b>Fatal error</b>:  Call to undefined function PayPal\Core\curl_version() in <b>/var/www/html/wp-content/plugins/woocommerce-product-vendors/includes/gateways/paypal-php-sdk/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConfig.php</b> on line <b>65</b><br />

在我的例子中,这是一个问题与woomerce PayPal Pro支付网关和woomerce产品供应商,因为cURL不是默认安装在我的DigitalOcean服务器上。对于Woomcommerce产品供应商来说,每次客户下订单,供应商都会获得PayPal批量支付的佣金。为了让PayPal批量支付生效,您必须确保在PayPal帐户上启用批量支付,并确保服务器上安装了cURL。
我一安装卷发器,就起作用了。下面是如何在DigitalOcean上安装cURLhttps://www.digitalocean.com/community/questions/curl-is-not-installed-in-your-php-installation
希望这能帮助其他人。

10-01 10:29