| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
xcart 5 additional charge | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
xcart 5 additional charge
Hi,
I want to make it so that if the QTY Ordered is not equal to the Size specified below, an additional charge of ё10 is added to the line total in the cart. I have added a global attribute called "Additional Charge" as a Yes/No selection and plan to add the additional charge as a config value later Example: product has 6 variants: Thickness=10, Size=25 Thickness=10, Size=50 Thickness=10, Size=75 Thickness=10, Size=100 Thickness=20, Size=25 Thickness=20, Size=50 This is what I have so far: PHP Code:
This works and adds ё10 to the line total in the cart if the QTY ordered is not a multiple of 25. All I need to know is how to retreive the Size of the variant selected and the product attribute "Additional Charge" in this function so that I can calculate the price correctly. We are using xcart 5.1.3 Thanks
__________________
www.ecommweb.co.uk Custom X-Cart design and functions eCommerce SEO www.hubmaster.co.uk Combine all your eCommerce channels in your existing website admin +44 (0)1302 325 032 |
|||||||||
#2
|
|||||||||
|
|||||||||
Re: xcart 5 additional charge
I believe \XLite\Model\OrderItem is not the class that you should use for adding extra charges to orders.
I would use the \XLite\Module\CDev\SalesTax\Logic\Order\Modifier class as the example as it does almost the same thing that you need (goes through products and adds an order surcharge). Quote:
\XLite\Model\OrderItem has the getVariant() method, so in your modifier you may interate over order items and compare variants against identifiers of the mentioned options. However, this requires you to hardcode these indentifiers into your module. A better solution would be adding a new checkbox on the "Edit variants" page and checking it for every variant when iterating over order items in your modifier.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
#3
|
|||||||||
|
|||||||||
Re: xcart 5 additional charge
Thanks for the reply
I would agree that adding a surcharge would be preferable and I spent some time trying to get that to work, but after copying and editing that class accordingly I just couldn't figure it out (it didn't ever apply anything). I have found I can use this (below) to get the currently selected Variant info, but could you provide any example as to how to get all other product variants for this order item? PHP Code:
If I can get the non-ordered variants for this product here, I can compare them with the current $amount ordered and then selectively apply the additional charge.
__________________
www.ecommweb.co.uk Custom X-Cart design and functions eCommerce SEO www.hubmaster.co.uk Combine all your eCommerce channels in your existing website admin +44 (0)1302 325 032 |
|||||||||
#4
|
|||||||||
|
|||||||||
Re: xcart 5 additional charge
$product->getVariants() should work. And if you work with order items, try this $item->getProduct()->getVariants().
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
|||
X-Cart forums © 2001-2020
|