extcode / cart

Cart is a small but powerful extension which "solely" adds a shopping cart to your TYPO3 installation. The extension allows you to create coupons, products with or without variants, special prices.
GNU General Public License v2.0
57 stars 51 forks source link

Zone Configuration no longer supported #591

Closed Poepp closed 1 month ago

Poepp commented 1 month ago

Bug Report

Current Behavior Looks like the Zone-Configuration of former cart versions is no longer working. In my working cart setup I used the following configuration for payments and shipping:

    shippings {
    zones {
            1 {
               preset = 1
               countries = at
               options {
                   1 {
                       title = Versand Österreich
                       extra = by_price
                       extra {
                         1 {
                           value = 0.00
                           extra = 3.70
                         }
                         2 {
                           value = 100.00
                           extra = 0.00
                         }
                       }
                       taxClassId = 1
                       status = open
                   }
                   2 {
                       title = Abholung
                       extra = 0.00
                       taxClassId = 1
                       status = open
                   }
               }
           }
           2 {
               preset = 1
               countries = de,ch,be,fr,it,lu,nl,sk,si
               options {
                   1 {
                       title = Versand International
                       extra = by_price
                       extra {
                         1 {
                          value = 0.00
                           extra = 5.90
                        }
                         2 {
                           value = 100.00
                           extra = 0.00
                         }
                       }
                       taxClassId = 1
                       status = open
                   }
                   2 {
                       title = Abholung
                       extra = 0.00
                       taxClassId = 1
                       status = open
                   }
               }
           }
        }
    }

    payments {
    zones {
            1 {
                preset = 2
                countries = at,de,ch,be,fr,it,lu,nl,sk,si
                options {
                    1 {
                        title = Vorkasse
                        extra = 0.00
                        taxClassId = 1
                        status = open
                    }
                    2 {
                        provider = PAYPAL
                        title = Paypal
                        extra = 0.50
                        taxClassId = 1
                        status = open
                    }
                    3 {
                        provider = PAYPAL_CREDIT_CARD
                        title = Kreditkarte
                        extra = 0.50
                        taxClassId = 1
                        status = open
                     }
                    4 {
                        provider = PAYPAL_CREDIT_CARD
                        title = Lastschrift
                        extra = 0.50
                        taxClassId = 1
                        status = open
                     }
                }
            }
        }
    }

However, with the breaking change of https://docs.typo3.org/p/extcode/cart/9.0/en-us/Changelog/9.0/Breaking-380-TypoScriptCountriesUniformFormat.html#breaking-380-typoscript-for-countries-in-uniform-format the setup above seems no longer working. This makes sense as the rest of the payment and shipping configuration has changed. I was successfully able to get it working using the normal configuration without using zones.

Therefore it would be great to either update the documentation describing how zones can be used with the new configuration for shippings and payments or just remove the zones configuration feature and give a hint that it's no longer available.

Environment

For reference here the working configuration after adaption to the new structure:

    payments {
        countries {         
            de {
                preset = 1
                options {
                    1 {
                        provider = PAYPAL
                        title = Paypal
                        extra = 0.50
                        taxClassId = 1
                        status = open
                    }
                    2 {
                        provider = PAYPAL_CREDIT_CARD
                        title = Kreditkarte
                        extra = 0.50
                        taxClassId = 1
                        status = open
                     }
                    3 {
                        provider = PAYPAL_CREDIT_CARD
                        title = Lastschrift
                        extra = 0.50
                        taxClassId = 1
                        status = open
                     }
                }
            }
           at < .de
           ch < .de
           be < .de
           fr < .de
           it < .de
           lu < .de
           nl < .de
           sk < .de
           si < .de
        }
    }

    shippings {
       countries {
           at {
               preset = 1
               options {
                   1 {
                       title = Versand Österreich
                       extra = by_price
                       extra {
                         1 {
                           value = 0.00
                           extra = 3.70
                         }
                         2 {
                           value = 100.00
                           extra = 0.00
                         }
                       }
                       taxClassId = 1
                       status = open
                   }
                   2 {
                       title = Abholung
                       extra = 0.00
                       taxClassId = 1
                       status = open
                   }             
                }
             }
           de {
               preset = 1
               options {
                   1 {
                       title = Versand International
                       extra = by_price
                       extra {
                         1 {
                          value = 0.00
                           extra = 5.90
                        }
                         2 {
                           value = 100.00
                           extra = 0.00
                         }
                       }
                       taxClassId = 1
                       status = open
                   }
                   2 {
                       title = Abholung
                       extra = 0.00
                       taxClassId = 1
                       status = open
                   }
               }
           }
           ch < .de
           be < .de
           fr < .de
           it < .de
           lu < .de
           nl < .de
           sk < .de
           si < .de
        }
    }
extcode commented 1 month ago

Zones configuration should work in current version. Perhaps something is missing in your configuration or in our documentation. We have a test https://github.com/extcode/cart/blob/main/Tests/Unit/Service/AbstractConfigurationFromTypoScriptServiceTest.php for that.

I'll try to test your configuration. Perhaps you can debug what's happen in https://github.com/extcode/cart/blob/main/Classes/Service/AbstractConfigurationFromTypoScriptService.php#L49-L83.

extcode commented 1 month ago

I get your configuration working. But I have to remove the countries configuration the cart extension provide as an example:

plugin.tx_cart {
    shippings {
        countries >
    }
    payments {
        countries >
    }
}
Poepp commented 1 month ago

Thanks again for your quick feedback. I've tested your suggestion and it works for me as well. When reading your comment I might have come up with this configuration as well but this was not clear enough to me. Might be worth mentioning it in the docs?! Nevertheless I close this issue.

rintisch commented 1 month ago

Would be great if you could make a suggestion for the docs by creating a pull request! :)

Poepp commented 1 month ago

I will take care but it will take some time as I'm OOO a couple of days.