public function on_price_html($html, $_product)
 {
     $from = strstr($html, 'From') !== false ? ' From ' : ' ';
     $discount_price = false;
     $id = isset($_product->variation_id) ? $_product->variation_id : $_product->id;
     $working_price = isset($this->discounted_products[$id]) ? $this->discounted_products[$id] : $_product->get_price();
     $base_price = $_product->get_price();
     if ($this->pricing_by_store_category->is_applied_to($_product)) {
         if (floatval($working_price)) {
             $discount_price = $this->pricing_by_store_category->get_price($_product, $working_price);
             if ($discount_price && $discount_price != $base_price) {
                 $html = '<del>' . woocommerce_price($base_price) . '</del><ins>' . $from . woocommerce_price($discount_price) . '</ins>';
             }
         }
     }
     //Make sure we are using the price that was just discounted.
     $working_price = $discount_price ? $discount_price : $base_price;
     if ($this->pricing_by_membership->is_applied_to($_product)) {
         $discount_price = $this->pricing_by_membership->get_price($_product, $working_price);
         if (floatval($working_price)) {
             if ($discount_price && $discount_price != $base_price) {
                 $html = '<del>' . woocommerce_price($base_price) . '</del><ins>' . $from . woocommerce_price($discount_price) . '</ins>';
             }
         }
     }
     $this->discounted_products[$id] = $discount_price ? $discount_price : $base_price;
     return $html;
 }
/**
 * Define our custom columns contents shown in admin.
 * @param  string $column
 *
 */
function rpgc_custom_columns($column)
{
    global $post;
    $giftcardInfo = get_post_meta($post->ID, '_wpr_giftcard', true);
    switch ($column) {
        case "buyer":
            echo '<div><strong>' . esc_html(isset($giftcardInfo['from']) ? $giftcardInfo['from'] : '') . '</strong><br />';
            echo '<span style="font-size: 0.9em">' . esc_html(isset($giftcardInfo['fromEmail']) ? $giftcardInfo['fromEmail'] : '') . '</div>';
            break;
        case "recipient":
            echo '<div><strong>' . esc_html(isset($giftcardInfo['to']) ? $giftcardInfo['to'] : '') . '</strong><br />';
            echo '<span style="font-size: 0.9em">' . esc_html(isset($giftcardInfo['toEmail']) ? $giftcardInfo['toEmail'] : '') . '</span></div>';
            break;
        case "amount":
            $price = isset($giftcardInfo['amount']) ? $giftcardInfo['amount'] : '';
            echo woocommerce_price($price);
            break;
        case "balance":
            $price = isset($giftcardInfo['balance']) ? $giftcardInfo['balance'] : '';
            echo woocommerce_price($price);
            break;
        case "expiry_date":
            $expiry_date = isset($giftcardInfo['expiry_date']) ? $giftcardInfo['expiry_date'] : '';
            if ($expiry_date) {
                echo esc_html(date_i18n('F j, Y', strtotime($expiry_date)));
            } else {
                echo '&ndash;';
            }
            break;
    }
}
/**
 * Define our custom columns shown in admin.
 * @param  string $column
 *
 */
