Пример #1
1
function listProductUpdateData($products, $setUrl = 0)
{
    $jshopConfig = JSFactory::getConfig();
    $userShop = JSFactory::getUserShop();
    $taxes = JSFactory::getAllTaxes();
    if ($jshopConfig->product_list_show_manufacturer) {
        $manufacturers = JSFactory::getAllManufacturer();
    }
    if ($jshopConfig->product_list_show_vendor) {
        $vendors = JSFactory::getAllVendor();
    }
    if ($jshopConfig->show_delivery_time) {
        $deliverytimes = JSFactory::getAllDeliveryTime();
    }
    $image_path = $jshopConfig->image_product_live_path;
    $noimage = $jshopConfig->noimage;
    JPluginHelper::importPlugin('jshoppingproducts');
    $dispatcher = JDispatcher::getInstance();
    foreach ($products as $key => $value) {
        $dispatcher->trigger('onListProductUpdateDataProduct', array(&$products, &$key, &$value));
        $use_userdiscount = 1;
        if ($jshopConfig->user_discount_not_apply_prod_old_price && $products[$key]->product_old_price > 0) {
            $use_userdiscount = 0;
        }
        $products[$key]->_original_product_price = $products[$key]->product_price;
        $products[$key]->product_price_wp = $products[$key]->product_price;
        $products[$key]->product_price_default = 0;
        if ($jshopConfig->product_list_show_min_price) {
            if ($products[$key]->min_price > 0) {
                $products[$key]->product_price = $products[$key]->min_price;
            }
        }
        $products[$key]->show_price_from = 0;
        if ($jshopConfig->product_list_show_min_price && $value->different_prices) {
            $products[$key]->show_price_from = 1;
        }
        $products[$key]->product_price = getPriceFromCurrency($products[$key]->product_price, $products[$key]->currency_id);
        $products[$key]->product_old_price = getPriceFromCurrency($products[$key]->product_old_price, $products[$key]->currency_id);
        $products[$key]->product_price_wp = getPriceFromCurrency($products[$key]->product_price_wp, $products[$key]->currency_id);
        $products[$key]->product_price = getPriceCalcParamsTax($products[$key]->product_price, $products[$key]->tax_id);
        $products[$key]->product_old_price = getPriceCalcParamsTax($products[$key]->product_old_price, $products[$key]->tax_id);
        $products[$key]->product_price_wp = getPriceCalcParamsTax($products[$key]->product_price_wp, $products[$key]->tax_id);
        if ($userShop->percent_discount && $use_userdiscount) {
            $products[$key]->product_price_default = $products[$key]->_original_product_price;
            $products[$key]->product_price_default = getPriceFromCurrency($products[$key]->product_price_default, $products[$key]->currency_id);
            $products[$key]->product_price_default = getPriceCalcParamsTax($products[$key]->product_price_default, $products[$key]->tax_id);
            $products[$key]->product_price = getPriceDiscount($products[$key]->product_price, $userShop->percent_discount);
            $products[$key]->product_old_price = getPriceDiscount($products[$key]->product_old_price, $userShop->percent_discount);
            $products[$key]->product_price_wp = getPriceDiscount($products[$key]->product_price_wp, $userShop->percent_discount);
        }
        if ($jshopConfig->list_products_calc_basic_price_from_product_price) {
            $products[$key]->basic_price_info = getProductBasicPriceInfo($value, $products[$key]->product_price_wp);
        } else {
            $products[$key]->basic_price_info = getProductBasicPriceInfo($value, $products[$key]->product_price);
        }
        if ($value->tax_id) {
            $products[$key]->tax = $taxes[$value->tax_id];
        }
        if ($jshopConfig->product_list_show_manufacturer && $value->product_manufacturer_id && isset($manufacturers[$value->product_manufacturer_id])) {
            $products[$key]->manufacturer = $manufacturers[$value->product_manufacturer_id];
        } else {
            $products[$key]->manufacturer = new stdClass();
            $products[$key]->manufacturer->name = '';
        }
        if ($jshopConfig->admin_show_product_extra_field) {
            $products[$key]->extra_field = getProductExtraFieldForProduct($value);
        } else {
            $products[$key]->extra_field = '';
        }
        if ($jshopConfig->product_list_show_vendor) {
            $vendordata = $vendors[$value->vendor_id];
            $vendordata->products = SEFLink("index.php?option=com_jshopping&controller=vendor&task=products&vendor_id=" . $vendordata->id, 1);
            $products[$key]->vendor = $vendordata;
        } else {
            $products[$key]->vendor = '';
        }
        if ($jshopConfig->hide_delivery_time_out_of_stock && $products[$key]->product_quantity <= 0) {
            $products[$key]->delivery_times_id = 0;
            $value->delivery_times_id = 0;
        }
        if ($jshopConfig->show_delivery_time && $value->delivery_times_id) {
            $products[$key]->delivery_time = $deliverytimes[$value->delivery_times_id];
        } else {
            $products[$key]->delivery_time = '';
        }
        $products[$key]->_display_price = getDisplayPriceForProduct($products[$key]->product_price);
        if (!$products[$key]->_display_price) {
            $products[$key]->product_old_price = 0;
            $products[$key]->product_price_default = 0;
            $products[$key]->basic_price_info['price_show'] = 0;
            $products[$key]->tax = 0;
            $jshopConfig->show_plus_shipping_in_product = 0;
        }
        if ($jshopConfig->product_list_show_qty_stock) {
            $products[$key]->qty_in_stock = getDataProductQtyInStock($products[$key]);
        }
        $image = getPatchProductImage($products[$key]->image, 'thumb');
        $products[$key]->product_name_image = $products[$key]->image;
        $products[$key]->product_thumb_image = $image;
        if (!$image) {
            $image = $noimage;
        }
        $products[$key]->image = $image_path . "/" . $image;
        $products[$key]->template_block_product = "product.php";
        if (!$jshopConfig->admin_show_product_labels) {
            $products[$key]->label_id = null;
        }
        if ($products[$key]->label_id) {
            $image = getNameImageLabel($products[$key]->label_id);
            if ($image) {
                $products[$key]->_label_image = $jshopConfig->image_labels_live_path . "/" . $image;
            }
            $products[$key]->_label_name = getNameImageLabel($products[$key]->label_id, 2);
        }
        if ($jshopConfig->display_short_descr_multiline) {
            $products[$key]->short_description = nl2br($products[$key]->short_description);
        }
    }
    if ($setUrl) {
        addLinkToProducts($products, 0, 1);
    }
    $dispatcher->trigger('onListProductUpdateData', array(&$products));
    return $products;
}
Пример #2
0
 function loadproductinfo()
 {
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onLoadInfoProduct', array());
     $id_vendor_cuser = getIdVendorForCUser();
     $product_id = JRequest::getInt('product_id');
     $layout = JRequest::getVar('layout', 'productinfo_json');
     if ($id_vendor_cuser && $product_id) {
         checkAccessVendorToProduct($id_vendor_cuser, $product_id);
     }
     $products = $this->getModel("products");
     $product = JTable::getInstance('product', 'jshop');
     $product->load($product_id);
     $product->getDescription();
     $res = array();
     $res['product_id'] = $product->product_id;
     $res['product_ean'] = $product->product_ean;
     $res['product_price'] = $product->product_price;
     $res['delivery_times_id'] = $product->delivery_times_id;
     $res['vendor_id'] = fixRealVendorId($product->vendor_id);
     $res['product_weight'] = $product->product_weight;
     $res['product_tax'] = $product->getTax();
     $res['product_name'] = $product->name;
     $res['thumb_image'] = getPatchProductImage($product->image, 'thumb');
     $view = $this->getView("product_edit", 'html');
     $view->setLayout($layout);
     $view->assign('res', $res);
     $view->assign('edit', null);
     $view->assign('product', $product);
     $dispatcher->trigger('onBeforeDisplayLoadInfoProduct', array(&$view));
     $view->display();
     die;
 }
