bobbingwide / vgc

VGC - Garden Vista Group theme
GNU General Public License v2.0
0 stars 0 forks source link

Update global base calculations logic #49

Open bobbingwide opened 1 year ago

bobbingwide commented 1 year ago

Originally raised as https://github.com/bobbingwide/gardenvista/issues/15

2)On the options - global base calculations, we like to reduce the range of the bases (concrete base, Single brick course base around greenhouse, Timber base to go on existing paving or concrete, Timber frame base with support posts concreted into the ground)

17-47, 48-71, 72-120 range to be replaced with 17-32, 33-48, 49-64, 65-80, 81-96, 97-120

The idea is when pricing, according to size of the area, to be more fair and precise. gardenvista.co.uk/wp-admin/admin.php/?page=acf-options

bobbingwide commented 1 year ago
Current rates Under 16 17-47 48-71 72-120 Over 121
No Base 0 0 0 0 0 0
Concrete 30 20 16 12 10
Single brick course 28 17 12 10 10
Timber base 12 6 4.2 3.2 2.2
Timber base & posts 15 9.5 8 6.2 5
bobbingwide commented 1 year ago

My guestimates for new rates for each range are as follows

Current rates Under 16 17-32 33-48 49-64 65-80 81-96 97-120 Over 121
No Base 0 0 0 0 0 0 0 0 0 0
Concrete 30 25 20 18 16 14 12 10
Single brick course 28 22.5 17 14.5 12 11 10 10 10
Timber base 12 9 6 5.1 4.2 3.7 3.2 2.2
Timber base & posts 15 11.7 9.5 8.7 8 7.1 6.2 5
bobbingwide commented 1 year ago

New display of rates for Concrete.

image

bobbingwide commented 1 year ago

At present there are two methods for calculating the base price:

  1. When displayed in the options the rate is determined from the base size ( width * length )
  2. When the final price is being calculated the rate is determine from the original base size ( width length ) but the price is calculated for the adjusted size: ( original base size + base_extra ) rate

where base_extra is to do with a verandah or some other extension that increases the overall base size.

The base price displayed in the cart may therefore be different from the original value.

Note: I'll have to find examples of this situation in order to test the code.

bobbingwide commented 1 year ago

Test products. Order with post code GU33 to avoid extra charges for postcode area 2 / 3.

URL base size Concrete Single brick course Timber Timber & Posts
https://gvg.co.uk/store/alton-broadwell-10-x-10-ft-summerhouse 100 1200 na 320 620
https://gvg.co.uk/store/passmores-tool-store-15-x-3/ 4.5 135 na 54 67.50
https://gvg.co.uk/store/halls-atrium-12-x-12-ft-hexagonal-green-greenhouse 151.29 1512.90 1512.90 na na
https://gvg.co.uk/store/regency-acapulco-summerhouse-12-x-12/ 144 1440 na 316.80 720
YSM980 commented 1 year ago
  • The base sizes for Global base calculations are different fields to those for Global Building Removal.
  • They currently have the same Field Labels and Field Name. eg Label 17 - 47 is called 17_47.
  • They are in different field groups, and are therefore different fields.
  • Global Building Removal was copied from Global base size table when first created.
  • The Global base size table repeater field is used 5 times:

    • No base
    • Concrete base
    • Single brick course base around greenhouse
    • Timber base to go on existing paving or concrete
    • Timber base with support posts concreted into the ground
  • Global building removal repeater field is used twice:

    • Removal and taking away of timber building
    • Removal of Greenhouses

Current rates Under 16 17-47 48-71 72-120 Over 121 No Base 0 0 0 0 0 Concrete 30 20 16 12 10 Single brick course 28 17 12 10 10 Timber base 12 6 4.2 3.2 2.2 Timber base & posts 15 9.5 8 6.2 5

WAITING FOR JAMES TO COME UP WITH PRICING

bobbingwide commented 1 year ago

Given that the requirement for Deposits is now a priority and that there's been no reply on whether or not the Base Removal Tables need changing I'll see if I can implement a solution that will make it very easy to apply the switch.

The idea is that there'll be three functions:

This solution assumes that the changes for global building removal would be the same as for base installation.

YSM980 commented 1 year ago

Hi Herb, Can you call me tomorrow afternoon before you do any work on this so we can discuss. I am planning on looking at the base costs next week.Many thanks  James

bobbingwide commented 1 year ago

James confirmed today:

I can try testing with Swallow combination shed and/or Regency Monte Carlo

bobbingwide commented 1 year ago

When the time comes we'll change the bool from false to true.

I added some logic that detects if the Global options table has been updated. When it contains the new key 17_32 then it will use the new keys, otherwise it uses the old keys.

The code won't need to be changed, just the Global options, which will be updated by ACF import.

bobbingwide commented 1 year ago

Results of tests of VGC v1.4.0 with the old rates

Test products. Order with post code GU33 to avoid extra charges for postcode area 2 / 3.

URL base size Concrete Single brick course Timber Timber & Posts OK?
https://gardenvista.co.uk/store/alton-broadwell-10-x-10-ft-summerhouse 118.81 1425.72 na 380.19 736.62 Yes
https://gardenvista.co.uk/store/passmores-tool-store-15-x-3/ 4.5 135 na 54 67.50 Yes
https://gardenvista.co.uk/store/halls-atrium-12-x-12-ft-hexagonal-green-greenhouse 151.29 1512.90 1512.90 na na Yes
https://gardenvista.co.uk/store/regency-acapulco-summerhouse-12-x-12/ 144 1440 na 316.80 720 Yes

Note: For the Alton Broadwell summerhouse the dimensions in the live site are different from my local site.

bobbingwide commented 1 year ago

I got some warning messages today. First one is from vgc_get_base_area_key_new().

C:\apache\htdocs\wordpress\wp-content\themes\vgc\inc\custom-woo-functions.php(958:0) vgc_get_base_area_key_new(1) 38 4 2023-06-27T11:25:41+00:00 7.243199 0.153560 cf! 58464 468 3656 14680064/14680064 2048M F=2193 1 32.5 C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php(286:2) bw_trace_error_handler(5) 39 5 2023-06-27T11:25:41+00:00 7.243977 0.000778 cf! 58464 468 3656 14680064/14680064 2048M F=2193 err Array

[0] => (integer) 2
[1] => (string) "Warning: Undefined variable $key"
[2] => (string) "C:\apache\htdocs\wordpress\wp-content\themes\vgc\inc\custom-woo-functions.php"
[3] => (integer) 983

The subsequent messages from line 668 are due to $key not being set.

Explanation

The logic doesn't properly cater for non integer values of $baseSqFeet

In this instance the $productLength is 6.5 so the base area is 32.5

3. vgc_get_base_area_key_new(32.5) C:\apache\htdocs\wordpress\wp-content\themes\vgc\inc\custom-woo-functions.php:1014 1
4. vgc_get_base_area_key(32.5,1) C:\apache\htdocs\wordpress\wp-content\themes\vgc\inc\custom-woo-functions.php:622 2
5. getBaseTypePriceFromGlobalOptions(6.5,5,0,array) C:\apache\htdocs\wordpress\wp-content\themes\vgc\template-parts\shop\addons\base-addon.php:18 4

Proposed fix

Round the $baseSqFeet to 0 decimal places