function rpgc_custom_columns($column)
{
    global $post, $woocommerce;
    switch ($column) {
        case "buyer":
            echo '<div><strong>' . esc_html(get_post_meta($post->ID, 'rpgc_from', true)) . '</strong><br />';
            echo '<span style="font-size: 0.9em">' . esc_html(get_post_meta($post->ID, 'rpgc_email_from', true)) . '</div>';
            break;
        case "recipient":
            echo '<div><strong>' . esc_html(get_post_meta($post->ID, 'rpgc_to', true)) . '</strong><br />';
            echo '<span style="font-size: 0.9em">' . esc_html(get_post_meta($post->ID, 'rpgc_email_to', true)) . '</span></div>';
            break;
        case "amount":
            $price = get_post_meta($post->ID, 'rpgc_amount', true);
            echo woocommerce_price($price);
            break;
        case "balance":
            $price = get_post_meta($post->ID, 'rpgc_balance', true);
            echo woocommerce_price($price);
            break;
        case "expiry_date":
            $expiry_date = get_post_meta($post->ID, 'rpgc_expiry_date', true);
            if ($expiry_date) {
                echo esc_html(date_i18n('F j, Y', strtotime($expiry_date)));
            } else {
                echo '&ndash;';
            }
            break;
    }
}
 /**
  * Converts the price for a bundled product. With bundled products, price
  * is passed "as-is" and it doesn't get converted into currency.
  *
  * @param string bundle_price_html The HTML snippet containing a
  * bundle's regular price in base currency.
  * @param WC_Product product The product being displayed.
  * @return string The HTML snippet with the price converted into currently
  * selected currency.
  */
 public function woocommerce_bundle_price_html($bundle_price_html, $product)
 {
     $product = $this->convert_product_prices($product);
     $bundle_price_html = $product->get_price_html_from_text();
     $bundle_price_html .= woocommerce_price($product->min_bundle_price);
     return $bundle_price_html;
 }
 function price($vlaue, $args = array())
 {
     $currency = isset($args['currency']) ? $args['currency'] : '';
     if (!$currency) {
         if (!isset($this->constants['woocommerce_currency'])) {
             $this->constants['woocommerce_currency'] = $currency = function_exists('get_woocommerce_currency') ? get_woocommerce_currency() : "USD";
         } else {
             $currency = $this->constants['woocommerce_currency'];
         }
     }
     $args['currency'] = $currency;
     $vlaue = trim($vlaue);
     $withoutdecimal = str_replace(".", "d", $vlaue);
     if (!isset($this->constants['price_format'][$currency][$withoutdecimal])) {
         if (!function_exists('woocommerce_price')) {
             if (!isset($this->constants['currency_symbol'])) {
                 $this->constants['currency_symbol'] = $currency_symbol = apply_filters('ic_commerce_currency_symbol', '&#36;', 'USD');
             } else {
                 $currency_symbol = $this->constants['currency_symbol'];
             }
             $vlaue = strlen(trim($vlaue)) > 0 ? $vlaue : 0;
             $v = $currency_symbol . "" . number_format($vlaue, 2, '.', ' ');
             $v = "<span class=\"amount\">{$v}</span>";
         } else {
             $v = woocommerce_price($vlaue, $args);
         }
         $this->constants['price_format'][$currency][$withoutdecimal] = $v;
     } else {
         $v = $this->constants['price_format'][$currency][$withoutdecimal];
     }
     return $v;
 }
 public function __construct()
 {
     $this->id = 'accountfunds';
     $this->method_title = __('Account Funds', 'woocommerce');
     // Support subscriptions
     $this->supports = array('subscriptions', 'products', 'subscription_cancellation', 'subscription_reactivation', 'subscription_suspension', 'subscription_amount_changes', 'subscription_payment_method_change', 'subscription_date_changes');
     // Load the form fields.
     $this->init_form_fields();
     // Load the settings.
     $this->init_settings();
     $this->title = $this->settings['title'];
     $wcaf_settings = get_option('wcaf_settings');
     $desc = sprintf(__("Available balance: %s", 'wc_account_funds'), x3m_get_account_funds());
     if ($wcaf_settings['give_discount'] == 1 && $wcaf_settings['discount_amount'] > 0) {
         $desc .= __('<br/>Use your account funds and get a %s discount on your order', 'wc_account_funds');
         $amount = floatval($wcaf_settings['discount_amount']);
         if ($wcaf_settings['discount_type'] == 'fixed') {
             $desc = sprintf($desc, woocommerce_price($amount));
         } else {
             $desc = sprintf($desc, $amount . '%');
         }
     }
     $this->description = $desc;
     add_action('woocommerce_update_options_payment_gateways', array(&$this, 'process_admin_options'));
     add_action('woocommerce_update_options_payment_gateways_' . $this->id, array(&$this, 'process_admin_options'));
     // Subscriptons
     add_action('scheduled_subscription_payment_' . $this->id, array($this, 'scheduled_subscription_payment'), 10, 3);
     // display the current payment method used for a subscription in the "My Subscriptions" table
     add_filter('woocommerce_my_subscriptions_recurring_payment_method', array($this, 'subscription_payment_method_name'), 10, 3);
 }
