Skip to main content

How to sell by different variables?

More
15 years 3 months ago #18563 by Johnny B
First off great product! I made the switch from virtuemart and I couldnt be happier.

But my question is I have a customer that wants to sell dog treats. They sell by weight, groups of 3,4, etc, or just by individual product.

When I sell by weight Id like it to say for example 5.95$ per lb or 1/2 lb
But other products may say 4 for 5$
And others say 5$ each

Ive done some reading but I cant find anything answering this do you have any suggestions? Any help is greatly appreciated.

On a side note, Do you guys have a donation button or anything? Id like to donate to help support hika shop!

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18568 by nicolas
It's already possible to do all of that with the options button it might require some modifications to do everything at once on a website. For example, if you want to display the price per lb, you can put a weight of 1lb in your product and then activate the price per weight unit option in the Display tab of the configuration. If you want to do all of these on the same website, you will have to edit the file listing_price of the view product via the menu Display->Views and change the code there in order to display the prices differently based on the products.

If you want to donate (thanks for that!), you can use the donation button at the bottom of that page: www.hikashop.com/en/support/documentation.html

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18579 by Johnny B
Great thanks for that! But could you help me with the coding? Im not sure what to enter and where to put it at?

All Id need is by weight, each, and something that says for example 4 for 5$

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago - 15 years 3 months ago #18587 by nicolas
You can do something like this:
Code:
switch($this->row->product_code){ case 'my_product1': case 'my_product2': //display price in one way break; case 'my_product3': //display price in another way break; default: //default break; }
Last edit: 15 years 3 months ago by nicolas.

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago - 15 years 3 months ago #18649 by Johnny B
Whoa, I tried that late last night and it didnt work so I just removed the code you made. I thought I would tinker with it later. But when I removed the code you sent now I have some big problems. All of the products are completely gone. Heres a couple of screenshots and the code. Before I put the code in I had 13 products with borders and everything btw.

This is a pic right after I click on one of the categories on the main page:




Heres a pic after you click on the product from the picture above:


I dont think I deleted anything but I thought you may need the code just in case.
Code:
<?php /** * @package HikaShop for Joomla! * @version 1.5.1 * @author hikashop.com * @copyright (C) 2010-2011 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?> <span class="hikashop_product_price_full"> <?php if(empty($this->row->prices)){ echo JText::_('FREE_PRICE'); }else{ $first=true; echo JText::_('PRICE_BEGINNING'); foreach($this->row->prices as $price){ if($first)$first=false; else echo JText::_('PRICE_SEPARATOR'); if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $price->price_min_quantity>1){ echo '<span class="hikashop_product_price_with_min_qty">'; } echo '<span class="hikashop_product_price">'; if($this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_value_with_tax,$price->price_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_value,$price->price_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } if($this->params->get('show_original_price') && !empty($price->price_orig_value)){ echo JText::_('PRICE_BEFORE_ORIG'); if($this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_orig_value_with_tax,$price->price_orig_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_orig_value,$price->price_orig_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } echo JText::_('PRICE_AFTER_ORIG'); } echo '</span> '; if(!empty($this->row->discount)){ if($this->params->get('show_discount')==1){ echo '<span class="hikashop_product_discount">'.JText::_('PRICE_DISCOUNT_START'); if(bccomp($this->row->discount->discount_flat_amount,0,5)!==0){ echo $this->currencyHelper->format(-1*$this->row->discount->discount_flat_amount,$price->price_currency_id); }else{ echo -1*$this->row->discount->discount_percent_amount.'%'; } echo JText::_('PRICE_DISCOUNT_END').'</span>'; }elseif($this->params->get('show_discount')==2){ echo '<span class="hikashop_product_price_before_discount">'.JText::_('PRICE_DISCOUNT_START'); if($this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_value_without_discount_with_tax,$price->price_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_value_without_discount,$price->price_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } if($this->params->get('show_original_price') && !empty($price->price_orig_value_without_discount_with_tax)){ echo JText::_('PRICE_BEFORE_ORIG'); if($this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_orig_value_without_discount_with_tax,$price->price_orig_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_orig_value_without_discount,$price->price_orig_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } echo JText::_('PRICE_AFTER_ORIG'); } echo JText::_('PRICE_DISCOUNT_END').'</span>'; } } if(isset($price->price_min_quantity) && empty($this->cart_product_price)){ if($price->price_min_quantity>1){ echo JText::sprintf('PER_UNIT_AT_LEAST_X_BOUGHT',$price->price_min_quantity); }else{ echo JText::_('PER_UNIT'); } } if($this->params->get('show_price_weight')){ if(!empty($this->element->product_id) && isset($this->row->product_weight) && bccomp($this->row->product_weight,0,3)){ echo JText::_('PRICE_SEPARATOR').'<span class="hikashop_product_price_per_weight_unit">'; if($this->params->get('price_with_tax')){ $weight_price = $price->price_value_with_tax / $this->row->product_weight; echo $this->currencyHelper->format($weight_price,$price->price_currency_id).' / '.JText::_($this->row->product_weight_unit); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ $weight_price = $price->price_value / $this->row->product_weight; echo $this->currencyHelper->format($weight_price,$price->price_currency_id).' / '.JText::_($this->row->product_weight_unit); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } echo '</span>'; } } if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $price->price_min_quantity>1){ echo '</span>'; } } } echo JText::_('PRICE_END'); } ?></span>



Again thank you so much for all the help
Last edit: 15 years 3 months ago by Johnny B.

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18650 by Johnny B
Whoa, I tried that late last night and it didnt work so I just removed the code you made. I thought I would tinker with it later. But when I removed the code you sent now I have some big problems. All of the products are completely gone. Heres a couple of screenshots and the code. Before I put the code in I had 13 products with borders and everything btw.

This is a pic right after I click on one of the categories on the main page:




Heres a pic after you click on the product from the picture above:


I dont think I deleted anything but I thought you may need the code just in case.
Code:
<?php /** * @package HikaShop for Joomla! * @version 1.5.1 * @author hikashop.com * @copyright (C) 2010-2011 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?> <span class="hikashop_product_price_full"> <?php if(empty($this->row->prices)){ echo JText::_('FREE_PRICE'); }else{ $first=true; echo JText::_('PRICE_BEGINNING'); foreach($this->row->prices as $price){ if($first)$first=false; else echo JText::_('PRICE_SEPARATOR'); if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $price->price_min_quantity>1){ echo '<span class="hikashop_product_price_with_min_qty">'; } echo '<span class="hikashop_product_price">'; if($this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_value_with_tax,$price->price_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_value,$price->price_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } if($this->params->get('show_original_price') && !empty($price->price_orig_value)){ echo JText::_('PRICE_BEFORE_ORIG'); if($this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_orig_value_with_tax,$price->price_orig_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_orig_value,$price->price_orig_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } echo JText::_('PRICE_AFTER_ORIG'); } echo '</span> '; if(!empty($this->row->discount)){ if($this->params->get('show_discount')==1){ echo '<span class="hikashop_product_discount">'.JText::_('PRICE_DISCOUNT_START'); if(bccomp($this->row->discount->discount_flat_amount,0,5)!==0){ echo $this->currencyHelper->format(-1*$this->row->discount->discount_flat_amount,$price->price_currency_id); }else{ echo -1*$this->row->discount->discount_percent_amount.'%'; } echo JText::_('PRICE_DISCOUNT_END').'</span>'; }elseif($this->params->get('show_discount')==2){ echo '<span class="hikashop_product_price_before_discount">'.JText::_('PRICE_DISCOUNT_START'); if($this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_value_without_discount_with_tax,$price->price_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_value_without_discount,$price->price_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } if($this->params->get('show_original_price') && !empty($price->price_orig_value_without_discount_with_tax)){ echo JText::_('PRICE_BEFORE_ORIG'); if($this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_orig_value_without_discount_with_tax,$price->price_orig_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_orig_value_without_discount,$price->price_orig_currency_id); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } echo JText::_('PRICE_AFTER_ORIG'); } echo JText::_('PRICE_DISCOUNT_END').'</span>'; } } if(isset($price->price_min_quantity) && empty($this->cart_product_price)){ if($price->price_min_quantity>1){ echo JText::sprintf('PER_UNIT_AT_LEAST_X_BOUGHT',$price->price_min_quantity); }else{ echo JText::_('PER_UNIT'); } } if($this->params->get('show_price_weight')){ if(!empty($this->element->product_id) && isset($this->row->product_weight) && bccomp($this->row->product_weight,0,3)){ echo JText::_('PRICE_SEPARATOR').'<span class="hikashop_product_price_per_weight_unit">'; if($this->params->get('price_with_tax')){ $weight_price = $price->price_value_with_tax / $this->row->product_weight; echo $this->currencyHelper->format($weight_price,$price->price_currency_id).' / '.JText::_($this->row->product_weight_unit); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){ $weight_price = $price->price_value / $this->row->product_weight; echo $this->currencyHelper->format($weight_price,$price->price_currency_id).' / '.JText::_($this->row->product_weight_unit); } if($this->params->get('price_with_tax')==2){ echo JText::_('PRICE_AFTER_TAX'); } echo '</span>'; } } if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $price->price_min_quantity>1){ echo '</span>'; } } } echo JText::_('PRICE_END'); } ?></span>



Again thank you so much for all the help

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18661 by nicolas
Your screenshots did not display.

On the views listing, you have an icon on the right to remove a customization. So if you have a problem, you can just click on it to go back to the default code.

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18664 by Johnny B
Ok that fixed it thanks a lot!

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18676 by Johnny B
The code you sent isnt working. It keeps taking all of my product listings down. Is there something Im doing wrong or a different line of code I could use?
Again I really appreciate all of the help you are giving me. Another reason hikashop is top notch

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18677 by nicolas
First, the code is just a skeleton of how you should do. Pasting it in the file without modifying it won't do anything. Second, you shouldn't put it in the middle of some other code in the file. You should try to put it at the end, that won't do anything but it shouldn't break anything either.

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18743 by Johnny B
I did try modifying it and I put it at the end. This is what I get when I do so:

This is right after clicking on a category



This is what I get right after clicking on the above image

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18751 by nicolas
Did you add a php code opening tag before it ?

like that: <?php

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18752 by Johnny B
Yes I did that. Ive been playing around with it for hours and I cant get it to show. It just keeps doing what its doing in the pics I posted

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18755 by nicolas
You should turn on the errors_display option of PHP by editing your php.ini that way, you will see an error message on your page.

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago - 15 years 3 months ago #18763 by Johnny B
This is the error Im getting

Code:
Notice: Undefined property: stdClass::$Treat_3 in /var/www/vhosts/magnismunchies.com/httpdocs/templates/fjt001_j16/html/com_hikashop/product/listing_price.php on line 131

Ok well that helped now Im editing the code and its not taking the site down, but its not displaying 5$ for 1/2 lb like I want. Any ideads?

Messing around with it I also get this code sometimes
Code:
Parse error: syntax error, unexpected T_CASE in /var/www/vhosts/magnismunchies.com/httpdocs/templates/fjt001_j16/html/com_hikashop/product/listing_price.php on line 132

I basically want the product Magnis Milk Bone (product code Treat_3 or item 275) to say 5$ for 1/2 lb
And another product to say 5$ for 4
Last edit: 15 years 3 months ago by Johnny B.

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18766 by nicolas
What code are you using ?

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18769 by Johnny B
<?php
switch($this->row->product_code){
case 'Treat_3':
//5$ for 1/2lbs
break;
default:
//default
break;
}

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18772 by nicolas
That should display fine and not display an error. Which line is the line 132 where you have the problem ?

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18774 by Johnny B
Oh Im pretty sure it was because I put in "magnis milk bone" instead of the product code "Treat_3"

Ok so the code is right so why isnt it displaying?

Please Log in or Create an account to join the conversation.

More
15 years 3 months ago #18775 by nicolas
It's not displaying because //5$ for 1/2lbs is a PHP comment.
If you want to display something, you should do like that:
echo "5$ for 1/2lbs";

Please Log in or Create an account to join the conversation.

Time to create page: 0.277 seconds
Powered by Kunena Forum