echo get_the_title(SunshineFrontend::$current_gallery->ID); ?> </h1> <div id="sunshine-action-menu" class="sunshine-clearfix"> <?php sunshine_action_menu(); ?> </div> <?php $this_gallery_id = $post->ID; $child_galleries = sunshine_get_child_galleries(); ?> <div id="sunshine-gallery-images" class="sunshine-clearfix"> <?php if (!sunshine_is_gallery_expired()) { if (post_password_required(SunshineFrontend::$current_gallery)) { echo get_the_password_form(); } elseif (sunshine_gallery_requires_email(SunshineFrontend::$current_gallery->ID)) { echo sunshine_gallery_email_form(); } else { sunshine_gallery_expiration_notice(); if (SunshineFrontend::$current_gallery->post_content) { ?> <div id="sunshine-content"> <?php echo apply_filters('the_content', SunshineFrontend::$current_gallery->post_content); ?> </div> <?php }
function sunshine_add_to_cart_form() { global $post, $sunshine; do_action('sunshine_before_add_to_cart_form'); $disable_products = get_post_meta(SunshineFrontend::$current_gallery->ID, 'sunshine_gallery_disable_products', true); $disable_products = get_post_meta(SunshineFrontend::$current_gallery->ID, 'sunshine_gallery_disable_products', true); $hide_add_to_cart = false; if ($sunshine->options['add_to_cart_require_account'] && !is_user_logged_in()) { echo '<p>' . sprintf(__('You must first <a href="%s">login</a> or <a href="%s">register</a> before you can add pictures to your cart. This allows us to track your favorites and items in your cart when you return.', 'sunshine'), wp_login_url(sunshine_current_url(false)), wp_registration_url() . '&redirect_to=' . sunshine_current_url(false)) . '</p>'; return; } elseif (sunshine_is_gallery_expired()) { echo '<p>' . __('This gallery this image belongs to has expired.', 'sunshine') . '</p>'; return; } if (!$disable_products && !$hide_add_to_cart && !$sunshine->options['proofing']) { ?> <form method="post" action=""> <ul id="sunshine-add-to-cart"> <?php $price_level = get_post_meta(SunshineFrontend::$current_gallery->ID, 'sunshine_gallery_price_level', true); $product_categories = get_terms('sunshine-product-category', 'orderby=slug&order=ASC'); foreach ($product_categories as $product_category) { $args = array('post_type' => 'sunshine-product', 'orderby' => 'menu_order', 'order' => 'ASC', 'nopaging' => true, 'tax_query' => array(array('taxonomy' => 'sunshine-product-category', 'field' => 'id', 'terms' => array($product_category->term_id))), 'meta_query' => array(array('key' => 'sunshine_product_price_' . $price_level, 'value' => '', 'compare' => '!='))); $args = apply_filters('sunshine_add_product_query_args', $args); $category_products = new WP_Query($args); if ($category_products->post_count > 0) { $available_products[$product_category->term_id] = $category_products; $available_categories[] = $product_category; } } if (count($available_categories) > 1) { ?> <li id="sunshine-product-category-select"> <h2><?php _e('Select Product Type', 'sunshine'); ?> </h2> <?php do_action('sunshine_before_product_category_select'); ?> <ul> <?php foreach ($available_categories as $product_category) { do_action('sunshine_before_product_category', $product_category); ?> <li><label><input type="radio" name="sunshine_product_category" value="<?php echo $product_category->term_id; ?> " /> <?php echo $product_category->name; ?> </label> <?php if ($product_category->description) { ?> <div class="sunshine-product-category-select-desc"><?php echo $product_category->description; ?> </div><?php } ?> </li> <?php do_action('sunshine_after_product_category', $product_category, $price_level); } ?> </ul> <?php do_action('sunshine_after_product_category_select', $price_level); ?> </li> <?php } ?> <?php if (!empty($available_products)) { ?> <li id="sunshine-product-select" style="display: <?php echo count($available_products) > 1 ? 'none' : 'block'; ?> "> <h2><?php _e('Select Product', 'sunshine'); ?> </h2> <?php foreach ($available_products as $category_id => $products) { ?> <div id="sunshine-product-category-<?php echo $category_id; ?> " class="sunshine-product-select" style="display: <?php echo count($available_products) > 1 ? 'none' : 'block'; ?> ;"> <?php if ($products->have_posts()) { ?> <ul> <?php while ($products->have_posts()) { $products->the_post(); ?> <li class="<?php sunshine_product_class(); ?> "> <?php do_action('sunshine_before_product', $post); ?> <label id="sunshine-product-<?php the_ID(); ?> "> <input type="radio" name="sunshine_product" value="<?php the_ID(); ?> "> <span class="sunshine-product-name"><?php the_title(); ?> </span> <span class="sunshine-product-divider">-</span> <span class="sunshine-product-price"><?php echo $sunshine->cart->get_product_price(get_the_ID(), $price_level); ?> </span> <?php if ($product_image_id = get_post_thumbnail_id()) { ?> <span class="sunshine-product-image-link"><a href="<?php echo wp_get_attachment_url($product_image_id); ?> " target="_blank"><?php _e('See Product', 'sunshine'); ?> </a></span> <?php } ?> </label> <?php if ($post->post_content) { ?> <span class="sunshine-product-desc-link"><a href="#sunshine-product-<?php the_ID(); ?> -desc" onclick="jQuery('#sunshine-product-<?php the_ID(); ?> -desc').toggle(); return false;"><?php _e('Details', 'sunshine'); ?> </a></span> <div class="sunshine-product-desc" id="sunshine-product-<?php the_ID(); ?> -desc"> <?php echo $post->post_content; ?> </div> <?php } ?> <?php do_action('sunshine_after_product', $post, $price_level); ?> </li> <?php } wp_reset_postdata(); ?> </ul> <?php } else { echo '<p>' . __('No products for this category', 'sunshine') . '</p>'; } ?> </div> <?php } // End foreach do_action('sunshine_after_product_select', $price_level); ?> </li> <?php } ?> <li id="sunshine-add-qty" style="display: none;"> <h2><?php _e('Quantity', 'sunshine'); ?> </h2> <input type="number" name="sunshine_qty" class="sunshine-qty" value="1" size="4" /> </li> <li id="sunshine-add-comments" style="display: none;"> <script> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <h2><?php _e('Comments', 'sunshine'); ?> </h2> <textarea name="sunshine_comments" rows="5" cols="20" onKeyDown="limitText(this.form.sunshine_comments,this.form.countdown,200);" onKeyUp="limitText(this.form.sunshine_comments,this.form.countdown,200);"></textarea> <br /><?php echo sprintf(__('You have %s characters left', 'sunshine'), '<input readonly type="text" class="sunshine-countdown" name="countdown" size="3" value="200" />'); ?> </li> <li id="sunshine-add-button" style="display: none;"> <input type="submit" value="<?php _e('Add to Cart', 'sunshine'); ?> " class="sunshine-button" /> <input type="hidden" name="sunshine_add_to_cart" value="1" /> <input type="hidden" name="sunshine_image" value="<?php echo SunshineFrontend::$current_image->ID; ?> " /> </li> </ul> </form> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('input[name="sunshine_product_category"]').change(function() { var product_category = jQuery(this).val(); jQuery('.sunshine-product-select').hide(); jQuery('#sunshine-product-select, #sunshine-product-category-'+product_category).show(); jQuery('#sunshine-add-qty, #sunshine-add-comments, #sunshine-add-button').hide(); }); jQuery('input[name="sunshine_product"]').change(function() { var product_id = jQuery(this).val(); jQuery('#sunshine-product-variations-'+product_id).toggle(); jQuery('#sunshine-add-qty, #sunshine-add-comments, #sunshine-add-button').show(); }); }); </script> <?php } do_action('sunshine_after_add_to_cart_form'); }
function check_expirations() { global $sunshine; if (isset(self::$current_image) && sunshine_is_gallery_expired()) { wp_redirect(get_permalink(self::$current_gallery->ID)); exit; } elseif (is_page($sunshine->options['page_cart'])) { // Remove items from cart if gallery is expired $cart = $sunshine->cart->get_cart(); $removed_items = false; foreach ($cart as $item) { if (isset($item['gallery_id'])) { $gallery_id = $item['gallery_id']; if (sunshine_is_gallery_expired($gallery_id)) { $sunshine->cart->remove_from_cart($item['key']); $removed_items = true; } } elseif (isset($item['image_id'])) { $image = get_post($item['image_id']); if (!$image) { // Remove if the image no longer exists as well $sunshine->cart->remove_from_cart($item['key']); $removed_items = true; continue; } else { $gallery_id = $image->post_parent; } } } if ($removed_items) { $sunshine->add_message(__('Images in your cart have been removed because they are no longer available', 'sunshine')); wp_redirect(get_permalink($sunshine->options['page_cart'])); exit; } } }