예제 #7
0
 /**
  * Pay all outstanding commission using Paypal Mass Pay
  *
  * @return array
  */
 public static function pay_now()
 {
     $mass_pay = new WCV_Mass_Pay();
     $mass_pay = $mass_pay->do_payments();
     $message = !empty($mass_pay['total']) ? $mass_pay['msg'] . '<br/>' . sprintf(__('Payment total: %s', 'wcvendors'), woocommerce_price($mass_pay['total'])) : $mass_pay['msg'];
     return array('message' => $message, 'status' => $mass_pay['status']);
 }
예제 #8
0
function road_woo_price_html($price, $product)
{
    if ($product->product_type == "variable") {
        if ($product->get_variation_sale_price() && $product->get_variation_regular_price() != $product->get_variation_sale_price()) {
            $rprice = $product->get_variation_regular_price();
            $sprice = $product->get_variation_sale_price();
            return '<span class="special-price">' . (is_numeric($sprice) ? woocommerce_price($sprice) : $sprice) . '</span><span class="old-price">' . (is_numeric($rprice) ? woocommerce_price($rprice) : $rprice) . '</span>';
        } else {
            $rprice = $product->get_variation_regular_price();
            return '<span class="special-price">' . (is_numeric($rprice) ? woocommerce_price($rprice) : $rprice) . '</span>';
        }
    }
    if ($product->price > 0) {
        if ($product->price && isset($product->regular_price) && $product->price != $product->regular_price) {
            $rprice = $product->regular_price;
            $sprice = $product->price;
            return '<span class="special-price">' . (is_numeric($sprice) ? woocommerce_price($sprice) : $sprice) . '</span><span class="old-price">' . (is_numeric($rprice) ? woocommerce_price($rprice) : $rprice) . '</span>';
        } else {
            $sprice = $product->price;
            return '<span class="special-price">' . (is_numeric($sprice) ? woocommerce_price($sprice) : $sprice) . '</span>';
        }
    } else {
        return '<span class="special-price">0</span>';
    }
}
    function widget($args, $instance)
    {
        $me = wp_get_current_user();
        if ($me->ID == 0) {
            return;
        }
        $funds = get_user_meta($me->ID, 'account_funds', true);
        if (empty($funds)) {
            $funds = 0;
        }
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
		<p><?php 
        printf(__('You currently have <b>%s</b> in your account', 'wc_account_funds'), woocommerce_price($funds));
        ?>
</p>
        <p style="text-align:center;"><a class="button" href="<?php 
        echo get_permalink(woocommerce_get_page_id('myaccount'));
        ?>
"><?php 
        _e('Deposit Funds', 'wc_account_funds');
        ?>
</a></p>
        <?php 
        echo $after_widget;
    }
 function render_input($args, $options = "", $default = "")
 {
     $_html = '';
     foreach ($options as $opt) {
         if ($default) {
             if (in_array($opt['option'], $default)) {
                 $checked = 'checked="checked"';
             } else {
                 $checked = '';
             }
         }
         if ($opt['price']) {
             $output = stripslashes(trim($opt['option'])) . ' (+ ' . woocommerce_price($opt['price']) . ')';
         } else {
             $output = stripslashes(trim($opt['option']));
         }
         $field_id = $args['name'] . '-meta-' . strtolower(preg_replace("![^a-z0-9]+!i", "_", $opt['option']));
         $_html .= '<label for="' . $field_id . '"> <input id="' . $field_id . '" data-price="' . $opt['price'] . '" type="checkbox" ';
         foreach ($args as $attr => $value) {
             if ($attr == 'name') {
                 $value .= '[]';
             }
             $_html .= $attr . '="' . stripslashes($value) . '"';
         }
         $_html .= ' value="' . $opt['option'] . '" ' . $checked . '>';
         $_html .= $output;
         $_html .= '</label>';
     }
     echo $_html;
 }
