6.0 Changes
Important
If upgrading from cart version 4.8.1 or earlier: Please read the documentation very carefully! Please make a backup of your filesystem and database! If possible test the update in a test copy of your TYPO3 instance.
Extracting products to an own cart_products extension
In the last month, there where a lot of projects where the product table was extended to the customer needs. In some cases I come to the result that an own product model respecting the customer domain would be a better solution. So I decided to extract all product related code to an own extension. If you updating from Cart v4.x you have to install the cart_products extension as well.
1. migrate database tables
RENAME TABLE tx_cart_domain_model_product_product TO tx_cartproducts_domain_model_product_product;
RENAME TABLE tx_cart_domain_model_product_specialprice TO tx_cartproducts_domain_model_product_specialprice;
RENAME TABLE tx_cart_domain_model_product_quantitydiscount TO tx_cartproducts_domain_model_product_quantitydiscount;
RENAME TABLE tx_cart_domain_model_product_bevariantattribute TO tx_cartproducts_domain_model_product_bevariantattribute;
RENAME TABLE tx_cart_domain_model_product_bevariantattributeoption TO tx_cartproducts_domain_model_product_bevariantattributeoption;
RENAME TABLE tx_cart_domain_model_product_bevariant TO tx_cartproducts_domain_model_product_bevariant;
RENAME TABLE tx_cart_domain_model_product_fevariant TO tx_cartproducts_domain_model_product_fevariant;
RENAME TABLE tx_cart_domain_model_product_tag TO tx_cart_domain_model_tag;
RENAME TABLE tx_cart_domain_model_product_coupon TO tx_cart_domain_model_coupon;
RENAME TABLE tx_cart_domain_model_product_product_related_mm TO tx_cartproducts_domain_model_product_product_related_mm;
RENAME TABLE tx_cart_domain_model_product_tag_mm TO tx_cartproducts_domain_model_product_tag_mm;
ALTER TABLE tx_cart_domain_model_order_address ADD record_type VARCHAR(255) DEFAULT '' NOT NULL;
ALTER TABLE tx_cart_domain_model_order_address ADD tax_identification_number VARCHAR(255) DEFAULT '' NOT NULL;
ALTER TABLE tt_content CHANGE COLUMN tx_cart_domain_model_product_product tx_cartproducts_domain_model_product_product int(11) unsigned DEFAULT '0' NOT NULL;
2. update cart and install cart_products
Update cart and install cart_product using composer or the update in the extension manager. Include new TypoScript of cart_products.
3. migrate some more the database tables
UPDATE tx_cart_domain_model_order_address SET record_type="\Extcode\Cart\Domain\Model\Order\BillingAddress" WHERE discr="billing";
UPDATE tx_cart_domain_model_order_address SET record_type="\Extcode\Cart\Domain\Model\Order\ShippingAddress" WHERE discr="shipping";
UPDATE sys_file_reference SET tablenames="tx_cartproducts_domain_model_product_product" WHERE tablenames="tx_cart_domain_model_product_product";
UPDATE sys_category_record_mm SET tablenames="tx_cartproducts_domain_model_product_product",fieldname="category" WHERE tablenames="tx_cart_domain_model_product_product" AND fieldname="main_category";
UPDATE sys_category_record_mm SET tablenames="tx_cartproducts_domain_model_product_product" WHERE tablenames="tx_cartproducts_domain_model_product_product" AND fieldname="categories";
4. update all plugins
The code summarized different parts of the business logic into a few controller classes. This results in big controller classes. I decided to split them up in more smaller classes. For an example the updateCountryAction in the the CartController class was moved to the CartCountryController and renamed to updateAction. This encapsulate one part of the business logic to an controller and thus allows better expandability. But that has the consequence that all used plugins has to be updated. The update can't be done by a simple query statement. The following query can help you to find the pages where the plugins are installed.
SELECT tt_content.uid, tt_content.pid, pages.title FROM tt_content LEFT JOIN pages ON tt_content.pid = pages.uid WHERE list_type LIKE "cart_%";
It gives you the uid of the tt_content element, the page id and the title of the page. You have to update all the plugins manually through the backend.
A second consequence are the changes in the Templates and Partials directories. The template files was moved to some subdirectories and the links to controller actions was changed. If you have own cart templates you have to move the files too.
5. change checkboxes for acceptTermsAndConditions, acceptRevocationInstruction, and acceptPrivacyPolicy
In order to link all the documents and get all agreements checked by an own checkbox the two checkboxes acceptTerms and acceptConditions was summarized in the new acceptTermsAndConditions checkbox. I add two more checkboxes. One is the agreement to have read and accept the revocation instructions. And the last is for the privace policy. If you changed the translations or hide one of the old ones, you have to change the TypoScript configuration and translation for the new ones.
plugin.tx_cart {
settings {
validation {
orderItem {
fields {
acceptTermsAndConditions.validator = Boolean
acceptTermsAndConditions.options.is = true
acceptRevocationInstruction.validator = Boolean
acceptRevocationInstruction.options.is = true
acceptPrivacyPolicy.validator = Boolean
acceptPrivacyPolicy.options.is = true
}
}
}
}
}
For more information see: Checkbox Configuration__
6. check used hooks and signal slots
If you extend or override classes, use hooks or signal slots you have to check them carefully. They can be removed or moved to another location.
Sorting of frontend and backend variants
The frontend and backend variants can be sorted in the product configuration.
Important
A database update is required. As this field is new, no problems are expected.
Storing the billing and shipping country codes in the order data
The order now stores the country codes from the TypoScript, so that later processing can access the right configuration.
Important
A database update is required. As this field is new, no problems are expected.
#59 and #64 Filling the billing and shipping address with user data
The showCartAction of the cart plugin now provides a hook showCartActionAfterCartWasLoaded. Besides further changes to the cart, it allows to prefill the billing and shipping address with data of a logged-in user.
Important
The address fields will not be prefilled with data of a logged-in frontend user out of the box. On the one hand this is not wanted in every case, on the other hand the FrontendUser model would have to be extended to store all relevant data of a user. Often these fields are already provided elsewhere.