Ejemplo n.º 1
0
 /**
  * Format price
  *
  * @param float $price
  * @param array $args
  *
  * @return string
  */
 public static function price($price, $args = array())
 {
     /** @var Plugin $wpcm */
     $wpcm = wp_car_manager();
     $args = apply_filters('wpcm_format_price_args', wp_parse_args($args, array('ex_tax_label' => false, 'currency' => '', 'decimal_separator' => $wpcm->service('settings')->get_option('decimal_separator'), 'thousand_separator' => $wpcm->service('settings')->get_option('thousand_separator'), 'decimals' => 0, 'price_format' => Price::get_price_format())));
     $negative = $price < 0;
     $price = floatval($negative ? $price * -1 : $price);
     $price = number_format($price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator']);
     $formatted_price = ($negative ? '-' : '') . sprintf($args['price_format'], Currency::get_currency_symbol(), $price);
     $return = '<span class="amount">' . $formatted_price . '</span>';
     return $return;
 }
Ejemplo n.º 2
0
 /**
  * Sets up the setting fields
  */
 private function setup_fields()
 {
     $this->fields = apply_filters('wpcm_fields', array('general' => array(__('General', 'wp-car-manager'), array(array('name' => 'listings_page', 'label' => __('Listings Page', 'wp-car-manager'), 'desc' => __('Choose the page that will display your listings. Note that this page will need to have the <code>[wpcm_cars]</code> shortcode to actually display listings.', 'wp-car-manager'), 'type' => 'select', 'options' => Helper\Pages::get_pages()), array('name' => 'currency', 'label' => __('Currency', 'wp-car-manager'), 'desc' => __('Choose the currency used in your price fields.', 'wp-car-manager'), 'type' => 'select', 'options' => Helper\Currency::get_currencies()), array('name' => 'currency_pos', 'label' => __('Currency Position', 'wp-car-manager'), 'desc' => __('', 'wp-car-manager'), 'desc' => __('The position of the currency symbol.', 'wp-car-manager'), 'type' => 'select', 'options' => array('left' => sprintf(__('Left %s', 'wp-car-manager'), Helper\Currency::get_currency_symbol() . '99' . $this->get_option('decimal_separator') . '99'), 'right' => sprintf(__('Right %s', 'wp-car-manager'), '99' . $this->get_option('decimal_separator') . '99' . Helper\Currency::get_currency_symbol()), 'left_space' => sprintf(__('Left with space %s', 'wp-car-manager'), Helper\Currency::get_currency_symbol() . ' 99' . $this->get_option('decimal_separator') . '99'), 'right_space' => sprintf(__('Right with space %s', 'wp-car-manager'), '99' . $this->get_option('decimal_separator') . '99 ' . Helper\Currency::get_currency_symbol()))), array('name' => 'decimal_separator', 'label' => __('Decimal Separator', 'wp-car-manager'), 'desc' => __('The decimal separator of distance unites and prices.', 'wp-car-manager')), array('name' => 'thousand_separator', 'label' => __('Thousand Separator', 'wp-car-manager'), 'desc' => __('The thousand separator of displayed distance unites and prices.', 'wp-car-manager')), array('name' => 'distance_unit', 'label' => __('Distance Unit', 'wp-car-manager'), 'desc' => __('The unit type your distances are in (e.g. Mileage).', 'wp-car-manager'), 'type' => 'select', 'options' => array('miles' => __('Miles', 'wp-car-manager'), 'km' => __('Kilometers', 'wp-car-manager'))))), 'contact' => array(__('Contact', 'wp-car-manager'), array(array('name' => 'contact_email', 'label' => __('Contact Email Address', 'wp-car-manager'), 'desc' => __('The email address people can send an email to.', 'wp-car-manager')), array('name' => 'contact_phone', 'label' => __('Contact Phone Number', 'wp-car-manager'), 'desc' => __('The phone number people can call to.', 'wp-car-manager'))))));
 }
Ejemplo n.º 3
0
 /**
  * Sets up the setting fields
  */
 private function setup_fields()
 {
     $this->fields = apply_filters('wpcm_fields', array('general' => array(__('General', 'wp-car-manager'), array(array('name' => 'currency', 'label' => __('Currency', 'wp-car-manager'), 'desc' => __('Choose the currency used in your price fields.', 'wp-car-manager'), 'type' => 'select', 'options' => Helper\Currency::get_currencies()), array('name' => 'currency_pos', 'label' => __('Currency Position', 'wp-car-manager'), 'desc' => __('', 'wp-car-manager'), 'desc' => __('The position of the currency symbol.', 'wp-car-manager'), 'type' => 'select', 'options' => array('left' => sprintf(__('Left %s', 'wp-car-manager'), Helper\Currency::get_currency_symbol() . '99' . $this->get_option('decimal_separator') . '99'), 'right' => sprintf(__('Right %s', 'wp-car-manager'), '99' . $this->get_option('decimal_separator') . '99' . Helper\Currency::get_currency_symbol()), 'left_space' => sprintf(__('Left with space %s', 'wp-car-manager'), Helper\Currency::get_currency_symbol() . ' 99' . $this->get_option('decimal_separator') . '99'), 'right_space' => sprintf(__('Right with space %s', 'wp-car-manager'), '99' . $this->get_option('decimal_separator') . '99 ' . Helper\Currency::get_currency_symbol()))), array('name' => 'decimal_separator', 'label' => __('Decimal Separator', 'wp-car-manager'), 'desc' => __('The decimal separator of distance unites and prices.', 'wp-car-manager')), array('name' => 'thousand_separator', 'label' => __('Thousand Separator', 'wp-car-manager'), 'desc' => __('The thousand separator of displayed distance unites and prices.', 'wp-car-manager')), array('name' => 'distance_unit', 'label' => __('Distance Unit', 'wp-car-manager'), 'desc' => __('The unit type your distances are in (e.g. Mileage).', 'wp-car-manager'), 'type' => 'select', 'options' => array('miles' => __('Miles', 'wp-car-manager'), 'km' => __('Kilometers', 'wp-car-manager'))), array('name' => 'date_format', 'label' => __('Date Format', 'wp-car-manager'), 'desc' => __('The way dates are formatted.', 'wp-car-manager')))), 'listings' => array(__('Listings', 'wp-car-manager'), array(array('name' => 'listings_hide_sold', 'label' => __('Hide Sold Listings', 'wp-car-manager'), 'cb_label' => __('Hide sold listings from listing pages', 'wp-car-manager'), 'desc' => __('If enabled, listings marked as sold will no longer be listed on your listing pages.', 'wp-car-manager'), 'type' => 'checkbox'), array('name' => 'listings_ppp', 'label' => __('Listings Per Page', 'wp-car-manager'), 'desc' => sprintf(__('The amount of listings per page. Enter %s to disable pagination.', 'wp-car-manager'), '<code>-1</code>')))), 'submission' => array(__('Submission', 'wp-car-manager'), array(array('name' => 'account_creation', 'label' => __('Account Creation', 'wp-car-manager'), 'cb_label' => __('Allow account creation', 'wp-car-manager'), 'desc' => __('If enabled, non-logged in users will be able to create an account by entering their email address on the submission form.', 'wp-car-manager'), 'type' => 'checkbox'), array('name' => 'account_username', 'label' => __('Account Username', 'wp-car-manager'), 'cb_label' => __('Automatically Generate Username from Email Address', 'wp-car-manager'), 'desc' => __('If enabled, a username will be generated from the first part of the user email address. Otherwise, a username field will be shown.', 'wp-car-manager'), 'type' => 'checkbox'), array('name' => 'account_role', 'label' => __('Account Role', 'wp-car-manager'), 'desc' => __('If you enable registration on your submission form, choose a role for the new user.', 'wp-car-manager'), 'type' => 'select', 'options' => Helper\Roles::get_roles()), array('name' => 'moderate_new_listings', 'label' => __('Moderate New Listings', 'wp-car-manager'), 'cb_label' => __('New listing submissions require admin approval', 'wp-car-manager'), 'desc' => __('If enabled, new submissions will be inactive, pending admin approval.', 'wp-car-manager'), 'type' => 'checkbox'), array('name' => 'listing_duration', 'label' => __('Listing Duration', 'wp-car-manager'), 'desc' => sprintf(__('How many %sdays%s listings are live before expiring. Can be left blank to never expire.', 'wp-car-manager'), '<strong>', '</strong>')))), 'contact' => array(__('Contact', 'wp-car-manager'), array(array('name' => 'contact_email', 'label' => __('Contact Email Address', 'wp-car-manager'), 'desc' => __('The email address people can send an email to.', 'wp-car-manager')), array('name' => 'contact_phone', 'label' => __('Contact Phone Number', 'wp-car-manager'), 'desc' => __('The phone number people can call to.', 'wp-car-manager')))), 'pages' => array(__('Pages', 'wp-car-manager'), array(array('name' => 'page_submit', 'label' => __('Submit Car Page Form', 'wp-car-manager'), 'desc' => sprintf(__('Select the page where you have placed the %s shortcode.', 'wp-car-manager'), '<a href="https://www.wpcarmanager.com/kb/submit-car-form/" target="_blank">[wpcm_submit_car_form]</a>'), 'type' => 'select', 'options' => Helper\Pages::get_pages()), array('name' => 'page_dashboard', 'label' => __('Car Dashboard Page', 'wp-car-manager'), 'desc' => sprintf(__('Select the page where you have placed the %s shortcode.', 'wp-car-manager'), '<a href="https://www.wpcarmanager.com/kb/car-dashboard/" target="_blank">[wpcm_dashboard]</a>'), 'type' => 'select', 'options' => Helper\Pages::get_pages()), array('name' => 'page_listings', 'label' => __('Car Listings Page', 'wp-car-manager'), 'desc' => sprintf(__('Select the page where you have placed the %s shortcode.', 'wp-car-manager'), '<a href="https://www.wpcarmanager.com/kb/listings-page/" target="_blank">[wpcm_cars]</a>'), 'type' => 'select', 'options' => Helper\Pages::get_pages())))));
 }