function display_price_in_variation_option_name($term)
{
    global $wpdb, $product;
    $term_temp = $term;
    $term = strtolower($term);
    $term = str_replace(' ', '-', $term);
    $result = $wpdb->get_col("SELECT slug FROM {$wpdb->prefix}terms WHERE name = '{$term}'");
    $term_slug = !empty($result) ? $result[0] : $term;
    $query = "SELECT postmeta.post_id AS product_id\nFROM {$wpdb->prefix}postmeta AS postmeta\nLEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id )\nWHERE postmeta.meta_key LIKE 'attribute_%'\nAND postmeta.meta_value = '{$term_slug}'\nAND products.post_parent = {$product->id}";
    $variation_id = $wpdb->get_col($query);
    $parent = wp_get_post_parent_id($variation_id[0]);
    if ($parent > 0) {
        $_product = new WC_Product_Variation($variation_id[0]);
        $testVariable = $_product->get_variation_attributes();
        $itemPrice = strip_tags(woocommerce_price($_product->get_price()));
        $getPrice = $_product->get_price();
        $itemPriceInt = (int) $getPrice;
        $term = $term_temp;
        //this is where you can actually customize how the price is displayed
        if ($itemPriceInt > 0) {
            return $term . ' (' . $itemPrice . ' incl. GST)';
        } else {
            return $term . ' (' . $itemPrice . ')';
        }
    }
    return $term;
}
 /**
  * Process this field after being posted
  * @return array on success, WP_ERROR on failure
  */
 public function get_cart_item_data()
 {
     $cart_item_data = array();
     foreach ($this->addon['options'] as $key => $option) {
         $option_key = empty($option['label']) ? $key : sanitize_title($option['label']);
         $posted = isset($this->value[$option_key]) ? $this->value[$option_key] : '';
         if ($posted === '') {
             continue;
         }
         $label = $this->get_option_label($option);
         $price = $this->get_option_price($option);
         switch ($this->addon['type']) {
             case "custom_price":
                 $price = floatval(sanitize_text_field($posted));
                 if ($price >= 0) {
                     $cart_item_data[] = array('name' => $label, 'value' => $price, 'price' => $price, 'display' => strip_tags(woocommerce_price($price)));
                 }
                 break;
             case "input_multiplier":
                 $posted = absint($posted);
                 $cart_item_data[] = array('name' => $label, 'value' => $posted, 'price' => $posted * $price);
                 break;
             default:
                 $cart_item_data[] = array('name' => $label, 'value' => wp_kses_post($posted), 'price' => $price);
                 break;
         }
     }
     return $cart_item_data;
 }
 function wcml_convert_price($formatted, $unformatted)
 {
     if (!is_admin()) {
         $currency = apply_filters('wcml_price_currency', get_woocommerce_currency());
         $formatted = strip_tags(woocommerce_price(apply_filters('wcml_raw_price_amount', $unformatted), array('currency' => $currency)));
     }
     return $formatted;
 }
 function mp_price($vlaue)
 {
     if (!function_exists('woocommerce_price') || 'WC_IS_MIS_WC_ACITVE' == false) {
         return apply_filters('mp_currency_symbol', '&#36;', 'USD') . $vlaue;
     } else {
         return woocommerce_price($vlaue);
     }
 }
 public static function format_price($price)
 {
     if (function_exists('woocommerce_price')) {
         return woocommerce_price($price);
     } else {
         return wc_price($price);
     }
 }
 public static function wc_price($price)
 {
     if (self::is_wc_version_gte_2_1()) {
         return wc_price($price);
     } else {
         return woocommerce_price($price);
     }
 }
예제 #17
0
/**
 * Calculates the price in 3 installments without interest.
 *
 * @return string Price in 3 installments.
 */
