Beispiel #1
0
 /**
  * Retrieves an active checkout (dynamic checkout or other)
  * @param $part (optionl)	The checkout part to retrieve: 'type' (default), 'steps'
  * @return string|bool		The active checkout name, if any, or False otherwise
  */
 protected function get_active_checkout($part = 'type')
 {
     // if theme supports app-checkout
     if (function_exists('appthemes_get_checkout')) {
         $checkout = appthemes_get_checkout();
         if (!$checkout) {
             return false;
         }
         $curr_checkout_type = $checkout->get_checkout_type();
         $steps = $checkout->get_steps();
         $steps = wp_list_pluck($steps, 'id');
         $registered_steps = APP_Form_Progress_Checkout_Registry::steps($curr_checkout_type);
         if (empty($registered_steps)) {
             // if the checkout is valid and no steps are registered use the dynamic checkout step tree as the steps defaults
             APP_Form_Progress_Checkout_Registry::register_steps($curr_checkout_type, $steps);
         }
     } else {
         if (!empty($_REQUEST['app-checkout-type'])) {
             $curr_checkout_type = wp_strip_all_tags($_REQUEST['app-checkout-type']);
             $steps = APP_Form_Progress_Checkout_Registry::steps($curr_checkout_type);
         }
     }
     // no steps found for the current checkout
     if (empty($steps) || empty($curr_checkout_type)) {
         return false;
     }
     $checkout = array('type' => $curr_checkout_type, 'steps' => $steps);
     return $checkout[$part];
 }
Beispiel #2
0
 function cp_dropdown_categories_prices($args = '')
 {
     $defaults = array('show_option_all' => '', 'show_option_none' => __('Select one', APP_TD), 'orderby' => 'name', 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0, 'hide_empty' => 0, 'child_of' => 0, 'exclude' => '', 'echo' => 1, 'selected' => 0, 'hierarchical' => 1, 'name' => 'cat', 'id' => 'ad_cat_id', 'class' => 'dropdownlist', 'depth' => 1, 'tab_index' => 0, 'taxonomy' => APP_TAX_CAT);
     $defaults['selected'] = is_category() ? get_query_var('cat') : 0;
     // auto select the parent category if available
     if (empty($defaults['selected']) && !empty($_GET['action']) && 'change' == $_GET['action']) {
         $checkout = appthemes_get_checkout();
         $listing_id = $checkout ? $checkout->get_data('listing_id') : false;
         if ($listing_id) {
             $listing = get_post($listing_id);
             $categories = wp_get_post_terms($listing->ID, APP_TAX_CAT);
             $defaults['selected'] = !empty($categories) ? $categories[0]->parent ? $categories[0]->parent : $categories[0]->term_id : 0;
         }
     }
     $r = wp_parse_args($args, $defaults);
     $r['include_last_update_time'] = $r['show_last_update'];
     extract($r);
     $tab_index_attribute = '';
     if ((int) $tab_index > 0) {
         $tab_index_attribute = " tabindex=\"{$tab_index}\"";
     }
     // TODO: remove dirty fix, consider to use 2 parameters array: one for
     // get_categories() another for cp_category_dropdown_tree()
     unset($r['name']);
     $categories = get_categories($r);
     $name = esc_attr($name);
     $r['name'] = $name;
     $class = esc_attr($class);
     $id = $id ? esc_attr($id) : $name;
     $output = '';
     if (!empty($categories)) {
         $output = "<select name='{$name}' id='{$id}' class='{$class}' {$tab_index_attribute}>\n";
         if ($show_option_all) {
             $show_option_all = apply_filters('list_cats', $show_option_all);
             $selected = '0' === strval($r['selected']) ? " selected='selected'" : '';
             $output .= "\t<option value='0'{$selected}>{$show_option_all}</option>\n";
         }
         if ($show_option_none) {
             $show_option_none = apply_filters('list_cats', $show_option_none);
             $selected = '-1' === strval($r['selected']) ? " selected='selected'" : '';
             $output .= "\t<option value='-1'{$selected}>{$show_option_none}</option>\n";
         }
         if ($hierarchical) {
             $depth = $r['depth'];
             // Walk the full depth.
         } else {
             $depth = -1;
             // Flat.
         }
         $output .= cp_category_dropdown_tree($categories, $depth, $r);
         $output .= "</select>\n";
     }
     $output = apply_filters('wp_dropdown_cats', $output);
     if ($echo) {
         echo $output;
     } else {
         return $output;
     }
 }
Beispiel #3
0
function appthemes_get_previous_step()
{
    $checkout = appthemes_get_checkout();
    if (!$checkout) {
        return;
    }
    $current_step = _appthemes_get_step_from_query();
    return $checkout->get_previous_step($current_step);
}
Beispiel #4
0
 /**
  * Modifies the Order return URL by adding the current step ID.
  */
 public function filter_return_url($url)
 {
     $checkout = appthemes_get_checkout();
     if ($checkout) {
         $url = esc_url_raw(add_query_arg(array('step' => $this->step_id, 'checkout' => $checkout->get_checkout_type()), $url));
     }
     return $url;
 }