예제 #1
0
function wpsc_shipping_region_list($selected_country, $selected_region, $deprecated = false, $id = 'region')
{
    $output = '';
    if (false !== $deprecated) {
        _wpsc_deprecated_argument(__FUNCTION, '3.8.14');
    }
    $country = new WPSC_Country($selected_country);
    $regions = $country->get_regions();
    $output .= "<select class=\"wpsc-visitor-meta\" data-wpsc-meta-key=\"shippingregion\" name=\"region\"  id=\"{$id}\" >\n\r";
    if (count($regions) > 0) {
        foreach ($regions as $region_id => $region) {
            $selected = '';
            if ($selected_region == $region_id) {
                $selected = "selected='selected'";
            }
            $output .= "<option {$selected} value='{$region_id}'>" . esc_attr(htmlspecialchars($region->get_name())) . "</option>\n\r";
        }
        $output .= '';
    }
    $output .= '</select>';
    return $output;
}
예제 #2
0
/**
 * Checks and replaces the Page title with the category title if on a category page
 *
 * @since 3.8
 * @access public
 *
 * @param string    $title      The Page Title
 * @param int       $id         The Page ID
 * @return string   $title      The new title
 *
 * @uses in_the_loop()                  Returns true if you are  in the loop
 * @uses _wpsc_is_in_custom_loop()      Returns true if in the WPSC custom loop
 * @uses is_tax()                       Returns true if you are on the supplied registered taxonomy
 * @uses get_term_by()                  Gets term object by defined item, and what you pass
 * @uses get_query_var()                Gets query var from wp_query
 */
function wpsc_the_category_title($title = '', $id = '')
{
    if (!empty($id)) {
        _wpsc_deprecated_argument(__FUNCTION__, '3.8.10', 'The $id param is not used. If you are trying to get the title of the category use get_term');
    }
    if (!in_the_loop() || _wpsc_is_in_custom_loop()) {
        return $title;
    }
    $term = null;
    if (is_tax('wpsc_product_category')) {
        $term = get_term_by('slug', get_query_var('wpsc_product_category'), 'wpsc_product_category');
    } elseif (is_tax('product_tag')) {
        $term = get_term_by('slug', get_query_var('term'), 'product_tag');
    }
    // is_tax
    if ($term) {
        return $term->name;
    }
    return $title;
}
 public function exists()
 {
     if (defined('WPSC_LOAD_DEPRECATED') && WPSC_LOAD_DEPRECATED) {
         _wpsc_deprecated_argument(__FUNCTION__, '3.8.14', self::_function_not_available_message(__FUNCTION__));
     }
     return true;
 }
 /**
  * Deletes a log from the database.
  *
  * @access  public
  * @since   3.8.9
  *
  * @uses  $wpdb                              Global database instance.
  * @uses  wpsc_is_store_admin()              Check user has admin capabilities.
  * @uses  WPSC_Purchase_Log::delete_cache()  Delete purchaselog cache.
  * @uses  WPSC_Claimed_Stock                 Claimed Stock class.
  *
  * @param   string   $log_id   ID of the log.
  * @return  boolean            Deleted successfully.
  */
 public function delete($log_id = false)
 {
     global $wpdb;
     if (!(isset($this) && get_class($this) == __CLASS__)) {
         _wpsc_doing_it_wrong('WPSC_Purchase_Log::delete', __('WPSC_Purchase_Log::delete() is no longer a static method and should not be called statically.', 'wpsc'), '3.9.0');
     }
     if (false !== $log_id) {
         _wpsc_deprecated_argument(__FUNCTION__, '3.9.0', 'The $log_id param is not used. You must first create an instance of WPSC_Purchase_Log before calling this method.');
     }
     if (!wpsc_is_store_admin()) {
         return false;
     }
     $log_id = $this->get('id');
     if ($log_id > 0) {
         do_action('wpsc_purchase_log_before_delete', $log_id);
         self::delete_cache($log_id);
         // Delete claimed stock
         $purchlog_status = $wpdb->get_var($wpdb->prepare("SELECT `processed` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`= %d", $log_id));
         if ($purchlog_status == WPSC_Purchase_Log::CLOSED_ORDER || $purchlog_status == WPSC_Purchase_Log::INCOMPLETE_SALE) {
             $claimed_query = new WPSC_Claimed_Stock(array('cart_id' => $log_id, 'cart_submitted' => 1));
             $claimed_query->clear_claimed_stock(0);
         }
         // Delete cart content, submitted data, then purchase log
         $wpdb->query($wpdb->prepare("DELETE FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = %d", $log_id));
         $wpdb->query($wpdb->prepare("DELETE FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` IN (%d)", $log_id));
         $wpdb->query($wpdb->prepare("DELETE FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = %d LIMIT 1", $log_id));
         do_action('wpsc_purchase_log_delete', $log_id);
         return true;
     }
     return false;
 }