function cs_product_parceled()
{
    $product = get_product();
    if ($product->get_price_including_tax()) {
        $value = woocommerce_price($product->get_price_including_tax() / 3);
        return $value;
    }
}
예제 #18
0
function custom_variation_price($price, $product)
{
    $price = '';
    if (!$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price) {
        $price .= '<span class="from">' . _x('From', 'min_price', 'woocommerce') . ' </span>';
        $price .= woocommerce_price($product->get_price());
    }
    return $price;
}
function custom_variation_price($price, $product)
{
    $price = '';
    if (!$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price) {
        $price .= '<p style="margin-bottom: -10px !important; padding: 0 !important;"><span class="from" style="color: #000;">' . _x('From', 'min_price', 'woocommerce') . ' </span></p>';
    }
    $price .= woocommerce_price($product->min_variation_price);
    return $price;
}
function woocommerce_gravityforms_get_updated_price()
{
    global $woocommerce;
    header('Cache-Control: no-cache, must-revalidate');
    header('Content-type: application/json');
    $variation_id = isset($_POST['variation_id']) ? $_POST['variation_id'] : '';
    $product_id = isset($_POST['product_id']) ? $_POST['product_id'] : 0;
    $gform_total = isset($_POST['gform_total']) ? $_POST['gform_total'] : 0;
    $product_data = null;
    if (function_exists('get_product')) {
        $product_data = get_product($variation_id > 0 ? $variation_id : $product_id);
    } else {
        if ($variation_id > 0) {
            $product_data = new WC_Product_Variation($variation_id);
        } else {
            $product_data = new WC_Product($product_id);
        }
    }
    $discount_price = false;
    $gforms_discount_price = false;
    $base_price = $product_data->get_price();
    if (class_exists('WC_Dynamic_Pricing')) {
        $working_price = $base_price;
        $dynamic_pricing = WC_Dynamic_Pricing::instance();
        foreach ($dynamic_pricing->modules as $module) {
            if ($module->module_type == 'simple') {
                //Make sure we are using the price that was just discounted.
                $working_price = $discount_price ? $discount_price : $base_price;
                $working_price = $module->get_product_working_price($working_price, $product_data);
                if (floatval($working_price)) {
                    $discount_price = $module->get_discounted_price_for_shop($product_data, $working_price);
                }
            }
        }
        $gforms_base_price = $base_price + $gform_total;
        $gforms_working_price = $base_price + $gform_total;
        foreach ($dynamic_pricing->modules as $module) {
            if ($module->module_type == 'simple') {
                //Make sure we are using the price that was just discounted.
                $gforms_working_price = $gforms_discount_price ? $gforms_discount_price : $gforms_base_price;
                $gforms_working_price = $module->get_product_working_price($gforms_working_price, $product_data);
                if (floatval($gforms_working_price)) {
                    $gforms_discount_price = $module->get_discounted_price_for_shop($product_data, $gforms_working_price);
                }
            }
        }
    }
    $price = $discount_price ? $discount_price : $base_price;
    $gform_final_total = $gforms_discount_price ? $gforms_discount_price : $price + $gform_total;
    $result = array('formattedBasePrice' => apply_filters('woocommerce_gform_base_price', woocommerce_price($price), $product_data), 'formattedTotalPrice' => apply_filters('woocommerce_gform_total_price', woocommerce_price($gform_final_total), $product_data), 'formattedVariationTotal' => apply_filters('woocommerce_gform_variation_total_price', woocommerce_price($gform_total), $product_data));
    echo json_encode($result);
    die;
}
function rpgc_email_content_return($email)
{
    $customEmail = get_option('woocommerce_enable_giftcard_custom_message');
    if ($customEmail != '') {
        $customEmail .= '<div>';
        $customEmial .= '<h4>' . __('Gift Card Amount', 'rpgiftcards') . ': ' . woocommerce_price(wpr_get_giftcard_balance($giftCard->ID)) . '</h4>';
        $customEmail .= '<h4>' . __('Gift Card Number', 'rpgiftcards') . ': ' . $giftCard->post_title . '</h4>';
        $customEmail .= '</div>';
        return $customEmail;
    }
    return $email;
}
 function render_input($args, $ranges)
 {
     $_html = '<input name="_pricematrix" id="_pricematrix" type="hidden" value="' . esc_attr(json_encode($ranges)) . '" />';
     $_html .= '<p id="box-' . $name . '">' . stripslashes($args['description']) . '</p>';
     foreach ($ranges as $opt) {
         $_html .= '<div style="clear:both;border-bottom:1px #ccc dashed;">';
         $_html .= '<span>' . stripslashes(trim($opt['option'])) . '</span>';
         $_html .= '<span style="float:right">' . woocommerce_price(trim($opt['price'])) . '</span>';
         $_html .= '</div>';
     }
     echo $_html;
 }
