Closed bobbingwide closed 1 year ago
I didn't get far. For the product https://gvg.co.uk/store/alton-shipton-6-x-6ft-summerhouse/#options_area choosing Add to cart produced a series of Warnings followed by a Fatal error This problem doesn't happen with 6.5.1
| <b>Warning</b>: Undefined array key 1 in <b>C:\apache\htdocs\wordpress\wp-content\themes\vgc\inc\custom-woo-functions.php</b> on line <b>200</b><br />
| <br />
| <b>Warning</b>: Undefined array key "base_extra" in <b>C:\apache\htdocs\wordpress\wp-content\themes\vgc\woocommerce\inc\classes\calculate-price.php</b> on line <b>128</b><br />
| <br />
| <b>Warning</b>: Undefined array key "installation" in <b>C:\apache\htdocs\wordpress\wp-content\themes\vgc\woocommerce\inc\classes\calculate-price.php</b> on line <b>128</b><br />
| <br />
| <b>Warning</b>: Undefined array key "base-type" in <b>C:\apache\htdocs\wordpress\wp-content\themes\vgc\woocommerce\inc\classes\calculate-price.php</b> on line <b>128</b><br />
| <br />
| <b>Warning</b>: Undefined array key 1 in <b>C:\apache\htdocs\wordpress\wp-content\themes\vgc\inc\custom-woo-functions.php</b> on line <b>200</b><br />
| <br />
| <b>Warning</b>: Undefined array key "b" in <b>C:\apache\htdocs\wordpress\wp-content\themes\vgc\woocommerce\inc\classes\calculate-price.php</b> on line <b>128</b><br />
| <br />
| <b>Warning</b>: Undefined array key "delivery" in <b>C:\apache\htdocs\wordpress\wp-content\themes\vgc\woocommerce\inc\classes\calculate-price.php</b> on line <b>128</b><br />
| <br />
| <b>Fatal error</b>: Uncaught TypeError: Unsupported operand types: string * int in C:\apache\htdocs\wordpress\wp-content\themes\vgc\woocommerce\inc\classes\calculate-price.php:354
| Stack trace:
| #0 C:\apache\htdocs\wordpress\wp-content\themes\vgc\woocommerce\inc\classes\calculate-price.php(64): calculate_price->calculatePrice()
| #1 C:\apache\htdocs\wordpress\wp-content\themes\vgc\inc\custom-woo-functions.php(80): calculate_price->__construct(Array, Array, '3979', '6', '6', 3990, '0', Object(WC_Product_Simple))
| #2 C:\apache\htdocs\gardenvista\wp-includes\class-wp-hook.php(309): calculate_price_on_cart_addition(Array, 3990)
| #3 C:\apache\htdocs\gardenvista\wp-includes\plugin.php(191): WP_Hook->apply_filters(Array, Array)
| #4 C:\apache\htdocs\gardenvista\wp-content\plugins\woocommerce\includes\class-wc-cart.php(1138): apply_filters('woocommerce_add...', Array, 3990, 0, 1)
| #5 C:\apache\htdocs\gardenvista\wp-content\plugins\woocommerce\includes\class-wc-form-handler.php(824): WC_Cart->add_to_cart(3990, 1)
| #6 C:\apache\htdocs\gardenvista\wp-content\plugins\woocommerce\includes\class-wc-form-handler.php(796): WC_Form_Handler::add_to_cart_handler_simple(3990)
| #7 C:\apache\htdocs\gardenvista\wp-includes\class-wp-hook.php(307): WC_Form_Handler::add_to_cart_action('')
| #8 C:\apache\htdocs\gardenvista\wp-includes\class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
| #9 C:\apache\htdocs\gardenvista\wp-includes\plugin.php(476): WP_Hook->do_action(Array)
| #10 C:\apache\htdocs\gardenvista\wp-settings.php(620): do_action('wp_loaded')
| #11 C:\apache\htdocs\gardenvista\wp-config.php(94): require_once('C:\\apache\\htdoc...')
| #12 C:\apache\htdocs\gardenvista\wp-load.php(50): require_once('C:\\apache\\htdoc...')
| #13 C:\apache\htdocs\gardenvista\wp-blog-header.php(13): require_once('C:\\apache\\htdoc...')
| #14 C:\apache\htdocs\gardenvista\index.php(17): require('C:\\apache\\htdoc...')
| #15 {main}
| thrown in <b>C:\apache\htdocs\wordpress\wp-content\themes\vgc\woocommerce\inc\classes\calculate-price.php</b> on line <b>354</b><br />
The above Warnings weren't due to WooCommerce. The problems occur with PHP 8, with values which are strings not being automatically cast to numbers.
When the Add to cart button is pressed $_REQUEST
contains
[base_extra] => (string) "0"
[building_removal_removal-and-taking-away-of-timber-building] => (string) ""
[building_removal_removal-of-greenhouses] => (string) ""
[installation] => (string) "yes"
[base-type] => (string) "no base"
[b] => (string) "2"
[delivery] => (string) "0"
[add-to-cart] => (string) "3995"
The code in calculate_price::calculatePrice()
needed to be adjusted to cater for the options which are not prefixed single-
or multi-
.
There's another Warning from calculate_price_on_cart_addition()
[0] => (integer) 2
[1] => (string) "Warning: Undefined variable $addons"
[2] => (string) "C:\apache\htdocs\wordpress\wp-content\themes\vgc\inc\custom-woo-functions.php"
[3] => (integer) 111
WooCommerce status reports: vgc/woocommerce/myaccount\form-login.php version 4.1.0 is out of date. The core version is 6.0.0
On the my-account page, accessed via the Sign in menu item, the Login and Register forms are shunted to the left. This is a screen capture from the live site. Locally it's the same.
The narrow styling comes from bootstrap.min.css
.col-1 {
flex: 0 0 auto;
width: 8.33333333%;
}
which overrides the styling for .woocommerce .col-1
The Register form is also narrow. Similar problem with the CSS using .col-2
A pragmatic fix, rather than mess about with potentially complex CSS, is to
col-1
and col-2
classes from the code class="fw-bold"
to the Register headingsection.my-account .row h2
similarly to the h1.A pragmatic fix, rather than mess about with potentially complex CSS
But this solution only works for the Login and Registration. The my-account Addresses and Account details are similarly affected.
Options
Note also that the h1 title for My Account is always "Login", which IMO is incorrect.
BTW The col-1, col-2 thing is a known issue dating back to 2018 and bootstrap 4. WooCommerce didn't change their code, so developers had to find their own solutions.
Yasmin emailed to report a problem that a customer noted.
I have just been made aware by a customer that, our option discount does not work at the checkout. I have tested myself to find that adding to cart is not a problem although when reaching the checkout page, it removes the discount.
I am not sure if it was always like this or changed later on, perhaps always been since we were not getting orders online, but only over the phone.
I'll test what happens when I add orders containing the products identified in https://github.com/bobbingwide/vgc/issues/19#issuecomment-1084194424
Tested with product ID 2652 Regency Notton Pent Shed 6' x 4'.
Problem occurs on Add to cart
.
The discount on Wood Types: Deluxe was not applied.
The add_to_cart button posts a message to the current page with the following C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\class-BW-trace-controller.php(461:0) trace_startup(2) 6 0 2022-11-02T21:10:53+00:00 0.269722 0.000052 cf! 25 1 0 2097152/2097152 2048M F=310 _REQUEST Array
[single-single-addon-wood-types:deluxe] => (string) "true"
[single-single-addon-door--window-positions:r1-option] => (string) "true"
[multi-single-addon-ironmongery-options:heavy-duty-hinges] => (string) ""
[base_extra] => (string) "0"
[building_removal_removal-and-taking-away-of-timber-building] => (string) ""
[building_removal_removal-of-greenhouses] => (string) ""
[installation] => (string) "no"
[base-type] => (string) "no base"
[b] => (string) "2"
[delivery] => (string) "2"
[add-to-cart] => (string) "2652"
As you can see, there are no prices. These must be calculated during the add_to_cart processing.
when the cart is displayed the cart item contains
C:\apache\htdocs\wordpress\wp-content\themes\vgc\woocommerce\cart\cart.php(40:0) include(2) 54 1 2022-11-02T23:57:58+00:00 5.483826 0.000206 cf=the_content 38618 163 6 16777216/16777216 2048M F=2496 cart_item default output handler,default output handler
Array
[unique_key] => (string) "2e7394b4d01bd363822d2e65e24e5305"
[custom_price] => (double) 1673.7
[addon_titles] => Array
[0] => (string) "<div><strong>Regency Notton Pent Shed 6' x 4' : </strong> <span>£1163.70</span></div>"
[1] => (string) "<div><strong> Wood Types: Deluxe</strong> <span class='addon__cost'>£328.00</span></div>"
[2] => (string) "<div><strong> Heavy Duty Options: Heavy Duty Roof</strong> <span class='addon__cost'>£62.00</span></div>"
[3] => (string) "<div><strong> Door Window Positions: R1 Option</strong> <span class='addon__cost'>£0.00</span></div>"
[4] => (string) "<div><strong>No Base</strong> <span class='addon__cost'>£0.00</span></div>"
[5] => (string) "<div><strong>Delivery:</strong> <span class='addon__cost'>£120.00</span></div>"
[addon_array] => (NULL)
[key] => (string) "0eeeb9aae12c8c216fe0bef12a7fbeaf"
[product_id] => (integer) 2652
[variation_id] => (integer) 0
[variation] => Array
The product price is the sale price, but the other addons are full price.
The problem was introduced when updating the discount logic for options where the cost was determined as a percentage of the product price.
The code in error was changing the value of $this->options_discount
rather than $this->apply_discount
.
This meant that when the product was added to the cart the prices for the discountable options weren't adjusted.
The fix was to change the name of the variable being set to false, from $this->options_discount
to $this->apply_discount
.
See https://github.com/bobbingwide/vgc/commit/91510e5da73e7ed6724409498f041ff3e74de8e9
I installed the latest version of the theme ( v1.3.2 ) on 3rd November and tested with https://gardenvista.co.uk/store/halls-atrium-12-x-12-ft-hexagonal-green-greenhouse/#options_area where 2 Tier Staging was reduced from £129 to £100.62 The Your order tab showed the correct values as well
In the production site the current version of WooCommerce is 6.5.1. The latest version is 7.0.0
This latest version needs to be
If there are issues eg Warning or Fatal errors then these need to be investigated and fixed. This issue will suffice for the VGC theme.
When everything's OK then the latest version can be installed in production and retested.