本文整理汇总了PHP中wc_setcookie函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_setcookie函数的具体用法?PHP wc_setcookie怎么用?PHP wc_setcookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_setcookie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wc_track_product_view
/**
* Track product views.
*/
function wc_track_product_view()
{
if (!is_singular('product') || !is_active_widget(false, false, 'woocommerce_recently_viewed_products', true)) {
return;
}
global $post;
if (empty($_COOKIE['woocommerce_recently_viewed'])) {
$viewed_products = array();
} else {
$viewed_products = (array) explode('|', $_COOKIE['woocommerce_recently_viewed']);
}
if (!in_array($post->ID, $viewed_products)) {
$viewed_products[] = $post->ID;
}
if (sizeof($viewed_products) > 15) {
array_shift($viewed_products);
}
// Store for session only
wc_setcookie('woocommerce_recently_viewed', implode('|', $viewed_products));
}
开发者ID:jameztrue,项目名称:woocommerce,代码行数:23,代码来源:wc-product-functions.php
示例2: as_add_cookie
function as_add_cookie($name, $value, $expire = 0)
{
if ($expire == 0) {
$expire = time() + 60 * 60 * 24 * 30;
}
$value = json_encode(stripslashes_deep($value));
$_COOKIE[WISHLIST_COOKIE_NAME] = $value;
wc_setcookie($name, $value, $expire, false);
}
开发者ID:bibiangel1989,项目名称:vespatour,代码行数:9,代码来源:as-main-lib.php
示例3: set_customer_session_cookie
/**
* Sets the session cookie on-demand (usually after adding an item to the cart).
*
* Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
*
* Warning: Cookies will only be set if this is called before the headers are sent.
*/
public function set_customer_session_cookie($set)
{
if ($set) {
// Set/renew our cookie
$to_hash = $this->_customer_id . $this->_session_expiration;
$cookie_hash = hash_hmac('md5', $to_hash, wp_hash($to_hash));
$cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
// Set the cookie
wc_setcookie($this->_cookie, $cookie_value, $this->_session_expiration);
}
}
开发者ID:Joaquinsemp,项目名称:patriestausado,代码行数:18,代码来源:class-wc-session-handler.php
示例4: set_customer_session_cookie
/**
* Sets the session cookie on-demand (usually after adding an item to the cart).
*
* Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
*
* Warning: Cookies will only be set if this is called before the headers are sent.
*/
public function set_customer_session_cookie($set)
{
if ($set) {
// Set/renew our cookie
$to_hash = $this->_customer_id . $this->_session_expiration;
$cookie_hash = hash_hmac('md5', $to_hash, wp_hash($to_hash));
$cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
$this->_has_cookie = true;
// Set the cookie
wc_setcookie($this->_cookie, $cookie_value, $this->_session_expiration, apply_filters('wc_session_use_secure_cookie', false));
}
}
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:19,代码来源:class-wc-session-handler.php
示例5: destroy_session
/**
* Destroy all session data.
*/
public function destroy_session()
{
// Clear cookie
wc_setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, apply_filters('wc_session_use_secure_cookie', false));
$this->delete_session($this->_customer_id);
// Clear cart
wc_empty_cart();
// Clear data
$this->_data = array();
$this->_dirty = false;
$this->_customer_id = $this->generate_customer_id();
}
开发者ID:jgcopple,项目名称:drgaryschwantz,代码行数:15,代码来源:class-wc-session-handler.php
示例6: set_cart_cookies
/**
* Set cart hash cookie and items in cart.
*
* @access private
* @param bool $set (default: true)
*/
private function set_cart_cookies($set = true)
{
if ($set) {
wc_setcookie('woocommerce_items_in_cart', 1);
wc_setcookie('woocommerce_cart_hash', md5(json_encode($this->get_cart_for_session())));
} elseif (isset($_COOKIE['woocommerce_items_in_cart'])) {
wc_setcookie('woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS);
wc_setcookie('woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS);
}
do_action('woocommerce_set_cart_cookies', $set);
}
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:17,代码来源:class-wc-cart.php
示例7: yith_setcookie
/**
* Create a cookie.
*
* @param string $name
* @param mixed $value
* @return bool
* @since 1.0.0
*/
function yith_setcookie($name, $value = array(), $time = null)
{
$time = $time != null ? $time : time() + apply_filters('yith_wcwl_cookie_expiration', 60 * 60 * 24 * 30);
//$value = maybe_serialize( stripslashes_deep( $value ) );
$value = json_encode(stripslashes_deep($value));
$expiration = apply_filters('yith_wcwl_cookie_expiration_time', $time);
// Default 30 days
$_COOKIE[$name] = $value;
wc_setcookie($name, $value, $expiration, false);
}
开发者ID:websideas,项目名称:Mondova,代码行数:18,代码来源:functions.yith-wcwl.php
示例8: so_get_customer_id
/**
* function to get unique id for user, create new if not already set
*/
static function so_get_customer_id()
{
global $sa_smart_offers;
$so_guest_id = !empty($_COOKIE['so_guest_id']) ? $_COOKIE['so_guest_id'] : null;
if (empty($so_guest_id)) {
$so_guest_id = $sa_smart_offers->global_wc()->session->get_customer_id();
wc_setcookie('so_guest_id', $so_guest_id, time() + 60 * 60 * 48, apply_filters('wc_session_use_secure_cookie', false));
}
return $so_guest_id;
}
开发者ID:WP-Panda,项目名称:allergenics,代码行数:13,代码来源:class-so-session-handler.php
示例9: set_rqa_cookies
/**
* Set hash cookie and items in raq.
*
* @since 1.0.0
* @access private
* @return void
* @author Emanuela Castorina
*/
private function set_rqa_cookies($set = true)
{
if ($set) {
wc_setcookie('yith_ywraq_items_in_raq', 1);
wc_setcookie('yith_ywraq_hash', md5(json_encode($this->raq_content)));
} elseif (isset($_COOKIE['yith_ywraq_items_in_raq'])) {
wc_setcookie('yith_ywraq_items_in_raq', 0, time() - HOUR_IN_SECONDS);
wc_setcookie('yith_ywraq_hash', '', time() - HOUR_IN_SECONDS);
}
do_action('yith_ywraq_set_rqa_cookies', $set);
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:19,代码来源:class.yith-request-quote.php
示例10: create_temp_user_cookie
/**
* Create a cookie on page with temp user id
* @return void
*/
public function create_temp_user_cookie()
{
if (!isset($_COOKIE['graphflow'])) {
if (!is_user_logged_in()) {
$user_id = wp_generate_password(32, false);
wc_setcookie('graphflow', $user_id, time() + 60 * 60 * 24 * 365);
$_REQUEST['graphflow_req_id'] = $user_id;
}
}
}
开发者ID:asafmaoz1234,项目名称:woocommerce-recommendations-by-graphflow,代码行数:14,代码来源:class-wc-graphflow.php
示例11: fz_visacheckout_load_from_callid
function fz_visacheckout_load_from_callid($fields)
{
$payment_gateways = WC()->payment_gateways->get_available_payment_gateways();
if (!isset($payment_gateways['fatzebra_visacheckout'])) {
return $fields;
}
$gw = $payment_gateways['fatzebra_visacheckout'];
$callid = isset($_COOKIE['fatzebra_visacheckout_callid']) ? $_COOKIE['fatzebra_visacheckout_callid'] : null;
if (empty($callid)) {
return $fields;
}
$token_result = $gw->tokenize_card(array("callid" => $callid));
if (is_wp_error($token_result)) {
// Tokenization error - for now lets return the fields with no manipulation..
// error_log
return $fields;
}
// Arghhh!
$wallet = $token_result['wallet'];
// Store the wallet data in a session. It is important to remove this upon successful checkout....
WC()->session->set('visa_wallet_first_name', $wallet->name->first);
WC()->session->set('visa_wallet_last_name', $wallet->name->last);
WC()->session->set('visa_wallet_address_1', $wallet->address->line_1);
WC()->session->set('visa_wallet_address_2', $wallet->address->line_2);
WC()->session->set('visa_wallet_city', $wallet->address->city);
WC()->session->set('visa_wallet_state', $wallet->address->state);
WC()->session->set('visa_wallet_postcode', $wallet->address->postcode);
WC()->session->set('visa_wallet_phone', $wallet->address->phone);
WC()->session->set('visa_wallet_email', $wallet->email);
WC()->session->set('visa_wallet_callid', $callid);
WC()->session->set('visa_wallet_token', $token_result['card_token']);
WC()->session->set('visa_wallet_masked_number', $token_result['card_number']);
wc_setcookie('fatzebra_visacheckout_callid', null, time() - 3600);
return $fields;
}
开发者ID:atomixdesign,项目名称:FatZebra-WooCommerce,代码行数:35,代码来源:class-wc-fatzebra-visacheckout.php
示例12: checkfermopoint_book_fieldupdate
public function checkfermopoint_book_fieldupdate($order_id, $posted)
{
if (isset($_COOKIE['fermopoint_session'])) {
$fermopoint_session = stripslashes($_COOKIE['fermopoint_session']);
$fermopoint_session = json_decode($fermopoint_session);
$url = $fermopoint_session->Links->GetBookingUrl;
$url_approval = $fermopoint_session->Links->ApprovalUrl;
$url_reject = $fermopoint_session->Links->RejectionUrl;
$ch = curl_init();
$connect_timeout = 5;
//sec
//$request = $_POST["request"];
// $url = $_POST["urlfermo"];
$base_time_limit = (int) ini_get('max_execution_time');
if ($base_time_limit < 0) {
$base_time_limit = 0;
}
$time_limit = $base_time_limit - $connect_timeout - 2;
if ($time_limit <= 0) {
$time_limit = 20;
//default
}
$httpHeader = array("Content-Type: application/json; charset=\"utf-8\"");
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $time_limit);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
if (!curl_errno($ch)) {
$ret = json_decode($result);
update_post_meta($order_id, '_shipping_first_name', $ret->Nickname);
update_post_meta($order_id, '_shipping_last_name', " - " . $ret->PointName . " - Fermo!Point");
update_post_meta($order_id, '_shipping_company', "");
update_post_meta($order_id, '_shipping_address_1', $ret->Address->Street);
update_post_meta($order_id, '_shipping_address_2', $ret->Address->Extended);
update_post_meta($order_id, '_shipping_postcode', $ret->Address->PostalCode);
update_post_meta($order_id, '_shipping_city', $ret->Address->Locality . " " . $ret->Address->City);
update_post_meta($order_id, '_shipping_state', $ret->Address->District);
update_post_meta($order_id, '_shipping_postcode', $ret->Address->PostalCode);
update_post_meta($order_id, '_shipping_country', "IT");
//var_dump($ret);
update_post_meta($order_id, '_shipping_ticketId-fermopoint', $ret->TicketId);
update_post_meta($order_id, '_shipping_urlticket-fermopoint', $ret->BookingUrl);
update_post_meta($order_id, '_shipping_statebook-fermopoint', $ret->State);
update_post_meta($order_id, '_shipping_statenote-fermopoint', $ret->Notes);
update_post_meta($order_id, '_shipping_approvalUrl-fermopoint', $url_approval);
update_post_meta($order_id, '_shipping_rejectUrl-fermopoint', $url_reject);
}
curl_close($ch);
wc_setcookie('fermopoint_session', "", strtotime('-1 day'));
wc_setcookie('fermopoint_invio', "", strtotime('-1 day'));
}
}
开发者ID:ssimo84,项目名称:fermopoint-woocommerce,代码行数:55,代码来源:class-fermopoint-public.php
示例13: process_package
/**
* Purchase a job package
* @param int|string $package_id
* @param int $job_id
* @return bool Did it work or not?
*/
private static function process_package($package_id, $is_user_package, $job_id)
{
if ($is_user_package) {
$user_package = wc_paid_listings_get_user_package($package_id);
$package = wc_get_product($user_package->get_product_id());
// Give job the package attributes
update_post_meta($job_id, '_job_duration', $user_package->get_duration());
update_post_meta($job_id, '_featured', $user_package->is_featured() ? 1 : 0);
update_post_meta($job_id, '_package_id', $user_package->get_product_id());
update_post_meta($job_id, '_user_package_id', $package_id);
if ($package && 'listing' === $package->package_subscription_type) {
update_post_meta($job_id, '_job_expires', '');
// Never expire automatically
}
// Approve the job
if (in_array(get_post_status($job_id), array('pending_payment', 'expired'))) {
wc_paid_listings_approve_job_listing_with_package($job_id, get_current_user_id(), $package_id);
}
do_action('wcpl_process_package_for_job_listing', $package_id, $is_user_package, $job_id);
return true;
} elseif ($package_id) {
$package = wc_get_product($package_id);
// Give job the package attributes
update_post_meta($job_id, '_job_duration', $package->get_duration());
update_post_meta($job_id, '_featured', $package->is_featured() ? 1 : 0);
update_post_meta($job_id, '_package_id', $package_id);
if ('listing' === $package->package_subscription_type) {
update_post_meta($job_id, '_job_expires', '');
// Never expire automatically
}
// Add package to the cart
WC()->cart->add_to_cart($package_id, 1, '', '', array('job_id' => $job_id));
woocommerce_add_to_cart_message($package_id);
// Clear cookie
wc_setcookie('chosen_package_id', '', time() - HOUR_IN_SECONDS);
wc_setcookie('chosen_package_is_user_package', '', time() - HOUR_IN_SECONDS);
do_action('wcpl_process_package_for_job_listing', $package_id, $is_user_package, $job_id);
// Redirect to checkout page
wp_redirect(get_permalink(woocommerce_get_page_id('checkout')));
exit;
}
}
开发者ID:sabdev1,项目名称:sabstaff,代码行数:48,代码来源:class-wc-paid-listings-submit-job-form.php
示例14: destroy_session
/**
* Destroy all session data
*/
public function destroy_session()
{
// Clear cookie
wc_setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, apply_filters('yith_ywraq_session_use_secure_cookie', false));
// Delete session
$session_option = '_yith_ywraq_session_' . $this->_customer_id;
$session_expiry_option = '_yith_ywraq_session_expires_' . $this->_customer_id;
delete_option($session_option);
delete_option($session_expiry_option);
// Clear data
$this->_data = array();
$this->_dirty = false;
$this->_customer_id = $this->generate_customer_id();
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:17,代码来源:class.yith-ywraq-session.php
示例15: repair_woocommerce_ajax_add_to_cart_guest
function repair_woocommerce_ajax_add_to_cart_guest()
{
if (defined('DOING_AJAX')) {
wc_setcookie('woocommerce_items_in_cart', 1);
wc_setcookie('woocommerce_cart_hash', md5(json_encode(WC()->cart->get_cart())));
do_action('woocommerce_set_cart_cookies', true);
}
}
开发者ID:tadas8,项目名称:Cocoro-restaurant,代码行数:8,代码来源:functions.php
注:本文中的wc_setcookie函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论