function wcaf_user_column_values($value, $column_name, $user_id)
{
    global $woocommerce, $wpdb;
    if ($column_name == 'wcaf_funds') {
        $funds = get_user_meta($user_id, 'account_funds', true);
        if (empty($funds)) {
            $funds = 0;
        }
        $value = woocommerce_price($funds);
    }
    return $value;
}
예제 #24
0
function show_stock_report_row($post, $product, $nested = false)
{
    global $woocommerce;
    ?>
	<tr>
		<td><?php 
    echo $product->get_sku();
    ?>
</td>
		<td><?php 
    if (!$nested) {
        $post_title = $post->post_title;
    } else {
        $post_title = '';
    }
    // Get variation data
    if ($post->post_type == 'product_variation') {
        $post_title = trim(current(explode('-', $post_title)));
        $post_title .= ' &mdash; <small><em>';
        $list_attributes = array();
        $attributes = $product->get_variation_attributes();
        foreach ($attributes as $name => $attribute) {
            $list_attributes[] = $woocommerce->attribute_label(str_replace('attribute_', '', $name)) . ': <strong>' . $attribute . '</strong>';
        }
        $post_title .= implode(', ', $list_attributes);
        $post_title .= '</em></small>';
    }
    echo $post_title;
    ?>
</td>
		<td><?php 
    echo $post->ID;
    ?>
</td>
		<td><?php 
    echo $post->post_type == 'product' ? 'Product' : 'Variation';
    ?>
</td>
		<td><?php 
    echo woocommerce_price($product->get_price());
    ?>
</td>
		<td><?php 
    echo $product->stock;
    ?>
</td>
	</tr>
	<?php 
}
예제 #25
0
 function show_single_product_info()
 {
     global $post;
     $auction_display_mode = get_option('wplister_local_auction_display', 'off');
     if ($auction_display_mode == 'forced') {
         if ($listing = $this->is_published_on_ebay($post->ID)) {
             // view on ebay button
             echo '<p>';
             echo sprintf('<a href="%s" class="single_add_to_cart_button button alt" target="_blank">%s</a>', $listing->ViewItemURL, __('View on eBay', 'wplister'));
             echo '</p>';
             // hide woo elements
             echo '<style> form.cart { display:none } </style>';
         }
     } elseif ($auction_display_mode != 'off') {
         if ($listing = $this->is_on_auction($post->ID)) {
             // echo "<pre>";print_r($listing);echo"</pre>";die();
             $details = $this->getItemDetails($listing->ebay_id);
             if ($details['BidCount'] == 0) {
                 // do nothing if "only if bids" is enabled and there are more than 12 hours left
                 // $auction_display_mode = get_option( 'wplister_local_auction_display', 'off' );
                 $hours_left = (strtotime($listing->end_date) - gmdate('U')) / 3600;
                 if ($hours_left > 12 && $auction_display_mode == 'if_bid') {
                     return;
                 }
                 // start price
                 echo '<p itemprop="price" class="price startprice">' . __('Starting bid', 'wplister') . ': <span class="amount">' . woocommerce_price($listing->price) . '</span></p>';
             } else {
                 // current price
                 echo '<p itemprop="price" class="price startprice">' . __('Current bid', 'wplister') . ': <span class="amount">' . woocommerce_price($details['CurrentPrice']) . '</span>';
                 echo ' (' . $details['BidCount'] . __('bids', 'wplister') . ')';
                 echo '</p>';
             }
             // auction message
             if ($listing->end_date) {
                 $msg = __('This item is currently on auction and will end in %s', 'wplister');
                 $msg = sprintf($msg, human_time_diff(strtotime($listing->end_date)));
             } else {
                 $msg = __('This item is currently on auction on eBay.', 'wplister');
             }
             echo '<p>' . $msg . '</p>';
             // view on ebay button
             echo '<p>';
             echo sprintf('<a href="%s" class="single_add_to_cart_button button alt" target="_blank">%s</a>', $listing->ViewItemURL, __('View on eBay', 'wplister'));
             echo '</p>';
             // hide woo elements
             echo '<style> form.cart, p.price { display:none }  p.startprice { display:inline }  </style>';
         }
     }
 }
