本文整理汇总了PHP中edd_get_cart_quantity函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_cart_quantity函数的具体用法?PHP edd_get_cart_quantity怎么用?PHP edd_get_cart_quantity使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_cart_quantity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: huesos_edd_show_header_cart_link
/**
* Show cart link and quantity count in header if the cart has contents.
*
* The ".edd-cart-quantity" class is needed in order for the quantity to be
* updated dynamically via AJAX.
*
* @todo Add cart link to mobile navigation bar.
*
* @since 1.0.0
*/
function huesos_edd_show_header_cart_link()
{
if (!edd_get_cart_contents()) {
return;
}
printf('<p class="cart-quantity"><a class="button" href="%1$s">%2$s (<span class="edd-cart-quantity">%3$s</span>)</a></p>', esc_url(edd_get_checkout_uri()), esc_html__('Cart', 'huesos'), esc_html(edd_get_cart_quantity()));
}
示例2: marketify_wp_nav_menu_items
/**
* Cart menu item
*
* @since Marketify 1.0
*
* @param string $items
* @param object $args
* @return string $items
*/
function marketify_wp_nav_menu_items($items, $args)
{
if ('primary' != $args->theme_location) {
return $items;
}
ob_start();
$widget_args = array('before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '');
$widget = the_widget('edd_cart_widget', array('title' => ''), $widget_args);
$widget = ob_get_clean();
$link = sprintf('<li class="current-cart"><a href="%s"><i class="icon-cart"></i> <span class="edd-cart-quantity">%d</span></a><ul class="sub-menu nav-menu"><li class="widget">%s</li></ul></li>', get_permalink(edd_get_option('purchase_page')), edd_get_cart_quantity(), $widget);
return $link . $items;
}
示例3: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$quantity = isset($instance['quantity']) ? $instance['quantity'] : false;
global $post, $edd_options;
echo $before_widget;
if ($title) {
if ($quantity == 1) {
$quantity = ' - <span class="edd-cart-quantity">' . edd_get_cart_quantity() . '</span>';
} else {
$quantity = '';
}
echo $before_title . $title . $quantity . $after_title;
}
do_action('edd_before_cart_widget');
edd_shopping_cart(true);
do_action('edd_after_cart_widget');
echo $after_widget;
}
示例4: edd_shopping_cart
/**
* Renders the Shopping Cart
*
* @since 1.0
* @return string Fully formatted cart
*/
function edd_shopping_cart($echo = false)
{
global $edd_options;
ob_start();
do_action('edd_before_cart');
$display = 'style="display:none;"';
$cart_quantity = edd_get_cart_quantity();
if ($cart_quantity > 0) {
$display = "";
}
echo "<p class='edd-cart-number-of-items' {$display}>" . __('Number of items in cart', 'edd') . ': <span class="edd-cart-quantity">' . $cart_quantity . '<span></p>';
?>
<ul class="edd-cart">
<!--dynamic-cached-content-->
<?php
$cart_items = edd_get_cart_contents();
if ($cart_items) {
foreach ($cart_items as $key => $item) {
echo edd_get_cart_item_template($key, $item, false);
}
edd_get_template_part('widget', 'cart-checkout');
} else {
edd_get_template_part('widget', 'cart-empty');
}
?>
<!--/dynamic-cached-content-->
</ul>
<?php
do_action('edd_after_cart');
if ($echo) {
echo ob_get_clean();
} else {
return ob_get_clean();
}
}
示例5: wp_nav_menu_items
/**
* This function adds the WooCommerce or Easy Digital Downloads cart icons/items to the top_nav
* menu area as the last item.
*/
function wp_nav_menu_items($items, $args, $ajax = false)
{
// Top Navigation area only
if (isset($ajax) && $ajax || property_exists($args, 'theme_location') && $args->theme_location === 'top_nav') {
// WooCommerce
if (class_exists('woocommerce')) {
$css_class = 'menu-item menu-item-type-cart menu-item-type-woocommerce-cart';
// Is this the cart page?
if (is_cart()) {
$css_class .= ' current-menu-item';
}
$items .= '<li class="' . esc_attr($css_class) . '">';
$items .= '<a class="cart-contents" href="' . esc_url(WC()->cart->get_cart_url()) . '">';
$items .= wp_kses_data(WC()->cart->get_cart_total()) . ' - <span class="count">' . wp_kses_data(sprintf(_n('%d item', '%d items', WC()->cart->get_cart_contents_count(), 'simple-shop'), WC()->cart->get_cart_contents_count())) . '</span>';
$items .= '</a>';
$items .= '</li>';
} else {
if (class_exists('Easy_Digital_Downloads')) {
$css_class = 'menu-item menu-item-type-cart menu-item-type-edd-cart';
// Is this the cart page?
if (edd_is_checkout()) {
$css_class .= ' current-menu-item';
}
$items .= '<li class="' . esc_attr($css_class) . '">';
$items .= '<a class="cart-contents" href="' . esc_url(edd_get_checkout_uri()) . '">';
$items .= wp_kses_data(edd_cart_subtotal()) . ' - <span class="count">' . wp_kses_data(sprintf(_n('%d item', '%d items', edd_get_cart_quantity(), 'simple-shop'), edd_get_cart_quantity())) . '</span>';
$items .= '</a>';
$items .= '</li>';
}
}
}
return $items;
}
示例6: menu_item
public function menu_item()
{
global $post;
$menu_item = array('cart_url' => edd_get_checkout_uri(), 'shop_page_url' => get_home_url(), 'cart_contents_count' => edd_get_cart_quantity(), 'cart_total' => edd_currency_filter(edd_format_amount(edd_get_cart_total())));
return $menu_item;
}
示例7: edd_ajax_add_to_cart
/**
* Adds item to the cart via AJAX.
*
* @since 1.0
* @return void
*/
function edd_ajax_add_to_cart()
{
if (isset($_POST['download_id'])) {
$to_add = array();
if (isset($_POST['price_ids']) && is_array($_POST['price_ids'])) {
foreach ($_POST['price_ids'] as $price) {
$to_add[] = array('price_id' => $price);
}
}
$items = '';
foreach ($to_add as $options) {
if ($_POST['download_id'] == $options['price_id']) {
$options = array();
}
parse_str($_POST['post_data'], $post_data);
if (isset($options['price_id']) && isset($post_data['edd_download_quantity_' . $options['price_id']])) {
$options['quantity'] = absint($post_data['edd_download_quantity_' . $options['price_id']]);
} else {
$options['quantity'] = isset($post_data['edd_download_quantity']) ? absint($post_data['edd_download_quantity']) : 1;
}
$key = edd_add_to_cart($_POST['download_id'], $options);
$item = array('id' => $_POST['download_id'], 'options' => $options);
$item = apply_filters('edd_ajax_pre_cart_item_template', $item);
$items .= html_entity_decode(edd_get_cart_item_template($key, $item, true), ENT_COMPAT, 'UTF-8');
}
$return = array('subtotal' => html_entity_decode(edd_currency_filter(edd_format_amount(edd_get_cart_subtotal())), ENT_COMPAT, 'UTF-8'), 'total' => html_entity_decode(edd_currency_filter(edd_format_amount(edd_get_cart_total())), ENT_COMPAT, 'UTF-8'), 'cart_item' => $items, 'cart_quantity' => html_entity_decode(edd_get_cart_quantity()));
if (edd_use_taxes()) {
$cart_tax = (double) edd_get_cart_tax();
$return['tax'] = html_entity_decode(edd_currency_filter(edd_format_amount($cart_tax)), ENT_COMPAT, 'UTF-8');
}
echo json_encode($return);
}
edd_die();
}
示例8: edd_get_cart_contents
<?php
$cart_items = edd_get_cart_contents();
$cart_quantity = edd_get_cart_quantity();
$display = $cart_quantity > 0 ? '' : 'style="display:none;"';
?>
<p class="edd-cart-number-of-items"<?php
echo $display;
?>
><?php
_e('Number of items in cart', 'edd');
?>
: <span class="edd-cart-quantity"><?php
echo $cart_quantity;
?>
</span></p>
<ul class="edd-cart">
<?php
if ($cart_items) {
?>
<?php
foreach ($cart_items as $key => $item) {
?>
<?php
echo edd_get_cart_item_template($key, $item, false);
?>
<?php
}
示例9: edd_get_cart_item_discount_amount
/**
* Get the discounted amount on a price
*
* @since 1.9
* @param array $item Cart item array
* @return float The discounted amount
*/
function edd_get_cart_item_discount_amount($item = array())
{
$amount = 0;
$price = edd_get_cart_item_price($item['id'], $item['options'], edd_prices_include_tax());
$discounted_price = $price;
// Retrieve all discounts applied to the cart
$discounts = edd_get_cart_discounts();
if ($discounts) {
foreach ($discounts as $discount) {
$code_id = edd_get_discount_id_by_code($discount);
$reqs = edd_get_discount_product_reqs($code_id);
$excluded_products = edd_get_discount_excluded_products($code_id);
// Make sure requirements are set and that this discount shouldn't apply to the whole cart
if (!empty($reqs) && edd_is_discount_not_global($code_id)) {
// This is a product(s) specific discount
foreach ($reqs as $download_id) {
if ($download_id == $item['id'] && !in_array($item['id'], $excluded_products)) {
$discounted_price -= $price - edd_get_discounted_amount($discount, $price);
}
}
} else {
// This is a global cart discount
if (!in_array($item['id'], $excluded_products)) {
if ('flat' === edd_get_discount_type($code_id)) {
/* *
* In order to correctly record individual item amounts, global flat rate discounts
* are distributed across all cart items. The discount amount is divided by the number
* of items in the cart and then a portion is evenly applied to each cart item
*/
$discounted_amount = edd_get_discount_amount($code_id);
$discounted_amount = $discounted_amount / edd_get_cart_quantity();
$discounted_price -= $discounted_amount;
} else {
$discounted_price -= $price - edd_get_discounted_amount($discount, $price);
}
}
}
}
$amount = $price - apply_filters('edd_get_cart_item_discounted_amount', $discounted_price, $discounts, $item, $price);
if ('flat' !== edd_get_discount_type($code_id)) {
$amount = $amount * $item['quantity'];
}
}
return $amount;
}
示例10: get_permalink
</div> <!-- /.col.grid_6_of_12 -->
<div class="col grid_6_of_12 header-extras last">
<?php
if (class_exists('Easy_Digital_Downloads')) {
?>
<span id="header-cart">
<a href="<?php
echo get_permalink($edd_options['purchase_page']);
?>
">
<i class="fa fa-shopping-cart"></i> <?php
_e('Cart', 'tatva');
?>
(<span class="header-cart edd-cart-quantity"><?php
echo edd_get_cart_quantity();
?>
</span>)
</a>
</span>
<?php
}
?>
<?php
if (class_exists('woocommerce')) {
global $woocommerce;
?>
<ul class="woo-cart-total">
<li>
<a class="cart-contents" href="<?php
示例11: shortcode_edd_cart_count
/**
* Return woocommerce number of items in cart (e.g 1)
*
* @since 1.3.3
* @return string
*/
public function shortcode_edd_cart_count()
{
if (function_exists('edd_get_cart_quantity')) {
return "<span class='mega-menu-edd-cart-count'>" . edd_get_cart_quantity() . "</span>";
}
}
示例12: process_payment
/**
* process_payment function.
*
* Submit payment and handle response
*
* @access public
*/
public function process_payment($purchase_data)
{
//edd_options contains the values of the admin settings
global $edd_options;
if (edd_is_test_mode()) {
$paystack_public = $edd_options['test_public_key'];
$paystack_secret = $edd_options['test_secret_key'];
} else {
$paystack_public = $edd_options['live_public_key'];
$paystack_secret = $edd_options['live_secret_key'];
}
//txcode POSTed from payment form
$txcode = isset($_POST['txcode']) ? $_POST['txcode'] : null;
/**
* check for checkout fields errors
*
*/
// check if there is a gateway name
if (!isset($purchase_data['post_data']['edd-gateway'])) {
return;
}
// get EDD errors
$errors = edd_get_errors();
// Paystack errors
$paystack_error = null;
/**
* end checkout fields error checks
*/
// if no errors
if (!$errors) {
// record purchase summary
$summary = edd_get_purchase_summary($purchase_data, false);
// cart quantity
$quantity = edd_get_cart_quantity();
/**
* setup the payment data
*/
$payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => $edd_options['currency'], 'downloads' => $purchase_data['downloads'], 'cart_details' => $purchase_data['cart_details'], 'user_info' => $purchase_data['user_info'], 'status' => 'pending');
// record the pending payment
$payment = edd_insert_payment($payment_data);
$order_id = $payment;
if (!$payment) {
// Record the error
edd_record_gateway_error(__('Payment Error', 'po_paystack'), sprintf(__('Payment creation failed before loading Paystack. Payment data: %s', 'po_paystack'), json_encode($payment_data)), $payment);
// Problems? send back
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
} else {
if (!$order_id || !$paystack_public) {
edd_record_gateway_error(__('Invalid transaction', 'po_paystack'), sprintf(__('Invalid transaction; possible hack attempt. Payment data: %s', 'po_paystack'), json_encode($payment_data)), $payment);
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
}
if (!$txcode) {
$error = "Error! An invalid transaction code was reported.";
edd_update_payment_status($order_id, 'failed');
throw new Exception(__($error));
} else {
$amount = $payment_data['price'] * 100;
//convert to kobo
if (intval($amount) < 100) {
$error = "Invalid transaction. Paystack cannot process orders under 100 kobo in value. Transaction code: " . $txcode;
edd_update_payment_status($order_id, 'failed');
throw new Exception(__($error));
}
$email = $payment_data['user_email'];
require_once dirname(__FILE__) . '/paystack-class/Paystack.php';
// Create the library object
$paystack = new Paystack($paystack_secret);
list($headers, $body, $code) = $paystack->transaction->verify(['reference' => $txcode]);
$resp = $body;
if (array_key_exists("status", $resp) && !$resp["status"]) {
$error = "Failed with message from Paystack: " . $resp["message"];
edd_insert_payment_note($order_id, __($error));
edd_update_payment_status($order_id, 'failed');
throw new Exception(__($error));
} elseif ($resp["data"]["customer"]["email"] !== $email) {
$error = "Invalid customer email associated with Transaction code:" . $txcode . " and Paystack reference: " . $resp["data"]['reference'] . ". Possible hack attempt.";
edd_insert_payment_note($order_id, __($error));
edd_update_payment_status($order_id, 'failed');
throw new Exception(__($error));
} else {
// Authcode and Authdesc. To be used in future version, for recurrent billing
$authcode = $resp["data"]["authorization"]["authorization_code"];
$authdesc = $resp["data"]["authorization"]["description"];
$paystackref = $resp["data"]["reference"];
// Complete the order. once a transaction is successful, set the purchase status to complete
edd_update_payment_status($payment, 'complete');
// record transaction ID, or any other notes you need
edd_insert_payment_note($payment, "Paystack.co payment completed (using " . strtoupper($authdesc) . " and Transaction code:" . $txcode . ") with Paystack reference:" . $paystackref);
// go to the success page
edd_send_to_success_page();
}
}
}
//.........这里部分代码省略.........
示例13: pp_show_cart_quantity_icon
/**
* Show the amount of downloads in the cart with an icon
*
* @since 1.0
*/
function pp_show_cart_quantity_icon()
{
global $edd_options;
$class = !(function_exists('edd_get_cart_contents') && edd_get_cart_contents()) ? ' hidden' : '';
$quantity = function_exists('edd_get_cart_quantity') && edd_get_cart_quantity() == 1 ? ' item' : ' items';
?>
<a href="<?php
echo esc_url(edd_get_checkout_uri());
?>
" class="menu-icon cart<?php
echo $class;
?>
" title="You have <?php
echo edd_get_cart_quantity() . $quantity;
?>
ready for purchase">
<div class="bag">
<span class="edd-cart-quantity"><?php
echo edd_get_cart_quantity();
?>
</span>
<img class="checkout" src="<?php
echo get_stylesheet_directory_uri() . '/images/arrow-right.svg';
?>
" />
</div>
</a>
<?php
}
示例14: esc_attr
<li class="edd-cart-item" data-cart-quantity="<?php
echo esc_attr(edd_get_cart_quantity());
?>
">
<span class="edd-cart-item-title">{item_title}</span>
<span class="edd-cart-item-separator">-</span><span class="edd-cart-item-price"> {item_amount} </span><span class="edd-cart-item-separator">-</span>
<a href="{remove_url}" data-cart-item="{cart_item_id}" data-download-id="{item_id}" data-action="edd_remove_from_cart" class="edd-remove-from-cart"><?php
esc_html_e('remove', 'helium');
?>
</a>
</li>
示例15: slackedd_notification
/**
* Slackedd Notification Codes
*
* @since 1.0.0
*/
function slackedd_notification($payment_id)
{
$edd_options = edd_get_settings();
/* Check that the user has all required information added for the plugin to work */
$enable_slack = isset($edd_options['slackedd_enable_notification']) ? $edd_options['slackedd_enable_notification'] : '';
$hide_order_number = isset($edd_options['slackedd_hide_order_number']) ? $edd_options['slackedd_hide_order_number'] : '';
$hide_order_items = isset($edd_options['slackedd_hide_order_items']) ? $edd_options['slackedd_hide_order_items'] : '';
$hide_payment_gateway = isset($edd_options['slackedd_hide_payment_gateway']) ? $edd_options['slackedd_hide_payment_gateway'] : '';
$hide_buyer_information = isset($edd_options['slackedd_hide_buyer_information']) ? $edd_options['slackedd_hide_buyer_information'] : '';
$slack_channel = isset($edd_options['slackedd_channel']) ? $edd_options['slackedd_channel'] : '';
$webhook_url = isset($edd_options['slackedd_webhook_url']) ? $edd_options['slackedd_webhook_url'] : '';
if (!($enable_slack && $slack_channel && $webhook_url)) {
return;
}
$enable_slack = isset($edd_options['slackedd_enable_notification']) ? $edd_options['slackedd_enable_notification'] : '';
$emoji = !empty($edd_options['slackedd_icon_emoji']) ? $edd_options['slackedd_icon_emoji'] : ':moneybag:';
$bot_name = !empty($edd_options['slackedd_bot_name']) ? $edd_options['slackedd_bot_name'] : 'Slackedd';
$order_amount = esc_attr(edd_format_amount(edd_get_payment_amount($payment_id)));
$currency_symbol = edd_currency_symbol($payment_meta['currency']);
$currency_symbol = html_entity_decode($currency_symbol, ENT_QUOTES, 'UTF-8');
$payment_meta = edd_get_payment_meta($payment_id);
$cart_items = edd_get_payment_meta_cart_details($payment_id);
$items_sold = '';
$order_id = edd_get_payment_number($payment_id);
foreach ($cart_items as $key => $cart_item) {
$name = $cart_item['name'];
$price = $cart_item['price'];
$items_sold .= "*Name:* " . $name . " | *Price:* " . $currency_symbol . "" . $price . " \n";
}
$gateway = edd_get_payment_gateway($payment_id);
$payment_method = edd_get_gateway_admin_label($gateway);
$user_data = $payment_meta['user_info'];
/* Display the new sale introduction */
$message = "A new sale has occurred at " . get_bloginfo('name') . " \n\n";
/* Show or hide order number based on user preference in settings page */
if (!$hide_order_number) {
$message .= "*Order* <" . get_bloginfo('home') . "/wp-admin/edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=" . $order_id . "|#" . $order_id . "> \n";
}
/* Show the order total */
$message .= "*Order Total:* " . $currency_symbol . "" . $order_amount . " \n\n";
/* Show or hide payment gateway based on user preference in settings page */
if (!$hide_payment_gateway) {
$message .= "*Payment Method:* " . $payment_method . " \n\n";
}
/* Show or hide order items based on user preference in settings page */
if (!$hide_order_items) {
$message .= "*" . edd_get_cart_quantity() . " ITEM(S):* \n";
$message .= $items_sold;
}
/* Show or hide order number based on user preference in settings page */
if (!$hide_buyer_information) {
$message .= "\n\n *Customer:* " . $user_data['first_name'] . " " . $user_data['last_name'] . " " . $user_data['email'] . "\n";
}
$attachment = array();
$attachment[] = array('color' => 'good', 'fallback' => 'New sale notification of ' . $currency_symbol . '' . $price . ' at ' . get_bloginfo('name'), 'mrkdwn_in' => array('text'), 'text' => $message, 'title' => 'New Sale Notification!');
$payload = array('attachments' => $attachment, 'channel' => $slack_channel, 'icon_emoji' => $emoji, 'username' => $bot_name);
$args = array('body' => json_encode($payload), 'timeout' => 30);
$response = wp_remote_post($webhook_url, $args);
return;
}