function add_cart() { $info = get_info_item($_POST['item_code']); if (!isset($_COOKIE['products'])) { $term = get_the_terms($info[0]->ID, 'provider'); $image = get_field('pv_images', $term[0]); $item = array('0' => array('id' => $info[0]->ID, 'icon' => $image["url"], 'name' => $info[0]->post_title, 'price' => get_field('price', $info[0]->ID))); $prod = json_encode($item, true); setcookie('products', $prod, time() + 2678400, COOKIEPATH, COOKIE_DOMAIN, false); } else { $prod = $_COOKIE['products']; $prod = stripslashes($prod); $prod = json_decode($prod, true); $key = findKey($prod, 'id', $info[0]->ID); if ($key === null) { $term = get_the_terms($info[0]->ID, 'provider'); $image = get_field('pv_images', $term[0]); $item = array('id' => $info[0]->ID, 'icon' => $image["url"], 'name' => $info[0]->post_title, 'price' => get_field('price', $info[0]->ID)); $prod[] = $item; $prod = json_encode($prod); setcookie('products', $prod, time() + 2678400, COOKIEPATH, COOKIE_DOMAIN, false); } else { $prod = json_encode(array("error" => 1)); } } header('Content-Type: application/json'); echo $prod; exit; }
$term = get_the_terms($value->product_id, 'provider'); $image = get_field('pv_images', $term[0]); ?> <div class="w-col w-col-3"><img src="<?php echo $image["url"]; ?> "> </div> <div class="w-col w-col-9"> <div class="title-feature-num"><?php echo $value->product_name; ?> </div> <div class="dtl-feature-num"> <?php $content = get_info_item($value->product_id); ?> <?php echo $content[0]->post_content; ?> </div> </div> </div> </div> </div> <div class="w-col w-col-2 col-con-mid"> <div class="text-th">1</div> </div> <div class="w-col w-col-2 col-con-mid"> <div class="text-th"><?php