Пример #3
0
            <?php 
        }
        ?>
        </div>
    <?php 
    }
    ?>
    <?php 
    if ($row->image) {
        ?>
        <a href="index.php?option=com_jshopping&controller=products&task=edit&product_id=<?php 
        print $row->product_id;
        ?>
">
            <img src="<?php 
        print getPatchProductImage($row->image, 'thumb', 1);
        ?>
" width="90" border="0" />
        </a>
    <?php 
    }
    ?>
   </td>
   <td>
     <b><a href="index.php?option=com_jshopping&controller=products&task=edit&product_id=<?php 
    print $row->product_id;
    ?>
"><?php 
    echo $row->name;
    ?>
</a></b>
Пример #4
0
 function getImages()
 {
     if (isset($this->attribute_active_data->ext_data) && $this->attribute_active_data->ext_data) {
         $list = $this->attribute_active_data->ext_data->getImages();
         if (count($list)) {
             return $list;
         }
     }
     $query = "SELECT I.*, IF(P.image=I.image_name,0,1) as sort FROM `#__jshopping_products_images` as I left join `#__jshopping_products` as P on P.product_id=I.product_id\n                 WHERE I.product_id = '" . $this->_db->escape($this->product_id) . "' ORDER BY sort, I.ordering";
     $this->_db->setQuery($query);
     $list = $this->_db->loadObjectList();
     foreach ($list as $k => $v) {
         $title = $v->name;
         if (!$title) {
             $title = $this->getName();
         }
         $list[$k]->_title = $title;
         $list[$k]->image_thumb = getPatchProductImage($v->image_name, 'thumb');
         $list[$k]->image_full = getPatchProductImage($v->image_name, 'full');
     }
     return $list;
 }