예제 #26
0
 /** @see WP_Widget */
 function widget($args, $instance)
 {
     global $woocommerce;
     if (is_cart() || is_checkout()) {
         return;
     }
     extract($args);
     if (!empty($instance['title'])) {
         $title = $instance['title'];
     } else {
         $title = __('Cart', 'woocommerce');
     }
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $hide_if_empty = isset($instance['hide_if_empty']) && $instance['hide_if_empty'] ? '1' : '0';
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     echo '<ul class="cart_list product_list_widget ';
     if ($hide_if_empty) {
         echo 'hide_cart_widget_if_empty';
     }
     echo '">';
     if (sizeof($woocommerce->cart->get_cart()) > 0) {
         foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) {
             $_product = $cart_item['data'];
             if ($_product->exists() && $cart_item['quantity'] > 0) {
                 echo '<li><a href="' . get_permalink($cart_item['product_id']) . '">';
                 echo $_product->get_image();
                 echo apply_filters('woocommerce_cart_widget_product_title', $_product->get_title(), $_product) . '</a>';
                 echo $woocommerce->cart->get_item_data($cart_item);
                 echo '<span class="quantity">' . $cart_item['quantity'] . ' &times; ' . woocommerce_price($_product->get_price()) . '</span></li>';
             }
         }
     } else {
         echo '<li class="empty">' . __('No products in the cart.', 'woocommerce') . '</li>';
     }
     echo '</ul>';
     if (sizeof($woocommerce->cart->get_cart()) > 0) {
         echo '<p class="total"><strong>' . __('Subtotal', 'woocommerce') . ':</strong> ' . $woocommerce->cart->get_cart_total() . '</p>';
         do_action('woocommerce_widget_shopping_cart_before_buttons');
         echo '<p class="buttons"><a href="' . $woocommerce->cart->get_cart_url() . '" class="button">' . __('View Cart &rarr;', 'woocommerce') . '</a> <a href="' . $woocommerce->cart->get_checkout_url() . '" class="button checkout">' . __('Checkout &rarr;', 'woocommerce') . '</a></p>';
     }
     echo $after_widget;
     if ($hide_if_empty && sizeof($woocommerce->cart->get_cart()) == 0) {
         $inline_js = "\n\t\t\t\tjQuery('.hide_cart_widget_if_empty').parent().hide();\n\t\t\t\tjQuery('body').bind('adding_to_cart', function(){\n\t\t\t\t\tjQuery(this).find('.hide_cart_widget_if_empty').parent().fadeIn();\n\t\t\t\t});\n\t\t\t";
         $woocommerce->add_inline_js($inline_js);
     }
 }
예제 #27
0
 public function menu_item()
 {
     global $woocommerce;
     // $woocommerce->cart->get_cart_total() is not a display function,
     // so we add tax if cart prices are set to display incl. tax
     // see https://github.com/woothemes/woocommerce/issues/6701
     if ($woocommerce->cart->display_cart_ex_tax) {
         $cart_contents_total = woocommerce_price($woocommerce->cart->cart_contents_total);
     } else {
         $cart_contents_total = woocommerce_price($woocommerce->cart->cart_contents_total + $woocommerce->cart->tax_total);
     }
     $cart_contents_total = apply_filters('woocommerce_cart_contents_total', $cart_contents_total);
     $menu_item = array('cart_url' => $woocommerce->cart->get_cart_url(), 'shop_page_url' => get_permalink(woocommerce_get_page_id('shop')), 'cart_contents_count' => $woocommerce->cart->get_cart_contents_count(), 'cart_total' => strip_tags($cart_contents_total));
     return $menu_item;
 }
예제 #28
0
 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 function widget($args, $instance)
 {
     global $woocommerce;
     extract($args);
     if (is_cart() || is_checkout()) {
         return;
     }
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Cart', 'woocommerce') : $instance['title'], $instance, $this->id_base);
     $hide_if_empty = empty($instance['hide_if_empty']) ? 0 : 1;
     if ($hide_if_empty) {
         echo '<div class="hide_cart_widget_if_empty">';
     }
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $_Twoot_Woo = new Twoot_Woo();
     $url = $_Twoot_Woo->shop_urls();
     $total_text = get_option('js_prices_include_tax') == 'yes' ? esc_attr__('Total', 'woocommerce') : esc_attr__('Subtotal', 'woocommerce');
     echo '<ul id="widget-woo-cart" class="cart-list clearfix">';
     if (sizeof($woocommerce->cart->cart_contents) > 0) {
         foreach ($woocommerce->cart->cart_contents as $cart_item_key => $cart_item) {
             $_product = $cart_item['data'];
             if ($_product->exists() && $cart_item['quantity'] > 0) {
                 echo '<li class="cart-item clearfix">';
                 echo '<div class="item-img"><a href="' . get_permalink($cart_item['product_id']) . '">' . $_product->get_image() . '</a></div>';
                 echo '<div class="item-info">';
                 echo '<a href="' . get_permalink($cart_item['product_id']) . '" class="title">' . apply_filters('woocommerce_cart_widget_product_title', $_product->get_title(), $_product) . '</a>';
                 echo '<span class="quantity">' . esc_attr__('Quantity:', 'woocommerce') . ' ' . $cart_item['quantity'] . '</span>';
                 echo '<span class="price">' . woocommerce_price($_product->get_price()) . '</span>';
                 echo '</div>';
                 echo '</li>';
             }
         }
         echo '<li class="total"><strong>' . $total_text . ': </strong>' . $woocommerce->cart->get_cart_total() . '</li>';
         echo '<li class="buttons">';
         echo '<a href="' . $url['cart'] . '" class="button button-dark button-medium">' . esc_attr__('View Cart', 'woocommerce') . '</a>';
         echo '<a href="' . $url['checkout'] . '" class="button button-dark button-medium checkout">' . esc_attr__('Checkout', 'woocommerce') . '</a>';
         echo '</li>';
     } else {
         echo '<li class="empty">' . esc_attr__('No products in the cart.', 'woocommerce') . '</li>';
     }
     echo '</ul>';
     echo $after_widget;
     if ($hide_if_empty) {
         echo '</div>';
     }
 }
