TOPIC:

options / variations / characteristics 4 months 1 week ago #240707

  • Topic Author
  • itwebservices
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 196
  • Thanks: 0
Hi,

I have faced some difficulties to set the characteristic option for my products.
The eshop is here: eshop

I will give you two examples to show me how to do it.

1) I have a product with the characteristics below (product per kg)

-diameter: 8mm, 10mm, 12mm
-Lenght: 1m, 2m, 3m, 4m, 5m

-kg/m:
--for 8mm --> 0,400 kg/m
--for 10mm --> 0,620 kg/m
--for 12mm --> 0,890 kg/m

How can the system will calculate the Total Kg of the product in order to multiply this with price/kg in order to display the final price for the buyer?

{ pieces * diameter * length * (kg/m) } = { Total Kg }
{ Total Kg } * price = Total price

For example: 10 pieces * diameter 10 mm * length 5m * 0,620 kg/m = 31 kg
31 kg * 2€ = 62€.


2) I have a product with the characteristics below (product per piece)

-Diameter: 1,8mm // 2,2mm // 2,4mm // 2,7mm
-holes: 50x50mm // 75x50mm // 100x63 mm
-height: 1,2m // 1,5m // 1,8m // 2m
-width:
--25m for 50x50mm
--25m for 75x50mm
--20m for 100x63 mm

the product is per piece (coil of the width of 25m or coil of width of 20m)

so I would like to know what the cost of the product {diameter * holes * height} in order to multiply with the price and export the final price for the buyer. For example:

{diameter 1,8mm * holes (50x50) * height 1,2m} * 2 pieces (width 25m) = { cost of product } * 2 pieces = Total price

Thank you.

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

options / variations / characteristics 3 months 2 weeks ago #242337

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 10063
  • Karma: 167
  • Thanks: 798
Hi,

for such a custom requirement I usually would consider to create a custom price plugin.
But you can also use the BreezingForms integration with BC to achieve it without creating a new plugin.

For this please install and enable the 2 BF plugins in BC and enable them.

Install BreezingForms and create either:
- If the dimensions are fixed per product: a simple form with a hidden input called "item" and a default value like "configured". We need this to apply some calculation code later on.

- If the dimensions should be adjustable by the user (=configurable), create a more complex form that allows the customer to choose the right dimensions he needs.

In your product(s) => Display Plugins tab locate the BF plugin and select the form you just created. Then save.

After save, locate the product(s) => price plugins tab => and click "code" for one of the form elements. I am using the fixed dimensions example, for this the code would look like this (example for fixed calculations [non configurable by customer]):
$db->setQuery("Select * From #__breezingcommerce_products Where id = " . $db->quote( $product_id ));

$the_product = $db->loadObject();

if( $the_product !== null){

     // BC doesn't have diameter, so you need to add it per product hardcoded
     $price = $amount * 25.00 * $the_product->length * $current_price;
}

If you then save everything, the price will be recalculated for that product based on the "weight & dimensions" tab.

If you use actual variations instead, then you need to extend this further, checking "$is_combination == true" and pull the dimensions from the BC "#__breezingcommerce_product_property_combinations" instead of the "#__breezingcommerce_products" table.

If the prices are supposed to be dynamic based on a user's configuration, you will need to pull the form data in the code using the "$fields" variable, which is an array and holds all values being made in the form that can be used to calculate everything dynamically.

However, the same principle would apply for all your other calculations.

Please see the screenshots below to give a feeling about how this would look like.

Hope this helps!

Regards,
Markus


Attachments:

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

options / variations / characteristics 3 months 2 weeks ago #242351

  • Topic Author
  • itwebservices
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 196
  • Thanks: 0
Hello and thank you very much for your customization.

It is really very difficult for me some steps to do.

I have done everything until the custom code (included). After this I don't understand nothing.

about this that you are reffering inside the code "// BC doesn't have diameter, so you need to add it per product hardcoded
$price = $amount * 25.00 * $the_product->length * $current_price;
}"
do you mean the example below that I had sent you? Where the elements "25.00" and "$current_price" are connecting/corresponding to my example below?

For example: 10 pieces * diameter 10 mm * length 5m * 0,620 kg/m = 31 kg
Total price = 31 kg * (2€/kg) = 62€.

If you use actual variations instead
> what do you mean with actual variations?

If the prices are supposed to be dynamic based on a user's configuration
> yes I would like to calculated dynamically during the user's configuration. I really don't understand what I have to do.

Please give some more help.
Thank you very much for all.

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

options / variations / characteristics 3 months 2 weeks ago #242357

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 10063
  • Karma: 167
  • Thanks: 798
Ok, let me explain:

Because product configurations are always differently across shops (everyone has different products, product types, formulas, etc), it is common for shops to use custom forms.

So if you want to let the customer decide the dimensions of a product, you will need some sort of a form where the user adds his data. In your case dimensions.

So in order to do that, I outlined a way. Since I couldn't get the whole picture based on your description I basically answered with the base principle.

So if you requirement is actually not having fixed dimensions but the user may configure the dimensions, then you will need to create a form that will be displayed right in the product details that he has to fill out prior adding the product to cart.

And this is exactly what BreezingForms + BreezingCommerce integration can help you with.

So to get into further details: How do you want customers exactly choose the dimensions in the product details before adding it to the cart? You can draw it, I just need to understand before I come up with something more specific.

Thanks!

Regards,
Markus

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

options / variations / characteristics 3 months 2 weeks ago #242363

  • Topic Author
  • itwebservices
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 196
  • Thanks: 0
Hello,

I am sorry. There was a misunderstanding from my side.

yes, the dimensions will be fixed. For example options for -Diameter: 1.8mm // 2.2mm // 2.4mm // 2.7mm. They are fixed. The dynamic (I was meaning) will be one of the fixed dimensions that customer will finally select.

so, from the previous message I continue don't understand the following

about this that you are reffering inside the code "// BC doesn't have diameter, so you need to add it per product hardcoded
$price = $amount * 25.00 * $the_product->length * $current_price;
}"
> do you mean the example below that I had sent you? Where the elements "25.00" and "$current_price" are connecting/corresponding to my example below?

>For example: 10 pieces * diameter 10 mm * length 5m * 0,620 kg/m = 31 kg
Total price = 31 kg * (2€/kg) = 62€.

If you use actual variations instead
> what do you mean with actual variations?

Finally the selected fields from BF does not displayed in the frontend of BC.

I am sure that we will solve this issue!

Thank you.

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

options / variations / characteristics 3 months 2 weeks ago #242365

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 10063
  • Karma: 167
  • Thanks: 798
> do you mean the example below that I had sent you? Where the elements "25.00" and

Yes, I just added a 25.00 as diameter.
It didn't really matter as the point was more about how changing the price can be done. The final formula can still be added properly/as you desire.

> what do you mean with actual variations?

BC has a feature called variations. They derive from options and each variation may have its won set of dimensions. These variations are stored in a different db table than the one from my code. That's all what I wanted to say.

If you added that field as hidden input, it won't appear. We just need a field so we can trigger that code. That's a little trick so we have a "spot" where we can add our code to change the price on the fly based on the formula.

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

Time to create page: 0.128 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!