bobbingwide / vgc

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

Discount on the price for options #19

Closed bobbingwide closed 2 years ago

bobbingwide commented 2 years ago

Requirement

When products are put on sale we also need to be able to reduce the price of options. What are the possible solutions?

eg. Product 7927 regular price is 1099.00 sale price is 989.10. ie discount of 10%

This needs to be applied to the optional upgrades:

Option name Option Price Discounted
Shelving 4' Shelving Black 109.00 98.10
Staging 10' Staging 299.00 269.10
Base Base Black 249.00 224.10

Options are:

  1. Automatically adjust option prices on the front end.
  2. Add a discount code that will apply the discount at checkout.
  3. Add a new Discount price field for each option.
  4. If necessary update https://github.com/bobbingwide/gvg_bulk_update

Assumptions

bobbingwide commented 2 years ago

It's possible to change the price on display. This change also needs to be applied to the cart display... etc.

bobbingwide commented 2 years ago

Automatically adjust option prices on the front end. Add a discount code that will apply the discount at checkout.

The first option to automatically adjust option prices on the front end seemed to work for the display of options. But the calculation of the discount based on the discount applied to the main product doesn't appear to satisfy the current sales drive:

Adding a new option to the Delivery, Base, Removal and Installation field group may satisfy the ability to apply a selected discount to all accessories.

Whether or not that can be applied to Optional Upgrades based on their Pricing route needs to be determined.

Pricing route Single or Multi Apply discount?
Single either Yes
Based on size squared either Yes
Based on size length either Yes
Percentage of stating price either No

Note: We can't easily correct the spelling of stating since it's stored in the database!

BTW. No idea what increase_base_size_by is about

bobbingwide commented 2 years ago

BTW. No idea what increase_base_size_by is about

increase_base_size_by is a value that's set on certain options which increase the area of the base for the product. For example a the Verandah on the Passmores Garden Room 8' x 8', post ID 5919 increases the size by 17.6 ( m2).

Applying this option doesn't necessarily increase the Base cost.

bobbingwide commented 2 years ago

It's possible to change the price on display. This change also needs to be applied to the cart display... etc.

Both the original price and new price need to be shown eg for 10% discount on an option that cost £100

From: £100.00 Now £90.00

The optional discount should be obvious to the user on the product page:

And in the cart:

bobbingwide commented 2 years ago

This change also needs to be applied to the cart display... etc.

bobbingwide commented 2 years ago

I've raised a couple of additional issues for problems found while testing the changes eg #32 I need to test the changes to ensure they're working as expected for each of the single- and multi- combinations. I could either create a test product that covered all these options or identify products to use.

Using existing products would appear to be a better approach as 1) it can be done in Live as well 2) It may find more problems with configuration as discovered in #32.

Additional option type Product ID Option Tested
multi-single swallow-robin-5-x-4-ft-greenhouse 4452 Wren Cold Frame Yes - Not sale
multi-squared
multi-length deponti-pigato-veranda-4060x3000mm 7031 Roofing - Ultra Clear Polycarbonate Yes - Not sale
multi-percent
single-single swallow-robin-5-x-4-ft-greenhouse 4452 Wooden Yes - Not sale
single-squared regency-notton-pent-shed-6-x-4 2652 Paint Colour options Yes
single-length deponti-bosco-veranda-6060x3000mm 7199 Roofing - Ultra Clear Polycarbonate Yes - Not sale
single-percent regency-notton-pent-shed-6-x-4 2652 Vertical boards Yes

Notes:

In the editor the left set of radio buttons is the Pricing route, the right set is Single or Multi. In the table above the sides are swapped and the radio button titles are mapped. eg Percentage of stating price is percent.

Example showing the B prefix used for single-length options. image

Example showing the *A prefix for single-single, the C prefix for single-squared options and D prefix for single-percent

For the Regency Notton Pent Shed the paint colour options are not marked as Allow only one choice. Here you can see that I've chosen two colours.

image

bobbingwide commented 2 years ago

Finding the products with the different combinations isn't easy using SQL.

SELECT * FROM `vgcwp_postmeta` where ( meta_value like  '%length%' and meta_key like '%_pricing_route%' )
order by post_id, meta_key;

I'll write some PHPUnit tests that I can use to locate them. metadata for _pricing_route is:

meta_value count
Single 24871
Based on size squared 4451
Based on size length 37
Percentage of stating price 871

metadata for _single_choice_or_multi_choice is

meta_value count
single 26159
multi 3850
bobbingwide commented 2 years ago

I wrote the PHPUnit tests for the gvg-bulk-update plugin since it already had some tests. I couldn't find any published products that had multi-squared or multi percent options So I created one called A test product, post ID 7982.

When I tested the product on sale I noticed that the Multi-percent options were already based on the sale price. This means any discount would be even greater

Price Sale Price Percentage Option price Options discount Subsequent options price
1000 - 10 100 n/a n/a
1000 900 10 90 20% 72
1000 - 20 200 n/a n/a
1000 900 20 180 20% 144
bobbingwide commented 2 years ago
The same logic applies to single-percent options. eg For the Regency Notton Pent shed the original cost of Vertical boards is a 15% increase on the original price. Price Sale Price Percentage Option price Options discount Subsequent options price
1293.00 - 15 193.95 n/a n/a
1293.00 1163.70 15 174.56 20% 139.65
bobbingwide commented 2 years ago

When I tested the product on sale I noticed that the Multi-percent options were already based on the sale price. This means any discount would be even greater. The same logic applies to single-percent options.

We discussed this today. When the product is on sale then the cost of the a multi-percent or single-percent option would be based on the Sale price of the product. The Options discount would not be applied. The table(s) would be as follows.

multi-percent

Price Sale Price Percentage Option price
1000 - 10 100
1000 900 10 90
1000 - 20 200
1000 900 20 180
single-percent Price Sale Price Percentage Option price
1293.00 - 15 193.95
1293.00 1163.70 15 174.56
bobbingwide commented 2 years ago

Delivered in v1.2.1