本文整理汇总了PHP中WC_Order::get_order_key方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::get_order_key方法的具体用法?PHP WC_Order::get_order_key怎么用?PHP WC_Order::get_order_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::get_order_key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Test: get_checkout_order_received_url
*/
function test_get_checkout_order_received_url()
{
$object = new WC_Order();
$object->set_order_key('xxx');
$id = $object->save();
$this->assertEquals('http://example.org?order-received=' . $id . '&key=' . $object->get_order_key(), $object->get_checkout_order_received_url());
}
示例2: get_download_ids
/**
* Get a list of download IDs for a specific item from an order.
*
* @since 2.7.0
* @param WC_Order_Item $item
* @param WC_Order $order
* @return array
*/
public function get_download_ids($item, $order)
{
global $wpdb;
return $wpdb->get_col($wpdb->prepare("SELECT download_id FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE user_email = %s AND order_key = %s AND product_id = %d ORDER BY permission_id", $order->get_billing_email(), $order->get_order_key(), $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id()));
}
示例3: wc_downloadable_file_permission
/**
* Grant downloadable product access to the file identified by $download_id.
*
* @param string $download_id file identifier
* @param int|WC_Product $product
* @param WC_Order $order the order
* @param int $qty purchased
* @return int|bool insert id or false on failure
*/
function wc_downloadable_file_permission($download_id, $product, $order, $qty = 1)
{
if (is_numeric($product)) {
$product = wc_get_product($product);
}
$download = new WC_Customer_Download();
$download->set_download_id($download_id);
$download->set_product_id($product->get_id());
$download->set_user_id($order->get_customer_id());
$download->set_order_id($order->get_id());
$download->set_user_email($order->get_billing_email());
$download->set_order_key($order->get_order_key());
$download->set_downloads_remaining(0 > $product->get_download_limit() ? '' : $product->get_download_limit() * $qty);
$download->set_access_granted(current_time('timestamp'));
$download->set_download_count(0);
$expiry = $product->get_download_expiry();
if ($expiry > 0) {
$order_completed_date = date_i18n("Y-m-d", $order->get_date_completed());
$download->set_access_expires(strtotime($order_completed_date . ' + ' . $expiry . ' DAY'));
}
return $download->save();
}
示例4: wc_downloadable_file_permission
/**
* Grant downloadable product access to the file identified by $download_id.
*
* @access public
* @param string $download_id file identifier
* @param int $product_id product identifier
* @param WC_Order $order the order
* @param int $qty purchased
* @return int|bool insert id or false on failure
*/
function wc_downloadable_file_permission($download_id, $product_id, $order, $qty = 1)
{
global $wpdb;
$user_email = sanitize_email($order->get_billing_email());
$limit = trim(get_post_meta($product_id, '_download_limit', true));
$expiry = trim(get_post_meta($product_id, '_download_expiry', true));
$limit = empty($limit) ? '' : absint($limit) * $qty;
// Default value is NULL in the table schema
$expiry = empty($expiry) ? null : absint($expiry);
if ($expiry) {
$order_completed_date = date_i18n("Y-m-d", strtotime($order->completed_date));
$expiry = date_i18n("Y-m-d", strtotime($order_completed_date . ' + ' . $expiry . ' DAY'));
}
$data = apply_filters('woocommerce_downloadable_file_permission_data', array('download_id' => $download_id, 'product_id' => $product_id, 'user_id' => absint($order->get_user_id()), 'user_email' => $user_email, 'order_id' => $order->get_id(), 'order_key' => $order->get_order_key(), 'downloads_remaining' => $limit, 'access_granted' => current_time('mysql'), 'download_count' => 0));
$format = apply_filters('woocommerce_downloadable_file_permission_format', array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d'), $data);
if (!is_null($expiry)) {
$data['access_expires'] = $expiry;
$format[] = '%s';
}
// Downloadable product - give access to the customer
$result = $wpdb->insert($wpdb->prefix . 'woocommerce_downloadable_product_permissions', $data, $format);
do_action('woocommerce_grant_product_download_access', $data);
return $result ? $wpdb->insert_id : false;
}