Пример #5
0
            <a href="index.php?option=com_jshopping&controller=products&task=edit&product_id=<?php 
    print $row->product_id;
    ?>
">
            <?php 
    if (strlen($row->image) > 0) {
        ?>
                <img src="<?php 
        print getPatchProductImage($row->image, 'thumb', 1);
        ?>
" width="90" border="0" />
            <?php 
    } else {
        ?>
                <img src="<?php 
        print getPatchProductImage($this->config->noimage, '', 1);
        ?>
" width="90" border="0" />
            <?php 
    }
    ?>
            </a>
        </div>
        <div style="padding-top:5px;"><input type="button" class="btn btn-small btn-success" value="<?php 
    print _JSHOP_ADD;
    ?>
" onclick="add_to_list_relatad(<?php 
    print $row->product_id;
    ?>
)"></div>
    </div>
Пример #6
0
">
            <input type="text" name="old_image_descr[<?php 
        print $image->image_id;
        ?>
]" value="<?php 
        print htmlspecialchars($image->name);
        ?>
" size="22" class="middle" />
            <div style="height:3px;"></div>
            <div style="padding-bottom:5px;padding-right:5px;">
                <a class="modal" href="<?php 
        echo getPatchProductImage($image->image_name, 'full', 1);
        ?>
" rel="{handler: 'image'}">
                <img style="cursor:pointer" src="<?php 
        echo getPatchProductImage($image->image_name, 'thumb', 1);
        ?>
" alt="" />
                </a>
            </div>
            <?php 
        print _JSHOP_ORDERING;
        ?>
: <input type="text" name="old_image_ordering[<?php 
        print $image->image_id;
        ?>
]" value="<?php 
        print $image->ordering;
        ?>
" class="small" />
            <div style="height:3px;"></div>