예제 #29
0
function greek_woo_price_html($price, $product)
{
    // return $product->price;
    if ($product->price > 0) {
        if ($product->price && isset($product->regular_price) && $product->price != $product->regular_price) {
            $from = $product->regular_price;
            $to = $product->price;
            return '<span class="old-price">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</span><span class="special-price">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>';
        } else {
            $to = $product->price;
            return '<span class="special-price">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>';
        }
    } else {
        return '<span class="special-price">0</span>';
    }
}
 function render_input($args, $images = "", $default_selected = "")
 {
     // nm_personalizedproduct_pa($images);
     $_html = '<div class="pre_upload_image_box">';
     $img_index = 0;
     $popup_width = $args['popup-width'] == '' ? 600 : $args['popup-width'];
     $popup_height = $args['popup-height'] == '' ? 450 : $args['popup-height'];
     if ($images) {
         foreach ($images as $image) {
             $_html .= '<div class="pre_upload_image">';
             if ($image['id'] != '') {
                 $_html .= '<img src="' . wp_get_attachment_thumb_url($image['id']) . '" />';
             } else {
                 $_html .= '<img width="150" height="150" src="' . $image['link'] . '" />';
             }
             // for bigger view
             $_html .= '<div style="display:none" id="pre_uploaded_image_' . $args['id'] . '-' . $img_index . '"><img style="margin: 0 auto;display: block;" src="' . $image['link'] . '" /></div>';
             $_html .= '<div class="input_image">';
             if ($args['multiple-allowed'] == 'on') {
                 $_html .= '<input type="checkbox" data-price="' . $image['price'] . '" data-title="' . stripslashes($image['title']) . '" name="' . $args['name'] . '[]" value="' . esc_attr(json_encode($image)) . '" />';
             } else {
                 //default selected
                 $checked = $image['title'] == $default_selected ? 'checked = "checked"' : '';
                 $_html .= '<input type="radio" data-price="' . $image['price'] . '" data-title="' . stripslashes($image['title']) . '" data-type="' . stripslashes($args['data-type']) . '" name="' . $args['name'] . '" value="' . esc_attr(json_encode($image)) . '" ' . $checked . ' />';
             }
             $price = '';
             if (function_exists('woocommerce_price') && $image['price'] > 0) {
                 $price = woocommerce_price($image['price']);
             }
             // image big view
             $_html .= '<a href="#TB_inline?width=' . $popup_width . '&height=' . $popup_height . '&inlineId=pre_uploaded_image_' . $args['id'] . '-' . $img_index . '" class="thickbox" title="' . $image['title'] . '"><img width="15" src="' . $this->plugin_meta['url'] . '/images/zoom.png" /></a>';
             $_html .= '<div class="p_u_i_name">' . stripslashes($image['title']) . ' ' . $price . '</div>';
             $_html .= '</div>';
             //input_image
             $_html .= '</div>';
             $img_index++;
         }
     }
     $_html .= '<div style="clear:both"></div>';
     //container_buttons
     $_html .= '</div>';
     //container_buttons
     echo $_html;
     $this->get_input_js($args);
 }