Exemplo n.º 1
0
function manage_product_columns($column_name, $product_id)
{
    $price_value = product_price($product_id);
    switch ($column_name) {
        case 'id':
            echo $product_id;
            break;
        case 'shortcode':
            echo '[show_products product="' . $product_id . '"]';
            break;
        case 'price':
            if ($price_value != '') {
                echo price_format($price_value);
            }
            break;
        case 'image':
            echo the_post_thumbnail(array(40, 40));
            break;
        case 'product_cat':
            echo get_the_term_list($product_id, 'al_product-cat', '', ', ', '');
            break;
        default:
            break;
    }
}
Exemplo n.º 2
0
 /**
  * Save product info
  *
  * @param Illuminate\Http\Request $request
  *
  * @return type
  */
 public function ajaxSaveProduct(Request $request)
 {
     //Only accept ajax request
     if ($request->ajax() && $request->isMethod('POST')) {
         if (store() === null) {
             return pong(0, _t('not_found'), 404);
         }
         $store = store();
         $productId = (int) $request->get('id');
         if ($productId) {
             $product = $store->products->find($productId);
         } else {
             $product = new Product();
         }
         if ($product === null) {
             return pong(0, _t('not_found'), 404);
         }
         $rules = $this->_product->getRules();
         $messages = $this->_product->getMessages();
         if ($productId) {
             $rules = remove_rules($rules, 'product_image_1');
         }
         $validator = Validator::make($request->all(), $rules, $messages);
         $tempImages = [$request->get('product_image_1'), $request->get('product_image_2'), $request->get('product_image_3'), $request->get('product_image_4')];
         if ($validator->fails()) {
             return pong(0, $validator->messages(), is_null($product) ? 404 : 403);
         }
         /**
          *  1. Copy product images from temporary folder to product folder.
          *  2. Delete old product image(s).
          *  3. Save product.
          */
         try {
             // 1
             $images = $this->_copyTempProductImages($tempImages);
             // 2
             if ($productId) {
                 $this->_deleteOldImages($images, $product->images);
             }
             // 3
             $product->store_id = $store->id;
             $product->name = $request->get('name');
             $product->price = $request->get('price');
             $product->old_price = $request->get('old_price');
             $product->description = $request->get('description');
             $product->setImages($images);
             $product->save();
         } catch (Exception $ex) {
             return pong(0, _t('opp'), 500);
         }
         return pong(1, ['messages' => _t('saved_info'), 'data' => ['id' => $product->id, 'name' => $product->name, 'price' => product_price($product->price), 'old_price' => product_price($product->old_price), 'image' => ($i = $product->toImage()->image_1) !== null ? product_image($i->medium) : '']]);
     }
 }
Exemplo n.º 3
0
/**
 * Checks if product has price set
 * @param type $product_id
 * @return boolean
 */
function has_product_price($product_id = null)
{
    $product_id = empty($product_id) ? get_the_ID() : $product_id;
    $price = product_price($product_id, 1);
    if (!empty($price)) {
        return true;
    }
    return false;
}
Exemplo n.º 4
0
/**
 * Shows product price
 * @param type $atts
 * @return string
 */
function ic_product_price($atts)
{
    $args = shortcode_atts(array('product' => get_the_ID(), 'formatted' => 1), $atts);
    $price = product_price($args['product']);
    if (!empty($price) && $args['formatted'] == 1) {
        $price = price_format($price);
    }
    return $price;
}
Exemplo n.º 5
0
function set_archive_price($archive_price, $post)
{
    $price_value = product_price($post->ID);
    if (!empty($price_value)) {
        $archive_price = '<span class="product-price ' . design_schemes('color', 0) . '">';
        $archive_price .= price_format($price_value);
        $archive_price .= '</span>';
    }
    return $archive_price;
}
Exemplo n.º 6
0
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
/**
 * The template to display product price on product page or with a shortcode
 *
 * Copy it to your theme implecode folder to edit the output: your-theme-folder-name/implecode/product-price.php
 *
 * @version		1.1.2
 * @package		ecommerce-product-catalog/templates/template-parts/product-page
 * @author 		Norbert Dreszer
 */
$product_id = ic_get_product_id();
$single_names = get_single_names();
$price = price_format(product_price($product_id));
if (!empty($price)) {
    ?>
	<table class="price-table">
		<tr>
			<td class="price-label"><?php 
    echo $single_names['product_price'];
    ?>
</td>
			<td class="price-value <?php 
    design_schemes();
    ?>
"><?php 
    echo $price;
    ?>
</td>