Пример #7
0
 function add($product_id, $quantity, $attr_id, $freeattributes)
 {
     $jshopConfig = JSFactory::getConfig();
     if ($quantity <= 0) {
         return 0;
     }
     $updateqty = 1;
     JPluginHelper::importPlugin('jshoppingcheckout');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeAddProductToCart', array(&$this, &$product_id, &$quantity, &$attr_id, &$freeattributes, &$updateqty));
     $attr_serialize = serialize($attr_id);
     $free_attr_serialize = serialize($freeattributes);
     $product = JTable::getInstance('product', 'jshop');
     $product->load($product_id);
     //check attributes
     if (count($product->getRequireAttribute()) > count($attr_id) || in_array(0, $attr_id)) {
         JError::raiseNotice('', _JSHOP_SELECT_PRODUCT_OPTIONS);
         return 0;
     }
     //check free attributes
     if ($jshopConfig->admin_show_freeattributes) {
         $allfreeattributes = $product->getListFreeAttributes();
         $error = 0;
         foreach ($allfreeattributes as $k => $v) {
             if ($v->required && trim($freeattributes[$v->id]) == "") {
                 $error = 1;
                 JError::raiseNotice('', sprintf(_JSHOP_PLEASE_ENTER_X, $v->name));
             }
         }
         if ($error) {
             return 0;
         }
     }
     $product->setAttributeActive($attr_id);
     $product->setFreeAttributeActive($freeattributes);
     $qtyInStock = $product->getQtyInStock();
     $pidCheckQtyValue = $product->getPIDCheckQtyValue();
     $new_product = 1;
     if ($updateqty) {
         foreach ($this->products as $key => $value) {
             if ($value['product_id'] == $product_id && $value['attributes'] == $attr_serialize && $value['freeattributes'] == $free_attr_serialize) {
                 $product_in_cart = $this->products[$key]['quantity'];
                 $save_quantity = $product_in_cart + $quantity;
                 $sum_quantity = $save_quantity;
                 foreach ($this->products as $key2 => $value2) {
                     if ($key == $key2) {
                         continue;
                     }
                     if ($value2['pid_check_qty_value'] == $pidCheckQtyValue) {
                         $sum_quantity += $value2["quantity"];
                         $product_in_cart += $value2["quantity"];
                     }
                 }
                 if ($jshopConfig->max_count_order_one_product && $sum_quantity > $jshopConfig->max_count_order_one_product) {
                     JError::raiseNotice('', sprintf(_JSHOP_ERROR_MAX_COUNT_ORDER_ONE_PRODUCT, $jshopConfig->max_count_order_one_product));
                     return 0;
                 }
                 if ($jshopConfig->min_count_order_one_product && $sum_quantity < $jshopConfig->min_count_order_one_product) {
                     JError::raiseNotice('', sprintf(_JSHOP_ERROR_MIN_COUNT_ORDER_ONE_PRODUCT, $jshopConfig->min_count_order_one_product));
                     return 0;
                 }
                 if (!$product->unlimited && $jshopConfig->controler_buy_qty && $sum_quantity > $qtyInStock) {
                     $balans = $qtyInStock - $product_in_cart;
                     if ($balans < 0) {
                         $balans = 0;
                     }
                     JError::raiseWarning('', sprintf(_JSHOP_ERROR_EXIST_QTY_PRODUCT_IN_CART, $this->products[$key]['quantity'], $balans));
                     return 0;
                 }
                 $this->products[$key]['quantity'] = $save_quantity;
                 $this->products[$key]['price'] = $product->getPrice($this->products[$key]['quantity'], 1, 1, 1, $this->products[$key]);
                 if ($jshopConfig->cart_basic_price_show) {
                     $this->products[$key]['basicprice'] = $product->getBasicPrice();
                 }
                 $dispatcher->trigger('onBeforeSaveUpdateProductToCart', array(&$this, &$product, $key));
                 $new_product = 0;
                 break;
             }
         }
     }
     if ($new_product) {
         $product_in_cart = 0;
         foreach ($this->products as $key2 => $value2) {
             if ($value2['pid_check_qty_value'] == $pidCheckQtyValue) {
                 $product_in_cart += $value2["quantity"];
             }
         }
         $sum_quantity = $product_in_cart + $quantity;
         if ($jshopConfig->max_count_order_one_product && $sum_quantity > $jshopConfig->max_count_order_one_product) {
             JError::raiseNotice('', sprintf(_JSHOP_ERROR_MAX_COUNT_ORDER_ONE_PRODUCT, $jshopConfig->max_count_order_one_product));
             return 0;
         }
         if ($jshopConfig->min_count_order_one_product && $sum_quantity < $jshopConfig->min_count_order_one_product) {
             JError::raiseNotice('', sprintf(_JSHOP_ERROR_MIN_COUNT_ORDER_ONE_PRODUCT, $jshopConfig->min_count_order_one_product));
             return 0;
         }
         if (!$product->unlimited && $jshopConfig->controler_buy_qty && $sum_quantity > $qtyInStock) {
             $balans = $qtyInStock - $product_in_cart;
             if ($balans < 0) {
                 $balans = 0;
             }
             JError::raiseWarning('', sprintf(_JSHOP_ERROR_EXIST_QTY_PRODUCT, $balans));
             return 0;
         }
         $product->getDescription();
         $temp_product['quantity'] = $quantity;
         $temp_product['product_id'] = $product_id;
         $temp_product['category_id'] = $product->getCategory();
         $temp_product['tax'] = $product->getTax();
         $temp_product['tax_id'] = $product->product_tax_id;
         $temp_product['product_name'] = $product->name;
         $temp_product['thumb_image'] = getPatchProductImage($product->getData('image'), 'thumb');
         $temp_product['delivery_times_id'] = $product->delivery_times_id;
         $temp_product['ean'] = $product->getEan();
         $temp_product['attributes'] = $attr_serialize;
         $temp_product['attributes_value'] = array();
         $temp_product['extra_fields'] = array();
         $temp_product['weight'] = $product->getWeight();
         $temp_product['vendor_id'] = fixRealVendorId($product->vendor_id);
         $temp_product['files'] = serialize($product->getSaleFiles());
         $temp_product['freeattributes'] = $free_attr_serialize;
         if ($jshopConfig->show_manufacturer_in_cart) {
             $manufacturer_info = $product->getManufacturerInfo();
             $temp_product['manufacturer'] = $manufacturer_info->name;
         } else {
             $temp_product['manufacturer'] = '';
         }
         $temp_product['pid_check_qty_value'] = $pidCheckQtyValue;
         $i = 0;
         if (is_array($attr_id) && count($attr_id)) {
             foreach ($attr_id as $key => $value) {
                 $attr = JTable::getInstance('attribut', 'jshop');
                 $attr_v = JTable::getInstance('attributvalue', 'jshop');
                 $temp_product['attributes_value'][$i] = new stdClass();
                 $temp_product['attributes_value'][$i]->attr_id = $key;
                 $temp_product['attributes_value'][$i]->value_id = $value;
                 $temp_product['attributes_value'][$i]->attr = $attr->getName($key);
                 $temp_product['attributes_value'][$i]->value = $attr_v->getName($value);
                 $i++;
             }
         }
         if ($jshopConfig->admin_show_product_extra_field && count($jshopConfig->getCartDisplayExtraFields()) > 0) {
             $extra_field = $product->getExtraFields(2);
             $temp_product['extra_fields'] = $extra_field;
         }
         $dispatcher->trigger('onBeforeSaveNewProductToCartBPC', array(&$this, &$temp_product, &$product));
         $temp_product['price'] = $product->getPrice($quantity, 1, 1, 1, $temp_product);
         if ($jshopConfig->cart_basic_price_show) {
             $temp_product['basicprice'] = $product->getBasicPrice();
             $temp_product['basicpriceunit'] = $product->getBasicPriceUnit();
         }
         $dispatcher->trigger('onBeforeSaveNewProductToCart', array(&$this, &$temp_product, &$product));
         $this->products[] = $temp_product;
     }
     $this->loadPriceAndCountProducts();
     $this->reloadRabatValue();
     $this->saveToSession();
     $dispatcher->trigger('onAfterAddProductToCart', array(&$this, &$product_id, &$quantity, &$attr_id, &$freeattributes));
     return 1;
 }
Пример #8
0
    print $row_related->product_id;
    ?>
">
                <div class="block_related_inner">
                    <div class="name"><?php 
    echo $row_related->name;
    ?>
 (ID:&nbsp;<?php 
    print $row_related->product_id;
    ?>
)</div>
                    <div class="image"><a href="index.php?option=com_jshopping&controller=products&task=edit&product_id=<?php 
    print $row_related->product_id;
    ?>
"><img src="<?php 
    print getPatchProductImage($row_related->image, 'thumb', 1);
    ?>
" width="90" border="0" /></a></div>
                    <div style="padding-top:5px;"><input type="button" class="btn btn-danger btn-small" value="<?php 
    print _JSHOP_DELETE;
    ?>
" onclick="delete_related(<?php 
    print $row_related->product_id;
    ?>
)"></div>
                    <input type="hidden" name="related_products[]" value="<?php 
    print $row_related->product_id;
    ?>
"/>
                </div>
            </div>