/** * Get Cart Item Template * * @since 1.0 * @param int $cart_key Cart key * @param array $item Cart item * @param bool $ajax AJAX? * @return string Cart item */ function edd_get_cart_item_template($cart_key, $item, $ajax = false) { global $post; $id = is_array($item) ? $item['id'] : $item; $remove_url = edd_remove_item_url($cart_key); $title = get_the_title($id); $options = !empty($item['options']) ? $item['options'] : array(); $quantity = edd_get_cart_item_quantity($id, $options); $price = edd_get_cart_item_price($id, $options); if (!empty($options)) { $title .= edd_has_variable_prices($item['id']) ? ' <span class="edd-cart-item-separator">-</span> ' . edd_get_price_name($id, $item['options']) : edd_get_price_name($id, $item['options']); } ob_start(); edd_get_template_part('widget', 'cart-item'); $item = ob_get_clean(); $item = str_replace('{item_title}', $title, $item); $item = str_replace('{item_amount}', edd_currency_filter(edd_format_amount($price)), $item); $item = str_replace('{cart_item_id}', absint($cart_key), $item); $item = str_replace('{item_id}', absint($id), $item); $item = str_replace('{item_quantity}', absint($quantity), $item); $item = str_replace('{remove_url}', $remove_url, $item); $subtotal = ''; if ($ajax) { $subtotal = edd_currency_filter(edd_format_amount(edd_get_cart_subtotal())); } $item = str_replace('{subtotal}', $subtotal, $item); return apply_filters('edd_cart_item', $item, $id); }
/** * Get Cart Item Template * * @access public * @since 1.0 * @return string */ function edd_get_cart_item_template($cart_key, $item, $ajax = false) { global $post; $id = is_array($item) ? $item['id'] : $item; $remove_url = edd_remove_item_url($cart_key, $post, $ajax); $title = get_the_title($id); $options = !empty($item['options']) ? $item['options'] : array(); if (!empty($options)) { $title .= ' <span class="edd-cart-item-separator">-</span> ' . edd_get_price_name($id, $item['options']); } $remove = '<a href="' . esc_url($remove_url) . '" data-cart-item="' . absint($cart_key) . '" data-download-id="' . absint($id) . '" data-action="edd_remove_from_cart" class="edd-remove-from-cart">' . __('remove', 'edd') . '</a>'; $item = '<li class="edd-cart-item"><span class="edd-cart-item-title">' . $title . '</span> '; $item .= '<span class="edd-cart-item-separator">-</span> ' . edd_currency_filter(edd_get_cart_item_price($id, $options)) . ' '; $item .= '<span class="edd-cart-item-separator">-</span> ' . $remove . '</li>'; return apply_filters('edd_cart_item', $item, $id); }
/** * Get lists for post ID * * @since 1.0 */ function edd_wl_get_wish_lists($download_id, $price_ids, $items, $price_option_single) { ob_start(); $messages = edd_wl_messages(); global $edd_options; $text = !empty($edd_options['edd_wl_add_to_wish_list']) ? $edd_options['edd_wl_add_to_wish_list'] : sprintf(__('Add to %s', 'edd-wish-lists'), edd_wl_get_label_singular(true)); ?> <div class="modal-header"> <h2 id="edd-wl-modal-label"> <?php echo esc_attr($text); ?> </h2> <?php $download = $download_id ? get_the_title($download_id) : ''; // price variations // EG: Download Name - Option 1, Option 2, Option 3 if (edd_has_variable_prices($download_id)) { $price_options = array(); foreach ($items as $item) { $price_options[] = edd_get_price_name($item['id'], $item['options']); } } $options = !empty($price_options) ? ' - ' . implode(', ', $price_options) : ''; // show user what they have selected echo '<p>' . sprintf('%1$s%2$s', $download, $options) . '</p>'; ?> <a class="edd-wl-close" href="#" data-dismiss="modal"> <i class="glyphicon glyphicon-remove"></i> <span class="hide-text"><?php _e('Close', 'edd-wish-lists'); ?> </span> </a> </div> <div class="modal-body"> <?php // show lists this item is already included in echo edd_wl_lists_included($download_id, $items[0]['options']); ?> <?php if (!edd_wl_allow_guest_creation()) { ?> <?php echo '<p>' . $messages['must_login'] . '</p>'; ?> <?php } else { ?> <?php $list_query = edd_wl_get_query(); $private = edd_wl_get_query('private'); $public = edd_wl_get_query('public'); $variable_pricing = edd_has_variable_prices($download_id); $data_variable = $variable_pricing ? ' data-variable-price=yes' : 'data-variable-price=no'; $type = edd_single_price_option_mode($download_id) ? 'data-price-mode=multi' : 'data-price-mode=single'; ?> <form method="post" action="" class="form-modal"> <?php if ($list_query) { ?> <p id="current_lists"> <input type="radio" checked="" id="existing-list" value="existing-list" name="list-options"> <label for="existing-list"><?php echo $messages['modal_option_add_to_existing']; ?> </label> <select id="user-lists" name="user-lists"> <?php /** * Public lists */ if ($public) { ?> <optgroup label="Public"> <?php foreach ($public as $id) { ?> <option value="<?php echo $id; ?> "><?php echo get_the_title($id) . ' ' . edd_wl_get_item_count($id); ?> </option> <?php } ?> </optgroup> <?php } ?> <?php /** * Private lists */ if ($private) { ?> <optgroup label="Private"> <?php foreach ($private as $id) { ?> <option value="<?php echo $id; ?> "><?php echo get_the_title($id) . ' ' . edd_wl_get_item_count($id); ?> </option> <?php } ?> </optgroup> <?php } ?> </select> </p> <?php } ?> <p> <input type="radio" id="new-list" value="new-list" name="list-options"> <label for="new-list"><?php echo $messages['modal_option_add_new']; ?> </label> <input type="text" id="list-name" name="list-name" placeholder="<?php echo $messages['modal_option_title']; ?> "> <select id="list-status" name="list-status"> <option value="private"><?php echo $messages['list_option_private']; ?> </option> <option value="publish"><?php echo $messages['list_option_public']; ?> </option> </select> </p> </div> <?php // add a hidden input field for each price ID which our next ajax function will grab foreach ($price_ids as $id) { ?> <input name="edd-wish-lists-post-id" type="hidden" value="<?php echo $id; ?> "> <?php } ?> <?php if ($price_option_single) { ?> <input name="edd-wl-single-price-option" type="hidden" value="yes"> <?php } ?> <div class="modal-footer"> <?php $args = array('download_id' => $download_id, 'text' => $messages['modal_option_save'], 'icon' => '', 'action' => 'edd_add_to_wish_list', 'class' => 'edd-wl-save edd-wl-action', 'style' => 'button'); edd_wl_wish_list_link($args); ?> <a class="edd-wl-button edd-wl-success edd-wl-action" href="#" data-dismiss="modal" style="display:none;"> <?php echo $messages['modal_option_close']; ?> </a> </div> </form> <?php } ?> </div> <?php $html = ob_get_clean(); return apply_filters('edd_wl_get_wish_lists', $html); }
<?php do_action('edd_checkout_table_body_first', $item['id']); ?> <td class="edd_cart_item_name"> <?php //print_r( $item ); if (current_theme_supports('post-thumbnails')) { if (has_post_thumbnail($item['id'])) { echo '<div class="edd_cart_item_image">'; echo get_the_post_thumbnail($item['id'], apply_filters('edd_checkout_image_size', array(25, 25))); echo '</div>'; } } $item_title = get_the_title($item['id']); if (!empty($item['options'])) { $item_title .= ' - ' . edd_get_price_name($item['id'], $item['options']); } echo '<span class="edd_checkout_cart_item_title">' . esc_html($item_title) . '</span>'; ?> </td> <td class="edd_cart_item_price"><?php echo esc_html(edd_currency_filter(edd_get_cart_item_price($item['id'], $item['options']))); ?> </td> <td class="edd_cart_actions"><a href="<?php echo esc_url(edd_remove_item_url($key, $post)); ?> "><?php _e('remove', 'edd'); ?> </a></td>
<?php do_action('edd_checkout_table_body_first', $item['id']); ?> <td class="edd_cart_item_name"> <?php if (current_theme_supports('post-thumbnails')) { if (has_post_thumbnail($item['id'])) { echo '<div class="edd_cart_item_image">'; echo get_the_post_thumbnail($item['id'], apply_filters('edd_checkout_image_size', array(25, 25))); echo '</div>'; } } $item_title = get_the_title($item['id']); $variable_pricing = edd_has_variable_prices($item['id']); if (!empty($item['options'])) { $item_title .= $variable_pricing ? ' - ' . edd_get_price_name($item['id'], $item['options']) : edd_get_price_name($item['id'], $item['options']); } echo '<span class="edd_checkout_cart_item_title">' . esc_html($item_title) . '</span>'; ?> </td> <td class="edd_cart_item_price"><?php echo edd_cart_item_price($item['id'], $item['options']); ?> </td> <td class="edd_cart_actions"><a href="<?php echo esc_url(edd_remove_item_url($key, $post)); ?> "><?php _e('Remove', 'edd'); ?> </a></td>