我正在使用此功能检查我的woocommerce上的某些产品是否在购物车中.这适用于我的localhost但是给了我一个:
在写上下文中不能使用函数返回值
在服务器上.
function product_is_in_the_cart() {
$ids = array( '139, 358, 359, 360' );
$cart_ids = array();
// Find each product in the cart and add it to the $cart_ids array
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
$cart_product = $values['data'];
$cart_ids[] = $cart_product->id;
}
// Si uno de los productos introducidos en el array esta, devuelve false
if ( ! empty( array_intersect( $ids, $cart_ids ) ) ) {
return true;
} else {
return false;
}}
Run Code Online (Sandbox Code Playgroud)
我试图找到其他方法来做到这一点,但我找不到我的问题的答案,我认为是因为空()但我怎么能在其他方式做到这一点?
我按照这个旧答案的步骤.主要问题是RKObjectLoaderDelegate已被删除,我无法找到任何适合我的替代方案.我试图用邮件/密码连接到服务器发送邮件请求给json.此外,我将使用json从数据库中获取数据,我测试它的工作正常.有人可以帮我这个吗?我正在使用RESTkit
//Autentificacion
NSURL* url = [[NSURL alloc]initWithString:@"http://myurl.com/tokens.json"];
RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:url];
objectManager = [RKObjectManager managerWithBaseURL:url];
Run Code Online (Sandbox Code Playgroud)
就像我之前说的,我试图做一个JSON登录帖子,但不同的例子对我不起作用,我正在寻找一些简单的方法来做它在restkit 0.20.我知道怎么做GET而不是POST.
我使用 gmail-api 从我的数据库向不同的联系人发送电子邮件。当我发送消息时,样式不起作用,因为发生这种情况,因为等号“=”丢失了。
例如,把这个放在消息中
<img src="mysite.com/image.jpg"/>
Run Code Online (Sandbox Code Playgroud)
但相反,我把这个放在了=
<img src"mysite.com/image.jpg"/>
Run Code Online (Sandbox Code Playgroud)
这是我为消息制作字符串的函数的一部分
$strSubject = $data['subject'];
//$strRawMessage = "From: myAddress<pblanco@mysite.com>\r\n";
$strRawMessage = "From: <".$data['from'].">\r\n"; //email consultor
//$strRawMessage .= "To: toAddress <pblanco@mysite.com>\r\n";
$strRawMessage .= "To: <".$data['to'].">\r\n"; //email destinatario
$strRawMessage .= 'Subject: =?utf-8?B?' . base64_encode($strSubject) . "?=\r\n"; //asunto
$strRawMessage .= "MIME-Version: 1.0\r\n";
$strRawMessage .= "Content-Type: text/html; charset=utf-8\r\n";
$strRawMessage .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n\r\n";
$strRawMessage .= $data['message']."\r\n"; //mensaje
// The message needs to be encoded in Base64URL
$msg = $this->createMessage($strRawMessage);
Run Code Online (Sandbox Code Playgroud)
在这里我对消息进行编码
public function createMessage($string){
//$mime = …Run Code Online (Sandbox Code Playgroud) php ×2
encoding ×1
gmail-api ×1
google-api ×1
json ×1
php-5.3 ×1
restkit ×1
restkit-0.20 ×1
woocommerce ×1
wordpress ×1