3 Posts
mattjohn
4 years ago
3
Topic

Hi all,

I have content with computation in an Admin form that has a field which is variable changeable in an another admin form, when a user updates the variable value it should change the results of the computation automatically to then render the correct value without having to go into each record to run it to then save the new calculated value.

So in a sense every time the Gold price field is updated it needs to re-run the computation or formula below on each record that has the id of the Gold rate to then update to give a new price.

  • 1.Have a content type called products
  • 2.Have a content type Gold Rates

Products Content Type has the following fields:

  • -Gold Rate Type (Select Dynamic Gold Rate CCK using Gold Price as Value in calculation but ID in Store Value)
  • -Weight
  • -Value 1 (computation: Gold Rate * Weight)
  • -Item Markup
  • -Value 2 (computation: Item markup * Value 1 / 100)
  • -Price (computation: Value 1 + Value 2)

Gold Rates Content Type has the following fields:

  • -ID
  • -Title
  • -Gold Price
  • -Last Updated

Example Data:

Product 1 ( product Admin Form)

Gold Rate = Rate 1, Weight = 60, Value 1 = 960, Item Markup = 30, Value 2 = 288, PRICE = £1,248

Gold Rate Type 1 (Gold Rate Admin Form)

ID = 1, Title = Gold Rate 1, Gold Price = 16

I am not sure which way round or the best way to get the result I need, should I be using a script that when the page loads on the front-end it runs the above formula to always give a live price, or should it be mass updated to then give a fixed static price in the DB column price?

The user will be able to update the Gold price in gold rates for it to then render a new correct calculated price in the content view on the front-end through products content type.

So if the user updated the Gold Rate Type 1, Gold Price field to 20, the new Price in Product content should be: £1,560 on the front-end without having to go into every product that has that gold rate to re-run the computation and save.

Any help would be much appreciated

Get a Book for SEBLOD
1283 Posts
Bucklash
4 years ago
2
Level 1

Many ways I guess:

1: some ajax solution... I know nothing about ajax

2: some js solution.

3: beforerender grab the gold value and do the calculation and apply value to some field.

... 

3 Posts
mattjohn
4 years ago
1
Level 2

I was thinking about that but then went on to think it would be too much in the front-end wihtin all views etc be a lot of overload, so went on to see if I can generate a list of products based on the ID of the Gold Rate Type and then mass update in 1 go so the price is not dynamic in the front end, but i dont think you can do this with seblod.


How to update more than one record within a form of another content type admin form not by using the import and export tool tho!

Be nice if I could do it this way round?

1283 Posts
Bucklash
4 years ago
0
Level 3

this is what I would use:

https://www.seblod.com/resources/manuals/developer/manipulating-content-extend-method-reusable-code

Every time gold price changes update all relevant records.

Get a Book for SEBLOD