Using Various size and pricing...?

Permalink Browser Info Environment
Hi there! I am working on a project for an Olive Oil company and they want to be able to have two sizes and have customers select from them and have the price populate automatically. Can this be done?

Example:

Roasted Garlic Olive Oil:
250 ml :: $16
500 ml :: $24

Please take a look at cdaoliveoil.com if you want to see the actual site I am referring to.

Cannot for the life of me figure out how to swing this. Help? : )

Thanks!

1 Attachment

Type: Discussion
Status: New
rainmaker
View Replies: View Best Answer
frz replied on at Permalink Best Answer Reply
frz
yes, you can do this with a custom pricing attribute at the product level.
rainmaker replied on at Permalink Reply
rainmaker
Could you be more specific please? I am a total leman. : )
frz replied on at Permalink Reply
frz
play with the demo:

http://ecommerce.concrete5.org

make a product.

Add a "customer choice" to it. (its a button to look for)

Look in the list of types available, they should start to make sense for what you need.
rainmaker replied on at Permalink Reply
rainmaker
Thanks frz. I did read all through that and I have used each of the selections and "customer choices" but I still can't seem to get it right. Let's start here. What is a "handle"?
rainmaker replied on at Permalink Reply
rainmaker
Please help me. Pretty please? I am just not sure how to get this right. I feel like I have tried everything!
abstracts replied on at Permalink Reply
abstracts
Hi. The handle is just a database name for the attribute so just needs to be a unique identifier.
So go into Customer Choices, click Add Option and choose 'Select - Product Price' then give a handle such as 'bottle_size', make it Required when adding to cart so customer chooses the size they want. In Values, add each size with the difference in price to the default size being offered so if 250ml is the default product at $16 you would add to Values 500ml and the price difference of $8. When customers choose the product they can then select the larger size if required and the difference in price will be added to the order.
That is how I've done it anyway and it seems to work OK but you can also choose Checkbox - Product Price or Text - Product Price if they are more suitable.
Hope that helps.
Denise
netclickMe replied on at Permalink Reply
netclickMe
Screenshots on how to do this are posted on my site at:
http://creativecitywebdesign.com/index.php/concrete5-screenshots/co...
~Here's the general run-down~

Click the item you want options for:

Select Customer Choices

Choose -s Select Product Price

Make your drop-down options and give the customer choice a handle/name
RizzzO replied on at Permalink Reply
RizzzO
Hi there, I got the same problem - client is offering like 5 choices in size of each product.

Problem is, the option described here makes no sense for my purposes.

Let's say I sell bread. A small loaf costs USD 2,00, a medium size USD 3.00 and bigass large USD 5.00. Also, there's the option of bigass large, in a box, for USD 6.00.

Now I don't want the customer to have to add the price up himself, coz in the real case, prices are quite complicated (and higher). Also, there's no logic in that, because you're not getting small bread with extra, you're getting a big bread - different product, so to speak.

I don't even need a default price - just a select box with options, but with end prices, not the price to add on top of a specific price.

How do I get that to work?

Thanx!

PS: Well, I reckon I can just make the basic price UDS 0.00, but I'd need to get rid of the + sign in the select box - how do I do that?
ryan replied on at Permalink Reply
ryan
Possibly have the base price $0, then make a required, select customer choice that adds the full price to the product.
AndYMacKay replied on at Permalink Reply
AndYMacKay
double post
AndYMacKay replied on at Permalink Reply
AndYMacKay
Hi RizzO

did you ever find a way to get rid of that + sign?

thanks
jordanlev replied on at Permalink Reply
jordanlev
I've gotten rid of it by modifying this file:
YOURSITE/packages/core_commerce/models/attribute/types/product_price_adjustment_select/controller.php
as follows:
Find the "getSelectAttributeOptionDisplayValue()" function, and change this:
public function getSelectAttributeOptionDisplayValue() {
   $adjValue = $this->getSelectAttributeOptionAdjustmentValue();
   $txt = $this->value;
   if($adjValue != 0) {
      if($adjValue > 0) {
         $txt .= " +";
      } else {
         $txt .= " -";
      }
      $txt .= CoreCommercePrice::format($adjValue);
   }
   return $txt;
}

to something like this:
public function getSelectAttributeOptionDisplayValue() {
   $adjValue = $this->getSelectAttributeOptionAdjustmentValue();
   $txt = $this->value;
   if($adjValue != 0) {
      if($adjValue > 0) {
         $txt .= ": "; //<--Changed this (I put a colon so it reads "Product: $0.00", but you could put in anything, or even just leave it blank by putting in an empty string ("")
      } else {
         $txt .= " -";
      }
      $txt .= CoreCommercePrice::format($adjValue);
   }
   return $txt;
}


You'll need to make sure to re-implement this change when the ecommerce addon is upgraded, but since this is only 1 line of code I've found it much easier to do this than to try overriding the whole thing. Just leave a note for yourself somewhere about it :)
AndYMacKay replied on at Permalink Reply
AndYMacKay
Thanks for your help. It worked a charm.

Also, have just been checking out your Force Single Sublevel add-on and really, what a great idea!

andy
jordanlev replied on at Permalink Reply
jordanlev
I have the same situation. My client would rather not use a dropdown list. I was thinking that outputting radio buttons instead of a dropdown list shouldn't be that different as far as application logic goes.

Question for C5 guys -- if I just copy the "product_price_adjustment_select" attribute (changing its name of course), and modify it to output radio buttons instead of a select list, should that work okay? Or am I missing some other piece of the puzzle that's going to cause a lot more effort than at first glance?

Thanks for any help you can provide.

-Jordan
ryan replied on at Permalink Reply
ryan
Yep, that should work
cali replied on at Permalink Reply
cali
Hi, i'm interested by this method :) could you explain a little how did you do that ?
i'm looking for a radio list buttons with price modification too :)

i found how to replace select list by radio
for those who are interested i change the /packages/core_commerce/models/attribute/types/product_price_adjustment_select/form.php from
<?php  } else {
   $opts = array('');
   foreach($options as $opt) {
      $opts[$opt->getSelectAttributeOptionID()] = $opt->getSelectAttributeOptionDisplayValue();
   }
   ?>
   <?php echo $form->select($this->field('atSelectOptionID') . '[]', $opts, $selectedOptions[0]); ?>
<?php  } ?>

to
<?php  } else {
   ?>
   <?php  foreach($options as $opt) { ?>
      <div>
         <?php echo $form->radio($this->field('atSelectOptionID') . '[]', $opt->getSelectAttributeOptionID(), in_array($opt->getSelectAttributeOptionID(), $selectedOptions)); ?>
         <?php echo $opt->getSelectAttributeOptionDisplayValue()?></div>
   <?php  } ?>
<?php  } ?>


but, if i copy the product_price_adjustment_select folder, change its name in product_price_adjustment_radio, and make name changes in controller and type_form and finally upload it in /packages/core_commerce/models/attribute/types/, i do not found how to add the attributes.

i think i miss a simple step, but can't remember witch one :s
jordanlev replied on at Permalink Reply
jordanlev
I couldn't make it work by creating my own attribute type, so I just hacked the core files to make it output the html for radio buttons instead of a select element. Note that this was with an old version of ecommerce (1.something), so I have no idea if this code is still the same in the new version. But what I did is modify this file:
packages/core_commerce/models/attribute/types/product_price_adjustment_select/form.php

I commented out this portion of code:
$opts = array('' => t('** None'));
   foreach($options as $opt) { 
      $opts[$opt->getSelectAttributeOptionID()] = $opt->getSelectAttributeOptionDisplayValue();
   }
   ?>
   <?php echo $form->select($this->field('atSelectOptionID') . '[]', $opts, $selectedOptions[0]); ?>
<?php  } ?>

...and replaced it with this:
$radioIndex = 1; //We need this to associate label with radio button id (to match what the radio() function in concrete/helpers/form.php does).
   foreach($options as $opt) {
      $key = $this->field('atSelectOptionID') . '[]';
      $value = $opt->getSelectAttributeOptionID();
      $label = $opt->getSelectAttributeOptionDisplayValue();
      echo $form->radio($key, $value);
      echo "<label for=\"{$key}{$radioIndex}\">{$label}</label>";
      echo '<br />';
      $radioIndex++;
   }
}


I also made 2 other changes that are not essential but might be helpful to you as well. Both of these are in this file:
packages/core_commerce/models/attribute/types/product_price_adjustment_select/controller.php


1) I removed the plus sign (+) from in front of the prices (because I set the base price for all products to $0.00, and then the total price for the item was reflected in the "adjustment" for a particular option, so it wasn't really "adding" anything to the price, but rather the option was the entire price. To do that, I changed this code:
if($adjValue > 0) {
   $txt .= " +";
} else {
   $txt .= " -";
}

...to this:
if($adjValue > 0) {
   $txt .= ": ";
} else {
   $txt .= " -";
}


2) For some silly reason (in my opinion anyway), there's a requirement on the select attribute that you must have at least 2 options. But this was not good for me because while most of the products had more than 1 option, some only had one, and I didn't want just one or two random items in the product list to have a different-looking interface from the rest -- I just wanted them to have a single radio button choice. So I changed this code:
if ($vals->count() < 2 && $this->post('akSelectAllowOtherValues') == 0) {
   $e->add(t('A select attribute type must have at least two values, or must allow users to add to it.'));
}

...to this:
if ($vals->count() < 1 && $this->post('akSelectAllowOtherValues') == 0) {
   $e->add(t('A select attribute type must have at least one value, or must allow users to add to it.'));
}


Again, I have no idea if the above two changes are needed in the most recent version of eCommerce (I especially hope they've removed the restriction on having less than 2 options for the select attribute -- it's very useful in some situations to only have one -- for both admin and end-user consistency).

Hope that helps.

-Jordan
cali replied on at Permalink Reply
cali
Hi Jordan, the change i made (explain on my previous post) is working find too.

thanks for details :) you provide, it will help me a lot in another way i'm working on !

then we're on the same step how to implement a new customer choice attribute type :)
jordanlev replied on at Permalink Reply
jordanlev
Oh jeez, sorry -- I didn't notice you posted all that code! (Either the email notification didn't include your entire post or you edited it after initial submission)

Glad you figured it out, hopefully one of the core team folks can explain how we'd be able to override it properly without changing the package files :)

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.