Version Notes
==== v1.10.1 ====
==== Bug fixes ====
- Fixed calculation order totals in Idev OneStepCheckout and PostNL 1.10.1
==== v1.10.0 ====
==== New Features ====
- Added support for same day delivery.
- Added support for food delivery.
- Added support for shipment from Belgium.
- Matrix rates calculation can use a separate rate for PakjeGemak.
==== Improvements ====
- Compatibility for special characters on packing slip.
- Street number not always required for shipment outside of the Netherlands.
- Improved feedback about wrong configurations in the backend.
- PakjeGemak orders now save the location code and ID in the database.
- Google Maps JS library updated to version 3.22. - The shipmenttype is visible on the packing slip.
- Optional middle name is now visible on the shipment label.
- Different diacritical characters can be used in streetnames.
- Fixed a conflict with the Amasty Order Status extension.
- Several code improvements.
- Changes for the purpose of PHP 7.
==== Bug fixes ====
- If monday isn't a shipment day and the current day is sunday, tuesday won't be seen as delivery option anymore.
- OneStepCheckout doesn't default to PostNL as shipping method anymore.
- The e-mail handler shows the correct delivery times. - The inventory control on configured, bundled and grouped products will go right now.
- Fixed an issue where return shipping labels resulted in white pdf files. - Los voormelden from Globalpack shipment isn't possible anymore.
- Cyprus and Mali aren't EPS countries anymore.
- The correct business hours for pickup locations are now always shown.
==== v1.9.0 ====
- Internal release.
==== v1.8.0 ====
- Internal release.
==== v1.7.2 ====
==== Improvements ====
- Added additional compatibility with the Adyen_Payment extension
- Added a timeout for delivery options AJAX calls. The timeout is set to 5s by default
- Monday delivery is now clearly marked as such in front- and backend, rather than being considered a standard domestic shipment
==== Bug fixes ====
- Fixed a problem where Zend_Pdf could throw errors for certain character combinations
- Fixed a problem where orders without a delivery date could cause fatal errors in the order grid
- Fixed a problem where delivery options in OSC would sometimes not show the delivery address
- Fixed a problem where the PostNL shipping method would not be visible when shipping to the Netherlands when no EPS shipping option was selected
- Fixed a problem where you could choose a default post office delivery shipping option when post office delivery was disabled
- Fixed a problem where certain fields on the PostNL configuration page were available on storeview level, while their parent group was not
- Fixed a problem where fatal errors could occur in GoMage Lightcheckout due to an undefined variable
- PostNL postcode check now also works when the country field is disabled in Idev's OSC
- Fixed a problem where orders would always return next day delivery when delivery options are not used
- Fixed a problem where certain shipping options were unavailable when creating shipments
- Fixed a problem where getConfigMinQty would return 0 or 1 rather than the min Qty
- Non-domestic shipments will no longer show a domestic delivery date
==== v1.7.1 ====
==== Improvements ====
- Refactored references to the TIG_PostNL_Helper_DeliveryOptions class' fee methods so they now call their counterparts in the TIG_PostNL_Helper_DeliveryOptions_Fee class
- Refactored the canUseDeliveryOptions method for GoMage LightCheckout to improve performance
==== Bug Fixes ====
- Fixed an issue with EPS label rotation where sometimes EPS combi-labels would be displayed as regular, non combi-labels.
- Fixed a problem where two config fields would throw E_STRICT_NOTICE level errors which in certain server configurations could lead to subsequent fatal errors when Magento unsuccessfully tried to log the errors.
- Fixed a problem where orders without a PostNL order entity could not be shipped due to a coding error
==== v1.7.0 ====
==== New Features ====
- Added support for sunday delivery.
- Added ability to charge a fee for sunday delivery.
==== Improvements ====
- Added compatibility with Picqer extension.
- Added the option to disable system.xml fields. This may be useful for other extensions that want to replace PostNL features.
- Updated CIF services used to CIF 1.14.
- Improved delivery date calculation to improve performance and stability.
- Updated Track & Trace URL format to the new PostNL standards
- Delivery options on Idev's OneStepCheckout will not immediately save the first available delivery option, rather than waiting for customer interaction
==== Bug Fixes ====
- Fixed an issue where the buspakje configuration modus check ignored the 'isbuspakjeactive' flag.
- Fixed an issue where configurable products never allowed delivery options.
- Fixed a rare problem that could cause an infinite loading spinner in GoMage LightCheckout when saving the selected delivery options.
- Fixed a problem where delivery dates and delivery time estimations are double-corrected for timezone differences.
- Fixed a problem where certain cron jobs would report that a directory is not readable, when actually it is just empty.
- Removed an unnecessary check when determining whether delivery options are available for the current quote.
==== v1.6.0 ====
==== New Features ====
- PostNL delivery options are now compatible with GoMage LightCheckout.
- PostNL MijnPakket login and Postcode check are now compatible with GoMage LightCheckout.
- It is now possible to use Magento's Soap API to confirm PostNL shipments, print shipping labels, get Track&Trace information and more!
- Added the option to not print a PostNL shipping label when printing the PostNL packing slip.
- Added a new uninstall button to safely uninstall the PostNL extension.
==== Improvements ====
- Updated the Google Maps integration to v3.19.
- Optimized error handling for certain CIF errors.
- Reverted the PostNL extension's Zend_Soap implementation to native PHP SoapClient for improved compatibility with HHVM.
- Improved the out-of-stock check used in PostNL delivery options to better match merchant expectations.
- Improved performance when printing packing slips or shipping labels.
- Malta is now considered an EPS destination.
- Added compatibility with Magento's SUPEE-6285 patch.
- Improved the address-splitting regular expression to better split house numbers from street names.
==== Bug Fixes ====
- Fixed an incorrect variable name in the upgradeNotification block.
- Fixed an issue where the mobile phone number popup would not appear when selecting a parcel dispenser location in onestepcheckout after a coupon had been added.
- Fixed a conflict with OneStepCheckout, where selecting a delivery date in the popup and then closing the popup (not by saving, but by using the 'x' icon), PostNL would be selected as delivery option but not the date, leaving the shipment with no shipping information.
- Fixed an issue where products on the PostNL packing slip would sometimes show 0 tax amount.
- The shipping date is now also shown on the packing slip when the show shipping method option is disabled.
- Fixed a javascript issue with PostNL COD when Delivery Options are disabled .
- Fixed several problems relating to a server's time zone configuration.
- Fixed an issue in the date renderers in Magento's backend where an unnecessary timezone correction resulted in incorrect dates being displayed.
- Fixed an issue where the attribute update cron would not be removed automatically when all products were updated.
- Fixed a problem with the temporary update crons when config cache is active.
- Fixed a problem where re-activating a quote after the order had been placed could lead to missing PostNL data.
- Fixed an issue where orders could incorrectly have an expected delivery date when no delivery option was selected.
- Fixed compatibility with payment extensions (e.g. Sisow) to prevent crashing when printing packing slip.
==== v1.5.3 ====
==== Bug Fixes ====
- Fixed an issue where in certain situations the delivery date may be equal to the shipping date for orders where no delivery date was chosen during checkout.
- Fixed an issue where all orders would be considered to be placed past the cut off time when the shipping duration was configured to be more than 1 day.
==== v1.5.2 ====
==== New Features ====
- Added compatibility with the Bpost Shipping Manager extension.
- Added the option to hide often shown warnings for the current admin user.
==== Improvements ====
- Added a warning to the configuration page when using the Postcode.NL extension as this extension may conflict with the PostNL extension/
- The PostNL postcode check functionality is now automatically disabled when using the Postcode.NL extension.
- Improved error handling when changes were made directly to the Magento database.
- The expected shipping and delivery dates are now also saved when no delivery option was selected during checkout.
- Several additional characters are now allowed in the packing slip item columns.
- Modified the way delivery options determine whether products are in stock in order to better match merchant expectations.
- Modified interface element for stock options for delivery options to better match merchant expectations.
- Modified code to prevent errors when the default cut-off time is missing.
- Improved error handling when changing a package shipment to a letter box shipment and the default letter box product option is unavailable.
- Added caching to the store time zones in the PostNL data helper.
- Added additional checks to prevent no extra cover amount from being sent for extra cover shipments.
- Fixed an incorrect English name for parcel dispensers.
- Removed the parcel dispenser label from the delivery options interface.
- Added a new notification to the order email to make it more clear that the customer has chosen to have their order delivered at a pick up location.
- Added a new notification to the billing and shipping address templated in OPC to make it more clear that the customer can select a pick up location in the shipping method step.
- The shipping address is now hidden in the progress bar on OPC when a post office address is selected.
==== Bug Fixes ====
- Fixed the split address lines detection on the PostNL config page. This should prevent incorrect warnings about split address lines from being shown.
- Fixed a bug where the chosen product option was not saved when using the create shipments mass action.
- Fixed the order confirm date renderer for orders that were placed late at night.
- A PostNL order is now also created for orders that do not have an associated delivery option. This prevents unexpected behaviour in the order grid when filtering on the confirm date column.
- Shipping labels are now oriented horizontally to prevent errors when printing directly from Chrome.
- Fixed an issue where the extra cover amount option was shown on the create shipment page when the 'is_buspakje' checkbox was checked by default and an extra product option was selected as default.
- Fixed an issue where buspakje was available for avond shipments.
- Fixed issue with not selecting delivery option in OSC would cause order date to be show as delivery date.
- Fixed an issue where the delivery and confirm dates were calculated using the server's time zone, rather than the UTC time zone.
- Fixed a possible notice due to a missing default value in the 'hour-minute' field renderer.
- Fixed an issue where filtering on the order type column would cause errors due to an incorrect join alias.
- Removed regex-based validation for delivery location names to prevent valid names from being blocked. Instead all tags are stripped from the name and the name is additionally escaped before processing.
- Fixed an issue which caused the Magento table rates title to be displayed for PostNL.
- Fixed an issue which caused the default letter box parcel option configuration setting to not be visible.
- Fixed an issue which could cause JS errors when there was an error while loading delivery options.
- Dots are now allowed in street addresses..
- Fixed a small typo in certain error messages.
- Fixed a small layout problem in the delivery options on small desktop screens.
- Fixed a bug where delivery options are not available when purchasing the same configurable product twice with different options.
- Fixed a warning message in the update attributes cron due to an undefined index.
- Fixed an issue where only come delivery options are available when the product attribute cron is still running.
==== v1.5.1 ====
==== New Features ====
- Added a parcel dispenser filter to the delivery options location picker.
==== Improvements ====
- Improved the available filter options for the shipping date columns in the order and shipment grids.
- Improved the way parcel dispenser pick-up locations are shown in the delivery options interface.
- The chosen pick up location is now shown in Idev's OneStepCheckout's order preview pop-up.
- It is no longer possible to configure the extension to use split address lines when there is only 1 address line available.
- When using split address lines it is no longer possible to use the same address line for multiple fields.
==== Bug fixes ====
- Fixed a problem that prevented PostNL Checkout orders from being placed.
- Removed an unnecessary css link in the default Magento theme.
- Phone numbers are no longer mandatory for PostNL post office locations.
==== v1.5.0 ====
==== New features ====
- Added support for printing return labels and tracking return shipments.
- You may now change the number of parcels in a shipment as long as the shipment has not yet been confirmed with PostNL.
- Added the option to show the chosen delivery options and post office pick-up location in transactional e-mails.
- Added a new mass action to the shipment grid to update the shipping status of selected shipments.
==== Improvements ====
- The extension has been updated to CIF 1.10 specifications.
- Cut-off times now take the store's time zone into account.
- Improved performance in the webshop's backend.
- Reduced the risk of extension conflicts in the order and shipment grids.
- It is now possible to print GlobalPack shipping labels even when one of the products in the shipment is missing a country of origin value.
- Address lines on the PostNL packing slip now have a maximum size of 33 characters (up from 20).
- The selected post office location is now shown on the sales/guest/form pages in Magento.
- The confirm and delivery dates of a shipment are now stored in the UTC time zone in the database.
- The selected post office location is now shown on the OnePage Checkout progress bar during checkout.
- The schedules of several cronjobs related to background processes have been redistributed over the day to reduce the load on the sever's cron during peak hours.
- VAT and discounts are now taken into account when calculating a shipment's base grandtotal amount.
- The extension will now shown a proper error message when the sever's PHP version is below the minimum version required by the PostNL extension (PHP 5.3.0).
- Decimal values are now allowed in the alternative standard product option field.
- Shipping labels will now be deleted from the database 30 days after the shipment has been delivered in order to give the consumer enough time to return the shipments without allowing the database to become too bloated.
==== Bug fixes ====
- The Track & Trace URL for orders which are shipped to post office locations has been modified to correctly use the postcode of the intended recipient.
- PostNL mass actions in the order grid will no longer affect non-PostNL mass actions which may have been added by other extensions.
- Postcodes are no longer required in order to create a Track & Trace URL.
- It is no longer possible to modify the confirmation of letter box parcel shipments without Track & Trace.
- An issue in Magento CE 1.6 and EE 1.11 has been resolved by no longer relying on the 'DEFAULT_DEST_STREET' constant value.
- MijnPakket login and delivery options are now also compatible with Idev's OneStepCheckout when the shipping address form has been disabled.
- Letter box parcel configuration options are now also applied to grouped products.
- The chosen delivery day is no longer shown on the customer's account page when delivery days have been disabled in the extension's configuration.
- Product's alternative shipping duration values are now taken into account when calculating the probable delivery day for orders when no specific delivery day was chosen during checkout.
- Tuesday is no longer shown as a valid delivery day when monday is not a shipping day and it is already past saturday.
==== v1.4.1 ====
==== New features ====
- Completely redesigned the configuration page of the extension!
- The extension's configuration page has now been split into a wizard-style menu for the core settings and a separate advanced options menu.
==== Improvements ====
- Added forwards compatibility to Magento 1.6 for advanced configuration field dependencies and other features that were introduced in Magento 1.7.
- Only stated address fee will now be hidden if the fee is less than 1 cent.
- Delivery days will now show 'as soon as possible' as the delivery time when no delivery days are available.
- The status update cron will now run 3 times a day. Before it was only 2 times a day.
- Added additional transactional email parameters to the track & trace email.
==== Bug fixes ====
- Only stated address option is no longer available for letter box orders.
- Removed two legacy references to css files from the frontend's layout XML file.
- Fixed a problem where the delivery option fee would not be reset if delivery options became unavailable during checkout.
- Fixed the delivery options responsive design in OneStepCheckout on older versions of Magento.
- Fixed an issue that prevented the order grid from being filtered on the order ID column.
- International track & trace URL's now use PostNL's new track & trace URL syntax. The old syntax is no longer supported by PostNL.
- Fixed a PHP warning level error that could occur if no additional options were saved for a PostNL order.
==== v1.4.0 ====
==== New features ====
- Added a new responsive design for PostNL delivery options.
- Added the option to specify on which days of the week the merchant will ship orders.
- Added the option to print packing slips directly from the order detail page.
- Added the option for customers to choose whether their order can be delivered to their neighbours in case they are not home during the delivery.
- Added a new PostNL rate type that allows merchants to finely tune their shipping costs.
- Added the option to charge a separate shipping rate for letter box parcels.
==== Improvements ====
- Modified a lot of heavy loading functionality in order to improve performance.
- PostNL Checkout will now check if an order is a letter box parcel before deciding whether PostNL Checkout should be available.
- In order to decrease server load during the extension's installation or upgrade, modifying product attributes is now handled by a temporary cron job.
- A comment will now be added to the order and shipment page when the PostNL track & trace email is sent.
- Evening delivery will no longer be available for letter box parcel orders.
==== Bug fixes ====
- FIxed the filter functionality of the order grid's confirm date column.
- Fixed a problem where the extra cover amount was missing when extra cover was used as a default shipping option.
- Fixed a problem where adding coupon codes in OneStepCheckout would disable delivery options.
- PostNL Checkout's weight calculation will no longer assume all items are weightless when a free shipping cart rule is active.
- Fixed a problem in the CMS page source model causing errors.
- Fixed a problem where tax calculation would not work as expected when tax calculation was set to before discount.
- Fixed a problem where it would be impossible to use the create shipment mass action when certain product options were disabled.
- Fixed problem where shipping to EPS countries could cause errors.
- Fixed an issue where the COD payment method would be hidden for regular shipments.
- Fixed an issue where the print labels mass action would also confirm the shipment
- Adding a new address in multi-address checkout will no longer cause errors when postcode check has been enabled.
- Fixed a bug in the updatePostnlOrder observer that caused errors when ordering virtual orders.
==== v1.3.1 ====
==== Bug fixes ====
- Confirm dates will no longer be shown as always being in the future.
- Added additional checks to prevent deleted Magento orders and shipments from causing errors.
- Prevented VAT amounts from being shown twice on the checkout page.
- It is no longer impossible to create multi-parcel shipments when 'letter box calculation mode' is set to automatic.
- Prevented COD fees from causing errors on the invoice page in the backend.
==== v1.3.0 ====
==== New features ====
- Added the option to ship orders as letter box parcels. Letter box parcels are shipped using the regular mail service and can be shipped at a reduced rate. It's possible to let the PostNL extension determine when an order qualifies as a letter box parcel or to decide this manually when creating a shipment in Magento.
- Added a new PostNL COD payment method that is fully integrated in the other PostNL services offered by the extension. It's possible to charge an additional fee to customers for using PostNL COD. It's also possible to have the extension automatically invoice COD orders once they have been delivered to the customer.
- Added a new PostNL packing slip. This packing slip may contain the PostNL shipping label, allowing you to use the packing slip as the shipping label for the parcel.
- Added the option to enable or disable delivery options at the product level.
- Added the ability to convert existing shipments to a letter box parcel or to a regular parcel as long as they have not been received by PostNL.
- Added the ability to change the selected shipping option for a shipment as long as it has not yet been received by PostNL.
- Added the option to use additional shipping methods for PostNL.
- Added the option to create a shipment, confirm it and print it's shipping labels for an order straight from the order grid in a single click.
==== Improvements ====
- It's now possible to enable or disable time frames separately from delivery days.
- You can now specify the cut-off time in minutes as well as hours.
- You can now view an order's confirm date, confirm status and shipping phase in the order grid.
- Additional information regarding the chosen delivery option is now shown on the order detail page.
- Added a button to download all PostNL debug log files to the PostNL configuration page.
- The 'create shipments' massaction interface has been modified so that only valid options are displayed.
- Errors that occur whilst processing multiple shipments or orders will no longer stop the entire process. Instead the remaining orders and shipments will be processed and an error message specifying which orders or shipments caused an error will be displayed afterwards.
- The first and last name fields are no longer mandatory for the sender's address fields in the PostNL configuration.
- Spaces are now allowed in postcodes.
==== Bug fixes ====
- Deleting orders from Magento should no longer cause errors when processing PostNL shipments.
- The PostNL shipping method will no longer be selected by default.
- Greece will now be processed with EPS, instead of GlobalPack.
- Upgrade and install scripts will now check if certain columns and attributes exist before modifying them.
- The progress bar on the Onepage Checkout page will now correctly update the shipping costs when the customer has chosen a delivery option that charges an additional fee.
- Creating shipments for which no default shipping option is selected will no longer cause errors.
==== v1.2.2 ====
==== New features ====
- Added the option to send a copy of the track & trace email to a specified email address.
==== Improvements ====
- Performance of the entire extension has been improved. The extension will now attempt to cache several configuration values.
- Label printing will now always follow the 'label size' configuration setting.
==== Bug fixes ====
- Fixed several small html errors in the track & trace email template.
- Fixed an SQL error that could occur when filtering the 'store' column in the order and shipment grids.
==== v1.2.1 ====
==== Release highlights ====
- The extension now fully supports Magento 1.9 and 1.14!
==== Minor improvements ====
- Added additional checks to prevent errors when Magento's layout has been altered or PostNL's layout has not been uploaded properly.
- Added additional compatibility enhancements for MultiSafePay and other PSP extensions.
- Improved several minor texts and translations.
==== Bug fixes ====
- Fixed an issue that prevented MijnPakket login data from being cached.
- Fixed an issue where using PostNL-only features on non-PostNL shipments would cause an error.
- Fixed an issue where PostNL's feed messages would be loaded in the wrong order.
- Fixed an issue where several notifications would be added to Magento when installing an unsupported version of Magento with the PostNL extension.
- Fixed an issue with EPS comb-labels. EPS combi-labels were rotated by 90 degrees, causing overlapping issues with other labels being printed.
==== v1.2.0 =====
==== New features ====
- Added delivery options to the checkout flow. Customers can now choose where, when and how they want their order shipped when choosing their preferred shipping method.
- Added support for evening delivery, early pickup locations and parcel dispenser locations.
- Added Dutch postcode validation support.
- Added the option to create a parcelware export csv file directly from the Magento backend.
- Added a MijnPakket login feature. Customers who have a MijnPakket account can use this feature to automatically fill in their preferred billing and shipping address.
==== Minor improvements ====
- Refactored the label printing functionality. Shipping labels will now be opened in a separate window from where they may be printed or downloaded.
- Added the option to select where on an A4 page the shipping labels will start printing. This allows you to re-use partially used sticker-sheets.
- Added many new customization options for the shipment grid in the Magento backend.
- Added the ability to view and edit a chosen post office delivery address from the Magento backend.
- Added the option to only show the PostNL Checkout feature to customers who have a MijnPakket account.
- Refactored many sections of the source code to improve readability and extensibility.
- Moved several configuration settings.
- Merged the 'test/live mode' settings of PostNl Checkout and Label Printing & Confirming functionality. There is now a single option to set the entire extension to test or live mode.
- Added the option to upload separate csv files for the PostNL shipping method in 'table rate' configuration.
==== Bug fixes ====
- Fixed an issue where it was not possible to choose to only manually send track & trace information.
- Fixed several typos and translation errors.
==== v1.1.5 =====
==== Bug fixes ====
- Fixed a problem with account validation only using test mode account credentials
- Made a minor security improvement to the notification system.
- Fixed an issue where shipments could not be confirmed if the shipping address did not have an email address.
- Fixed an issue where PostNl Checkout would incorrectly identify a product as being out of stock.
- Fixed an issue where for some shops PostNl Checkout would not function due to incorrect usage of https in an http environment.
==== v1.1.4 =====
==== New features ====
- Added a default test account to the extension. New installation will automatically have a PostNL test account pre-configured.
- Added the option to undo a confirmation as long as the shipment has not been received by PostNL.
- Added the option to delete shipping labels. This allows you to correct an address after a shipping label has been printed. Before this change if you noticed an error in the address after you had already printed a shipping label, you had to place en entire new order to correct it. Now you can simply delete the shipping label, edit the address and print a new shipping label with the new address.
==== Minor change ====
- The validate settings button in the extension’s configuration page now also validates settings while the extension is set to test mode.
- Removed the 'EU Pack Standard (Belgium only, no signature)' product option. If you use this option, please contact the Total Internet Group servicedesk.
- The extension's test mode is now available by default. In earlier versions you had to allow test mode through a setting under advanced options.
- When a confirmation expires, the barcode's track & trace link will now also be removed.
- Improved various texts and translations.
==== Bug fixes ====
- Solved an issue where certain configurations of the PostNL shipping method would only appear if the Magento tablerates shipping method was also active.
- Solved an issue where filtering the order and shipment grids in the Magento backend on certain columns would cause an error.
- Solved an issue where the shipment status cron would stop as soon as it encountered an error, rather than continue processing the remaining shipments.
- Solved an issue where you could not confirm a shipment without a barcode due to process locking when developer mode is active.
- Solved issue in Safari where labels would be printed as .pdf.html, rather than just .pdf files.
==== v1.1.3 ====
- FIxed an issue with the extension's activation procedure.
==== v1.1.2 ====
- Updated manual.
==== v1.1.1 ====
- Fixed issue where filtering the first column of the shipment grid could cause errors.
- Removed PHP extension dependencies from the PostNL extension packages. Magento connect would sometimes falsely report a PHP extension as missing preventing the PostNL extension from being installed.
==== v1.1.0 ====
- First public release.
==== v1.0.8 ====
- Improved compatibility with Magento 1.6 and 1.11.
==== v1.0.7 ====
- Improved configuration fields.
- Improved translations.
==== v1.0.6 ====
- Improved shipment grid interface. It shoulod now be more clear which shipments have been confirmed and when they should be handed over to PostNL.
- Improved PostNL Checkout payment method handling. The Checkout summary page should now remember your chosen bank when you attempt to pay using iDEAL. 100% support for all payment methods is not guaranteed.
==== v1.0.5 ====
- Several bug fixes.
- Improved configuration interface.
==== v1.0.4 ====
- Several minor bug fixes.
- Improved Dutch translations.
- Added additional information to several fields in system/config.
==== v1.0.3 ====
- Several bug fixes. Including an issue preventing the extension from functioning properly with the compiler active.
- Several improvements to the Dutch translations.
- Improved the extension's system > config interface
- Added the Klarna payment method to PostNL Checkout
==== v1.0.2 ====
- A large number of bug fixes and general improvements
- Improved error handling. Almost all errors will now automatically provide you with a link where you can find more information and a possible solution.
==== v1.0.1 ====
- Added a filter to the possible product options you may select, based on the selected orders when mass-creating shipments from the order grid.
- Improved several translations.
- Fixed several minor bugs.
==== v1.0.0 ====
This is the initial beta release of the extension. If you have any questions, please contact the Total Internet Group Servicedesk
Release Info
Developer | TIG |
Extension | tig_postnl |
Version | 1.10.1 |
Comparing to | |
See all releases |
Code changes from version 1.7.2 to 1.10.1
- app/code/community/TIG/PostNL/Block/AddressValidation/GoMage/LightCheckout/Billing.php +30 -14
- app/code/community/TIG/PostNL/Block/AddressValidation/GoMage/LightCheckout/Shipping.php +30 -14
- app/code/community/TIG/PostNL/Block/Adminhtml/Carrier/Postnl/Matrixrate/Grid.php +3 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Carrier/Postnl/Tablerate/Grid.php +3 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/CronNotification.php +5 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/IntegrityNotification.php +2 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/LogNotification.php +2 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Items/Column/Qty.php +5 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Create/Totals/CodFee.php +9 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Creditmemo/Create/CodFee.php +11 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Creditmemo/Totals/CodFee.php +13 -5
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Invoice/Totals/CodFee.php +12 -5
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/ProductOptions.php +14 -8
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Shipment/Create/ShipmentOptions.php +37 -14
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Shipment/View/DeliveryOptions.php +28 -6
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Shipment/View/ShippingStatus.php +4 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Shipment/View/Tab/StatusHistory.php +7 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Shipment/View/Tabs.php +10 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Totals/CodFee.php +15 -5
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/View/DeliveryOptions.php +35 -7
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Returns.php +3 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Returns/Grid.php +10 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form.php +41 -6
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ActivateButton.php +3 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ActivatedFieldHeader.php +2 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/AddressLines.php +7 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/Anchor.php +10 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/CheckForWarningBox.php +53 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/Checkbox.php +2 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ConfigCheck.php +54 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/GoMageDeliveryDateConflicts.php +6 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/GooglePlacesActive.php +58 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/Hidden.php +24 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/HourMinute.php +23 -8
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/InfoBox.php +1 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/MatrixrateExport.php +7 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/MatrixrateImport.php +2 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/Obscure.php +2 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/OscDeliveryDateActive.php +58 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/PackingSlipItemColumns.php +8 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/PostcodeNlExtensionActive.php +5 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/Radios.php +5 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/SplitAddressCheck.php +7 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/SupportTab.php +108 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/TablerateExport.php +7 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/TablerateImport.php +2 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/TextBox/Abstract.php +1 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/Tooltip/HourMinute.php +7 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/UninstallButton.php +4 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ValidateButton.php +5 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/WarningBox.php +1 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/WizardSaveButton.php +10 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Fieldset.php +25 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Js.php +9 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/Template.php +2 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/UpgradeNotification.php +1 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Form/Element/Dependence.php +5 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Filter/ConfirmDate.php +7 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/Action.php +21 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/Barcode.php +8 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ConfirmDate.php +21 -6
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ConfirmStatus.php +8 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/CountryArray.php +4 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/DeliveryDate.php +11 -4
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/OrderConfirmDate.php +1 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/OrderConfirmStatus.php +12 -11
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/OrderType.php +8 -8
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ReturnView.php +5 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ShipmentType.php +6 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ShippingDescription.php +10 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ShippingPhase.php +6 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/Time.php +13 -3
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/Translate.php +3 -1
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/Type/Abstract.php +130 -31
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/YesNo.php +6 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Massaction/Item/Additional/LabelStartPos.php +2 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Massaction/Item/Additional/ProductOptions.php +2 -2
- app/code/community/TIG/PostNL/Block/Adminhtml/WindowsTheme.php +6 -4
- app/code/community/TIG/PostNL/Block/Checkout/Cart/CheckoutLink.php +15 -5
- app/code/community/TIG/PostNL/Block/Checkout/Cart/Js.php +16 -6
- app/code/community/TIG/PostNL/Block/Checkout/Summary.php +11 -2
- app/code/community/TIG/PostNL/Block/Core/JsTranslate.php +6 -3
- app/code/community/TIG/PostNL/Block/Core/Order/Returns/Info.php +3 -2
- app/code/community/TIG/PostNL/Block/Core/Order/Returns/Shipment/Items.php +5 -2
- app/code/community/TIG/PostNL/Block/Core/ShippingStatus.php +8 -3
- app/code/community/TIG/PostNL/Block/Core/Template.php +2 -2
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Checkout/AddPhoneNumber.php +6 -3
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Checkout/DeliveryOptions.php +137 -51
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Checkout/GoMage/LightCheckout/DeliveryOptions.php +2 -2
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Checkout/Progress.php +2 -2
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Js.php +3 -3
- app/code/community/TIG/PostNL/Block/DeliveryOptions/PickupNotification.php +5 -3
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Template.php +6 -3
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Theme.php +11 -4
- app/code/community/TIG/PostNL/Block/Mijnpakket/AccountNotification.php +16 -6
- app/code/community/TIG/PostNL/Block/Mijnpakket/Js.php +6 -3
- app/code/community/TIG/PostNL/Block/Mijnpakket/LoginButton.php +11 -4
- app/code/community/TIG/PostNL/Block/Mijnpakket/OrderSuccessJs.php +3 -2
- app/code/community/TIG/PostNL/Block/Payment/Checkout/Total/CodFee.php +8 -3
- app/code/community/TIG/PostNL/Block/Payment/Form/Cod.php +7 -3
- app/code/community/TIG/PostNL/Block/Payment/Info.php +2 -2
- app/code/community/TIG/PostNL/Block/Payment/Sales/Order/Creditmemo/Totals/CodFee.php +14 -5
- app/code/community/TIG/PostNL/Block/Payment/Sales/Order/Invoice/Totals/CodFee.php +11 -5
- app/code/community/TIG/PostNL/Block/Payment/Sales/Order/Totals/CodFee.php +16 -5
- app/code/community/TIG/PostNL/Controller/Adminhtml/Abstract.php +3 -2
- app/code/community/TIG/PostNL/Controller/Adminhtml/Config.php +8 -7
- app/code/community/TIG/PostNL/Controller/Adminhtml/Shipment.php +5 -3
- app/code/community/TIG/PostNL/Controller/Sales.php +27 -11
- app/code/community/TIG/PostNL/Exception.php +1 -1
- app/code/community/TIG/PostNL/Helper/AddressValidation.php +107 -5
- app/code/community/TIG/PostNL/Helper/Adminhtml.php +28 -3
- app/code/community/TIG/PostNL/Helper/Carrier.php +20 -3
- app/code/community/TIG/PostNL/Helper/Checkout.php +5 -3
- app/code/community/TIG/PostNL/Helper/Cif.php +136 -29
- app/code/community/TIG/PostNL/Helper/Data.php +216 -58
- app/code/community/TIG/PostNL/Helper/Date.php +120 -33
- app/code/community/TIG/PostNL/Helper/DeliveryOptions.php +624 -84
- app/code/community/TIG/PostNL/Helper/DeliveryOptions/Fee.php +49 -17
- app/code/community/TIG/PostNL/Helper/Mijnpakket.php +8 -4
- app/code/community/TIG/PostNL/Helper/Parcelware.php +1 -1
- app/code/community/TIG/PostNL/Helper/Payment.php +3 -2
- app/code/community/TIG/PostNL/Helper/Webservices.php +4 -2
- app/code/community/TIG/PostNL/Model/AddressValidation/Cendris.php +1 -1
- app/code/community/TIG/PostNL/Model/AddressValidation/Cendris/Abstract.php +7 -3
- app/code/community/TIG/PostNL/Model/AddressValidation/Observer/AddressBook.php +6 -3
- app/code/community/TIG/PostNL/Model/AddressValidation/Observer/OneStepCheckout.php +8 -5
- app/code/community/TIG/PostNL/Model/AddressValidation/Observer/Onepage.php +12 -6
- app/code/community/TIG/PostNL/Model/AddressValidation/System/Config/Backend/ValidateAccount.php +9 -6
- app/code/community/TIG/PostNL/Model/Admin/Inbox.php +1 -1
- app/code/community/TIG/PostNL/Model/Admin/Logging/Handler/Postnl.php +8 -12
- app/code/community/TIG/PostNL/Model/Admin/Logging/Observer.php +8 -5
- app/code/community/TIG/PostNL/Model/Adminhtml/Form/Element/Checkbox.php +9 -2
- app/code/community/TIG/PostNL/Model/Adminhtml/Observer/OrderGrid.php +170 -16
- app/code/community/TIG/PostNL/Model/Adminhtml/Observer/ShipmentGrid.php +57 -15
- app/code/community/TIG/PostNL/Model/Adminhtml/Observer/ShipmentView.php +41 -16
- app/code/community/TIG/PostNL/Model/Adminhtml/Observer/SystemConfig.php +6 -3
- app/code/community/TIG/PostNL/Model/Adminhtml/Support/Logs.php +7 -4
- app/code/community/TIG/PostNL/Model/Adminhtml/System/Config/Form/FoodWarnings.php +262 -0
- app/code/community/TIG/PostNL/Model/Adminhtml/System/Config/Source/OrderGridColumns.php +1 -1
- app/code/community/TIG/PostNL/Model/Adminhtml/System/Config/Source/OrderGridMassaction.php +1 -1
- app/code/community/TIG/PostNL/Model/Adminhtml/System/Config/Source/ShipmentGridColumns.php +1 -1
- app/code/community/TIG/PostNL/Model/Adminhtml/System/Config/Source/ShipmentGridMassaction.php +1 -1
- app/code/community/TIG/PostNL/Model/Carrier/Matrixrate.php +2 -2
- app/code/community/TIG/PostNL/Model/Carrier/Postnl.php +373 -241
- app/code/community/TIG/PostNL/Model/Carrier/Quote/Address/Total/Shipping.php +21 -6
- app/code/community/TIG/PostNL/Model/Carrier/Resource/Matrixrate.php +60 -17
- app/code/community/TIG/PostNL/Model/Carrier/Resource/Matrixrate/Collection.php +3 -2
- app/code/community/TIG/PostNL/Model/Carrier/Resource/Tablerate.php +3 -2
- app/code/community/TIG/PostNL/Model/Carrier/Resource/Tablerate/Collection.php +3 -2
- app/code/community/TIG/PostNL/Model/Carrier/System/Config/Backend/Matrixrate.php +2 -2
- app/code/community/TIG/PostNL/Model/Carrier/System/Config/Backend/Tablerate.php +2 -2
- app/code/community/TIG/PostNL/Model/Carrier/System/Config/Source/RateType.php +1 -1
- app/code/community/TIG/PostNL/Model/Carrier/System/Config/Source/TablerateSource.php +1 -1
- app/code/community/TIG/PostNL/Model/Carrier/Tablerate.php +2 -2
- app/code/community/TIG/PostNL/Model/Checkout/Cif.php +27 -9
- app/code/community/TIG/PostNL/Model/Checkout/Observer/Order.php +5 -2
- app/code/community/TIG/PostNL/Model/Checkout/Observer/Shipment.php +7 -1
- app/code/community/TIG/PostNL/Model/Checkout/Order.php +2 -2
- app/code/community/TIG/PostNL/Model/Checkout/Service.php +44 -8
- app/code/community/TIG/PostNL/Model/Checkout/System/Config/Source/ActivePaymentMethods.php +4 -2
- app/code/community/TIG/PostNL/Model/Checkout/System/Config/Source/CmsPage.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/Api.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Api/V2.php +19 -6
- app/code/community/TIG/PostNL/Model/Core/Cache.php +8 -2
- app/code/community/TIG/PostNL/Model/Core/Cif.php +183 -16
- app/code/community/TIG/PostNL/Model/Core/Cif/Abstract.php +24 -2
- app/code/community/TIG/PostNL/Model/Core/Cif/Exception.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/Label.php +14 -2
- app/code/community/TIG/PostNL/Model/Core/Observer/Barcode.php +17 -3
- app/code/community/TIG/PostNL/Model/Core/Observer/Cache.php +3 -2
- app/code/community/TIG/PostNL/Model/Core/Observer/Cron.php +72 -28
- app/code/community/TIG/PostNL/Model/Core/Observer/Returns.php +8 -4
- app/code/community/TIG/PostNL/Model/Core/Observer/SaveShipment.php +5 -2
- app/code/community/TIG/PostNL/Model/Core/Order.php +47 -7
- app/code/community/TIG/PostNL/Model/Core/PackingSlip.php +130 -16
- app/code/community/TIG/PostNL/Model/Core/Packingslip/Pdf/Items/Invoice/Default.php +10 -4
- app/code/community/TIG/PostNL/Model/Core/Resource/Integrity.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Integrity/Collection.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Order.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Order/Collection.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Barcode.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Barcode/Collection.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Collection.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Label.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Label/Collection.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Status/History.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Status/History/Collection.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Service.php +21 -10
- app/code/community/TIG/PostNL/Model/Core/Service/IntegrityCheck.php +8 -2
- app/code/community/TIG/PostNL/Model/Core/Service/InvoiceDummy.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Service/OrderDummy.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Service/PaymentDummy.php +4 -2
- app/code/community/TIG/PostNL/Model/Core/Service/PaymentMethodDummy.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Service/Shipment.php +43 -21
- app/code/community/TIG/PostNL/Model/Core/Shipment.php +351 -87
- app/code/community/TIG/PostNL/Model/Core/Shipment/Barcode.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/Shipment/Label.php +7 -5
- app/code/community/TIG/PostNL/Model/Core/Shipment/Process.php +10 -6
- app/code/community/TIG/PostNL/Model/Core/Shipment/Status/History.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Backend/HourMinute.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/System/Config/Backend/Image/Pdf.php +4 -5
- app/code/community/TIG/PostNL/Model/Core/System/Config/Backend/ProductType.php +85 -0
- app/code/community/TIG/PostNL/Model/Core/System/Config/Backend/SenderCountry.php +37 -3
- app/code/community/TIG/PostNL/Model/Core/System/Config/Backend/ValidateDefaultOption.php +5 -2
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/AllProductOptions.php +53 -2
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/Attributes.php +3 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/BuspakjeProductOptions.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/CheckoutExtensions.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/CommentType.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/CooledProductOptions.php +154 -0
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/CutOffTime.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/DebugMode.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/Direction.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/EuProductOptions.php +2 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/FoodProductOptions.php +154 -0
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/GlobalProductOptions.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/GlobalpackShipmentType.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/HourMinute.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/LabelSize.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/ManualAutomatic.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/PackingSlipItemFields.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/PackingSlipLabel.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/PakjeGemakProductOptions.php +71 -42
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/PakketautomaatProductOptions.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/ProductOptions/Abstract.php +5 -2
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/ReferenceType.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/SenderCountry.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/ShippingDays.php +2 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/ShippingDuration.php +5 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/ShippingDurationDays.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/ShippingMethods.php +15 -12
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/StandardProductOptions.php +60 -3
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/StaticBlocks.php +2 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/StreetField.php +3 -2
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/StreetFieldWithDefault.php +2 -2
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/SundayProductOptions.php +1 -1
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/WeightUnit.php +1 -1
- app/code/community/TIG/PostNL/Model/DeliveryOptions/Cif.php +102 -32
- app/code/community/TIG/PostNL/Model/DeliveryOptions/Observer/GoMage/LightCheckout/Ajax.php +2 -2
- app/code/community/TIG/PostNL/Model/DeliveryOptions/Observer/ShippingMethodAvailable.php +17 -16
- app/code/community/TIG/PostNL/Model/DeliveryOptions/Observer/UpdateConfig.php +136 -0
- app/code/community/TIG/PostNL/Model/DeliveryOptions/Observer/UpdatePostnlOrder.php +99 -27
- app/code/community/TIG/PostNL/Model/DeliveryOptions/Product/Attribute/Source/ProductType.php +118 -0
- app/code/community/TIG/PostNL/Model/DeliveryOptions/Product/Attribute/Source/ShippingDuration.php +7 -3
- app/code/community/TIG/PostNL/Model/DeliveryOptions/Service.php +29 -41
- app/code/community/TIG/PostNL/Model/DeliveryOptions/System/Config/Backend/ValidateFee.php +16 -8
- app/code/community/TIG/PostNL/Model/DeliveryOptions/System/Config/Backend/ValidateFee/SameDayDeliveryFee.php +46 -0
- app/code/community/TIG/PostNL/Model/DeliveryOptions/System/Config/Backend/ValidateFee/SundayDeliveryFee.php +2 -2
- app/code/community/TIG/PostNL/Model/DeliveryOptions/System/Config/Source/DeliveryDaysNumber.php +1 -1
- app/code/community/TIG/PostNL/Model/DeliveryOptions/System/Config/Source/StockOptions.php +1 -1
- app/code/community/TIG/PostNL/Model/DeliveryOptions/System/Config/Source/Themes.php +3 -2
- app/code/community/TIG/PostNL/Model/ExtensionControl/Config.php +3 -2
- app/code/community/TIG/PostNL/Model/ExtensionControl/Feed.php +6 -2
- app/code/community/TIG/PostNL/Model/ExtensionControl/Observer/Cron.php +20 -8
- app/code/community/TIG/PostNL/Model/ExtensionControl/Webservices.php +76 -13
- app/code/community/TIG/PostNL/Model/ExtensionControl/Webservices/Abstract.php +7 -3
- app/code/community/TIG/PostNL/Model/Inbox.php +1 -1
- app/code/community/TIG/PostNL/Model/Mijnpakket/Cif.php +2 -2
- app/code/community/TIG/PostNL/Model/Mijnpakket/Service.php +2 -2
- app/code/community/TIG/PostNL/Model/Parcelware/Export.php +25 -9
- app/code/community/TIG/PostNL/Model/Payment/Cod.php +32 -3
- app/code/community/TIG/PostNL/Model/Payment/Observer/Cod.php +10 -4
- app/code/community/TIG/PostNL/Model/Payment/Order/Creditmemo/Total/CodFee.php +19 -3
- app/code/community/TIG/PostNL/Model/Payment/Order/Creditmemo/Total/CodFee/Abstract.php +12 -2
- app/code/community/TIG/PostNL/Model/Payment/Order/Creditmemo/Total/CodFeeTax.php +18 -2
- app/code/community/TIG/PostNL/Model/Payment/Order/Invoice/Total/CodFee.php +6 -2
- app/code/community/TIG/PostNL/Model/Payment/Order/Invoice/Total/CodFeeTax.php +7 -2
- app/code/community/TIG/PostNL/Model/Payment/Order/Invoice/Total/Subtotal.php +4 -1
- app/code/community/TIG/PostNL/Model/Payment/Order/Pdf/Total/CodFee.php +10 -5
- app/code/community/TIG/PostNL/Model/Payment/Order/Pdf/Total/Grandtotal.php +13 -5
- app/code/community/TIG/PostNL/Model/Payment/Order/Pdf/Total/Tax.php +10 -4
- app/code/community/TIG/PostNL/Model/Payment/Quote/Address/Total/CodFee.php +12 -3
- app/code/community/TIG/PostNL/Model/Payment/Quote/Address/Total/CodFee/Abstract.php +13 -5
- app/code/community/TIG/PostNL/Model/Payment/Quote/Address/Total/CodFeeTax.php +16 -6
- app/code/community/TIG/PostNL/Model/Payment/Service.php +21 -29
- app/code/community/TIG/PostNL/Model/Payment/System/Config/Source/CodFeeTaxClass.php +5 -3
- app/code/community/TIG/PostNL/Model/Resource/Catalog/Product.php +2 -2
- app/code/community/TIG/PostNL/Model/Resource/Db/Abstract.php +5 -2
- app/code/community/TIG/PostNL/Model/Resource/Db/Collection/Postnl.php +9 -1
- app/code/community/TIG/PostNL/Model/Resource/Order/Grid/Collection.php +9 -1
- app/code/community/TIG/PostNL/Model/Resource/Order/Shipment.php +2 -2
- app/code/community/TIG/PostNL/Model/Resource/Order/Shipment/Grid/Collection.php +9 -1
- app/code/community/TIG/PostNL/Model/Resource/Setup.php +190 -78
- app/code/community/TIG/PostNL/Model/System/Config/Backend/Checkbox.php +2 -2
- app/code/community/TIG/PostNL/Model/System/Config/Source/Testlive.php +2 -2
- app/code/community/TIG/PostNL/Model/System/Config/Source/Yesno.php +2 -2
- app/code/community/TIG/PostNL/Test/Block/DeliveryOptions/Checkout/AddPhoneNumberTest.php +181 -0
- app/code/community/TIG/PostNL/Test/Block/DeliveryOptions/JsTest.php +119 -0
- app/code/community/TIG/PostNL/Test/Controllers/AddressValidationControllerTest.php +161 -0
- app/code/community/TIG/PostNL/Test/Controllers/DeliveryOptionsControllerTest.php +559 -0
- app/code/community/TIG/PostNL/Test/Framework/TIG/Test/Config.php +109 -0
- app/code/community/TIG/PostNL/Test/Framework/TIG/Test/Http/Response.php +59 -0
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* ___________ __ __
|
4 |
* \__ ___/____ _/ |_ _____ | |
|
@@ -33,7 +34,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Billing extends GoMage_Checkout_Block_Onepage_Billing
|
@@ -45,7 +46,9 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Billing extends Go
|
|
45 |
*/
|
46 |
protected function _renderFields($fields)
|
47 |
{
|
48 |
-
|
|
|
|
|
49 |
return parent::_renderFields($fields);
|
50 |
}
|
51 |
|
@@ -64,10 +67,10 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Billing extends Go
|
|
64 |
continue;
|
65 |
} elseif ($field_code == 'street') {
|
66 |
$html .= $this->getChild('postnl_billing_postcodecheck')
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
continue;
|
72 |
}
|
73 |
|
@@ -87,7 +90,19 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Billing extends Go
|
|
87 |
$template = $this->default_address_template;
|
88 |
}
|
89 |
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
$row_class[] = $field_code;
|
93 |
|
@@ -105,10 +120,10 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Billing extends Go
|
|
105 |
continue;
|
106 |
} elseif ($field_code == 'street') {
|
107 |
$html .= $this->getChild('postnl_billing_postcodecheck')
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
continue;
|
113 |
}
|
114 |
|
@@ -121,7 +136,6 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Billing extends Go
|
|
121 |
'input_id' => $this->prefix . '_' . $field_code,
|
122 |
);
|
123 |
|
124 |
-
|
125 |
if ($this->getConfigData('address_fields/' . $field_code) == 'req') {
|
126 |
$data['is_required'] = true;
|
127 |
}
|
@@ -130,7 +144,9 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Billing extends Go
|
|
130 |
$template = $this->default_address_template;
|
131 |
}
|
132 |
|
133 |
-
|
|
|
|
|
134 |
}
|
135 |
|
136 |
}
|
@@ -138,4 +154,4 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Billing extends Go
|
|
138 |
|
139 |
return $html;
|
140 |
}
|
141 |
-
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* ___________ __ __
|
5 |
* \__ ___/____ _/ |_ _____ | |
|
34 |
* versions in the future. If you wish to customize this module for your
|
35 |
* needs please contact servicedesk@tig.nl for more information.
|
36 |
*
|
37 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
38 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
39 |
*/
|
40 |
class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Billing extends GoMage_Checkout_Block_Onepage_Billing
|
46 |
*/
|
47 |
protected function _renderFields($fields)
|
48 |
{
|
49 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
50 |
+
$helper = Mage::helper('postnl/addressValidation');
|
51 |
+
if (!$helper->isPostcodeCheckEnabled(null, 'checkout')) {
|
52 |
return parent::_renderFields($fields);
|
53 |
}
|
54 |
|
67 |
continue;
|
68 |
} elseif ($field_code == 'street') {
|
69 |
$html .= $this->getChild('postnl_billing_postcodecheck')
|
70 |
+
->setAddressType('billing')
|
71 |
+
->setAddress($this->getAddress())
|
72 |
+
->setCountryHtmlSelect($this->getCountryHtmlSelect('billing'))
|
73 |
+
->toHtml();
|
74 |
continue;
|
75 |
}
|
76 |
|
90 |
$template = $this->default_address_template;
|
91 |
}
|
92 |
|
93 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
94 |
+
$_html .= '<div class="field field-'
|
95 |
+
. $field_code
|
96 |
+
. ' '
|
97 |
+
. ($i % 2 == 0 ? ' field-first ' : ' field-last ')
|
98 |
+
. '">'
|
99 |
+
. $this->getLayout(
|
100 |
+
)->createBlock('gomage_checkout/onepage_' . $this->prefix)
|
101 |
+
->setTemplate($template)
|
102 |
+
->addData(
|
103 |
+
$data
|
104 |
+
)->toHtml()
|
105 |
+
. '</div>';
|
106 |
|
107 |
$row_class[] = $field_code;
|
108 |
|
120 |
continue;
|
121 |
} elseif ($field_code == 'street') {
|
122 |
$html .= $this->getChild('postnl_billing_postcodecheck')
|
123 |
+
->setAddressType('billing')
|
124 |
+
->setAddress($this->getAddress())
|
125 |
+
->setCountryHtmlSelect($this->getCountryHtmlSelect('billing'))
|
126 |
+
->toHtml();
|
127 |
continue;
|
128 |
}
|
129 |
|
136 |
'input_id' => $this->prefix . '_' . $field_code,
|
137 |
);
|
138 |
|
|
|
139 |
if ($this->getConfigData('address_fields/' . $field_code) == 'req') {
|
140 |
$data['is_required'] = true;
|
141 |
}
|
144 |
$template = $this->default_address_template;
|
145 |
}
|
146 |
|
147 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
148 |
+
$html .= '<li>' . $this->getLayout()->createBlock('gomage_checkout/onepage_' . $this->prefix)
|
149 |
+
->setTemplate($template)->addData($data)->toHtml() . '</li>';
|
150 |
}
|
151 |
|
152 |
}
|
154 |
|
155 |
return $html;
|
156 |
}
|
157 |
+
}
|
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* ___________ __ __
|
4 |
* \__ ___/____ _/ |_ _____ | |
|
@@ -33,14 +34,16 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Shipping extends GoMage_Checkout_Block_Onepage_Shipping
|
40 |
{
|
41 |
protected function _renderFields($fields)
|
42 |
{
|
43 |
-
|
|
|
|
|
44 |
return parent::_renderFields($fields);
|
45 |
}
|
46 |
|
@@ -59,10 +62,10 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Shipping extends G
|
|
59 |
continue;
|
60 |
} elseif ($field_code == 'street') {
|
61 |
$html .= $this->getChild('postnl_shipping_postcodecheck')
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
continue;
|
67 |
}
|
68 |
|
@@ -82,7 +85,19 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Shipping extends G
|
|
82 |
$template = $this->default_address_template;
|
83 |
}
|
84 |
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
$row_class[] = $field_code;
|
88 |
|
@@ -100,10 +115,10 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Shipping extends G
|
|
100 |
continue;
|
101 |
} elseif ($field_code == 'street') {
|
102 |
$html .= $this->getChild('postnl_shipping_postcodecheck')
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
continue;
|
108 |
}
|
109 |
|
@@ -116,7 +131,6 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Shipping extends G
|
|
116 |
'input_id' => $this->prefix . '_' . $field_code,
|
117 |
);
|
118 |
|
119 |
-
|
120 |
if ($this->getConfigData('address_fields/' . $field_code) == 'req') {
|
121 |
$data['is_required'] = true;
|
122 |
}
|
@@ -125,7 +139,9 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Shipping extends G
|
|
125 |
$template = $this->default_address_template;
|
126 |
}
|
127 |
|
128 |
-
|
|
|
|
|
129 |
}
|
130 |
|
131 |
}
|
@@ -133,4 +149,4 @@ class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Shipping extends G
|
|
133 |
|
134 |
return $html;
|
135 |
}
|
136 |
-
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* ___________ __ __
|
5 |
* \__ ___/____ _/ |_ _____ | |
|
34 |
* versions in the future. If you wish to customize this module for your
|
35 |
* needs please contact servicedesk@tig.nl for more information.
|
36 |
*
|
37 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
38 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
39 |
*/
|
40 |
class TIG_PostNL_Block_AddressValidation_GoMage_LightCheckout_Shipping extends GoMage_Checkout_Block_Onepage_Shipping
|
41 |
{
|
42 |
protected function _renderFields($fields)
|
43 |
{
|
44 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
45 |
+
$helper = Mage::helper('postnl/addressValidation');
|
46 |
+
if (!$helper->isPostcodeCheckEnabled(null, 'checkout')) {
|
47 |
return parent::_renderFields($fields);
|
48 |
}
|
49 |
|
62 |
continue;
|
63 |
} elseif ($field_code == 'street') {
|
64 |
$html .= $this->getChild('postnl_shipping_postcodecheck')
|
65 |
+
->setAddressType('shipping')
|
66 |
+
->setAddress($this->getAddress())
|
67 |
+
->setCountryHtmlSelect($this->getCountryHtmlSelect('shipping'))
|
68 |
+
->toHtml();
|
69 |
continue;
|
70 |
}
|
71 |
|
85 |
$template = $this->default_address_template;
|
86 |
}
|
87 |
|
88 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
89 |
+
$_html .= '<div class="field field-'
|
90 |
+
. $field_code
|
91 |
+
. ' '
|
92 |
+
. ($i % 2 == 0 ? ' field-first ' : ' field-last ')
|
93 |
+
. '">'
|
94 |
+
. $this->getLayout()
|
95 |
+
->createBlock('gomage_checkout/onepage_' . $this->prefix)
|
96 |
+
->setTemplate($template)
|
97 |
+
->addData(
|
98 |
+
$data
|
99 |
+
)->toHtml()
|
100 |
+
. '</div>';
|
101 |
|
102 |
$row_class[] = $field_code;
|
103 |
|
115 |
continue;
|
116 |
} elseif ($field_code == 'street') {
|
117 |
$html .= $this->getChild('postnl_shipping_postcodecheck')
|
118 |
+
->setAddressType('shipping')
|
119 |
+
->setAddress($this->getAddress())
|
120 |
+
->setCountryHtmlSelect($this->getCountryHtmlSelect('shipping'))
|
121 |
+
->toHtml();
|
122 |
continue;
|
123 |
}
|
124 |
|
131 |
'input_id' => $this->prefix . '_' . $field_code,
|
132 |
);
|
133 |
|
|
|
134 |
if ($this->getConfigData('address_fields/' . $field_code) == 'req') {
|
135 |
$data['is_required'] = true;
|
136 |
}
|
139 |
$template = $this->default_address_template;
|
140 |
}
|
141 |
|
142 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
143 |
+
$html .= '<li>' . $this->getLayout()->createBlock('gomage_checkout/onepage_' . $this->prefix)
|
144 |
+
->setTemplate($template)->addData($data)->toHtml() . '</li>';
|
145 |
}
|
146 |
|
147 |
}
|
149 |
|
150 |
return $html;
|
151 |
}
|
152 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Carrier_Postnl_Matrixrate_Grid
|
@@ -56,6 +56,7 @@ class TIG_PostNL_Block_Adminhtml_Carrier_Postnl_Matrixrate_Grid
|
|
56 |
*/
|
57 |
protected function _prepareCollection()
|
58 |
{
|
|
|
59 |
$collection = Mage::getResourceModel('postnl_carrier/matrixrate_collection');
|
60 |
$collection->setWebsiteFilter($this->getWebsiteId());
|
61 |
|
@@ -144,4 +145,4 @@ class TIG_PostNL_Block_Adminhtml_Carrier_Postnl_Matrixrate_Grid
|
|
144 |
|
145 |
return Mage_Adminhtml_Block_Widget_Grid::_prepareColumns();
|
146 |
}
|
147 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Carrier_Postnl_Matrixrate_Grid
|
56 |
*/
|
57 |
protected function _prepareCollection()
|
58 |
{
|
59 |
+
/** @var TIG_PostNL_Model_Carrier_Resource_Matrixrate_Collection $collection */
|
60 |
$collection = Mage::getResourceModel('postnl_carrier/matrixrate_collection');
|
61 |
$collection->setWebsiteFilter($this->getWebsiteId());
|
62 |
|
145 |
|
146 |
return Mage_Adminhtml_Block_Widget_Grid::_prepareColumns();
|
147 |
}
|
148 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Carrier_Postnl_Tablerate_Grid
|
@@ -46,6 +46,7 @@ class TIG_PostNL_Block_Adminhtml_Carrier_Postnl_Tablerate_Grid
|
|
46 |
*/
|
47 |
protected function _prepareCollection()
|
48 |
{
|
|
|
49 |
$collection = Mage::getResourceModel('postnl_carrier/tablerate_collection');
|
50 |
$collection->setConditionFilter($this->getConditionName())
|
51 |
->setWebsiteFilter($this->getWebsiteId());
|
@@ -54,4 +55,4 @@ class TIG_PostNL_Block_Adminhtml_Carrier_Postnl_Tablerate_Grid
|
|
54 |
|
55 |
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
|
56 |
}
|
57 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Carrier_Postnl_Tablerate_Grid
|
46 |
*/
|
47 |
protected function _prepareCollection()
|
48 |
{
|
49 |
+
/** @var TIG_PostNL_Model_Carrier_Resource_Tablerate_Collection $collection */
|
50 |
$collection = Mage::getResourceModel('postnl_carrier/tablerate_collection');
|
51 |
$collection->setConditionFilter($this->getConditionName())
|
52 |
->setWebsiteFilter($this->getWebsiteId());
|
55 |
|
56 |
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
|
57 |
}
|
58 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_CronNotification extends TIG_PostNL_Block_Adminhtml_Template
|
@@ -59,6 +59,7 @@ class TIG_PostNL_Block_Adminhtml_CronNotification extends TIG_PostNL_Block_Admin
|
|
59 |
/**
|
60 |
* Get the last execution time from the cron_schedule table
|
61 |
*/
|
|
|
62 |
$coreResource = Mage::getSingleton('core/resource');
|
63 |
$readConnection = $coreResource->getConnection('core_read');
|
64 |
|
@@ -112,7 +113,9 @@ class TIG_PostNL_Block_Adminhtml_CronNotification extends TIG_PostNL_Block_Admin
|
|
112 |
*/
|
113 |
$utcTimeZone = new DateTimeZone('UTC');
|
114 |
$currentTime = new DateTime('now', $utcTimeZone);
|
115 |
-
$
|
|
|
|
|
116 |
|
117 |
$oneHourAgo = $currentTime->sub(new DateInterval('PT1H'));
|
118 |
$lastExecutionTime = new DateTime($lastExecutionTime, $utcTimeZone);
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_CronNotification extends TIG_PostNL_Block_Adminhtml_Template
|
59 |
/**
|
60 |
* Get the last execution time from the cron_schedule table
|
61 |
*/
|
62 |
+
/** @var Mage_Core_Model_Resource $coreResource */
|
63 |
$coreResource = Mage::getSingleton('core/resource');
|
64 |
$readConnection = $coreResource->getConnection('core_read');
|
65 |
|
113 |
*/
|
114 |
$utcTimeZone = new DateTimeZone('UTC');
|
115 |
$currentTime = new DateTime('now', $utcTimeZone);
|
116 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
117 |
+
$dateModel = Mage::getModel('core/date');
|
118 |
+
$currentTime->setTimestamp($dateModel->gmtTimestamp());
|
119 |
|
120 |
$oneHourAgo = $currentTime->sub(new DateInterval('PT1H'));
|
121 |
$lastExecutionTime = new DateTime($lastExecutionTime, $utcTimeZone);
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_IntegrityNotification extends TIG_PostNL_Block_Adminhtml_Template
|
@@ -55,6 +55,7 @@ class TIG_PostNL_Block_Adminhtml_IntegrityNotification extends TIG_PostNL_Block_
|
|
55 |
{
|
56 |
$collection = $this->_collection;
|
57 |
if (!$collection) {
|
|
|
58 |
$collection = Mage::getResourceModel('postnl_core/integrity_collection');
|
59 |
$this->setCollection($collection);
|
60 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_IntegrityNotification extends TIG_PostNL_Block_Adminhtml_Template
|
55 |
{
|
56 |
$collection = $this->_collection;
|
57 |
if (!$collection) {
|
58 |
+
/** @var TIG_PostNL_Model_Core_Resource_Integrity_Collection $collection */
|
59 |
$collection = Mage::getResourceModel('postnl_core/integrity_collection');
|
60 |
$this->setCollection($collection);
|
61 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasMaxLogSize()
|
@@ -60,6 +60,7 @@ class TIG_PostNL_Block_Adminhtml_LogNotification extends TIG_PostNL_Block_Adminh
|
|
60 |
/**
|
61 |
* @var $logModelClass TIG_PostNL_Model_Adminhtml_Support_Logs
|
62 |
*/
|
|
|
63 |
$logModelClass = Mage::getConfig()->getModelClassName('postnl_adminhtml/support_logs');
|
64 |
$maxSize = $logModelClass::LOG_MAX_TOTAL_SIZE;
|
65 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasMaxLogSize()
|
60 |
/**
|
61 |
* @var $logModelClass TIG_PostNL_Model_Adminhtml_Support_Logs
|
62 |
*/
|
63 |
+
/** @noinspection PhpParamsInspection */
|
64 |
$logModelClass = Mage::getConfig()->getModelClassName('postnl_adminhtml/support_logs');
|
65 |
$maxSize = $logModelClass::LOG_MAX_TOTAL_SIZE;
|
66 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Items_Column_Qty extends Mage_Adminhtml_Block_Sales_Items_Column_Qty
|
@@ -100,10 +100,12 @@ class TIG_PostNL_Block_Adminhtml_Sales_Items_Column_Qty extends Mage_Adminhtml_B
|
|
100 |
*/
|
101 |
protected function _toHtml()
|
102 |
{
|
103 |
-
|
|
|
|
|
104 |
$this->setTemplate(self::DEFAULT_TEMPLATE);
|
105 |
}
|
106 |
|
107 |
return parent::_toHtml();
|
108 |
}
|
109 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Items_Column_Qty extends Mage_Adminhtml_Block_Sales_Items_Column_Qty
|
100 |
*/
|
101 |
protected function _toHtml()
|
102 |
{
|
103 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
104 |
+
$helper = Mage::helper('postnl');
|
105 |
+
if (!$helper->isEnabled($this->getItem()->getStoreId())) {
|
106 |
$this->setTemplate(self::DEFAULT_TEMPLATE);
|
107 |
}
|
108 |
|
109 |
return parent::_toHtml();
|
110 |
}
|
111 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Varien_Object getTotal()
|
@@ -64,7 +64,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Create_Totals_CodFee extends Mage_A
|
|
64 |
*/
|
65 |
public function getDisplayMode()
|
66 |
{
|
67 |
-
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE
|
68 |
|
69 |
return $displayMode;
|
70 |
}
|
@@ -78,7 +78,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Create_Totals_CodFee extends Mage_A
|
|
78 |
*/
|
79 |
public function getTaxLabel($inclTax = false)
|
80 |
{
|
81 |
-
|
|
|
|
|
82 |
|
83 |
return $taxLabel;
|
84 |
}
|
@@ -92,14 +94,17 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Create_Totals_CodFee extends Mage_A
|
|
92 |
*/
|
93 |
public function getValue($inclTax = false)
|
94 |
{
|
|
|
95 |
$address = $this->getTotal()->getAddress();
|
96 |
|
|
|
97 |
$exclTax = $address->getPostnlCodFee();
|
98 |
if (!$inclTax) {
|
99 |
return $exclTax;
|
100 |
}
|
101 |
|
|
|
102 |
$inclTax = $exclTax + $address->getPostnlCodFeeTax();
|
103 |
return $inclTax;
|
104 |
}
|
105 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Varien_Object getTotal()
|
64 |
*/
|
65 |
public function getDisplayMode()
|
66 |
{
|
67 |
+
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE);
|
68 |
|
69 |
return $displayMode;
|
70 |
}
|
78 |
*/
|
79 |
public function getTaxLabel($inclTax = false)
|
80 |
{
|
81 |
+
/** @var Mage_Tax_Helper_Data $taxHelper */
|
82 |
+
$taxHelper = Mage::helper('tax');
|
83 |
+
$taxLabel = $taxHelper->getIncExcTaxLabel($inclTax);
|
84 |
|
85 |
return $taxLabel;
|
86 |
}
|
94 |
*/
|
95 |
public function getValue($inclTax = false)
|
96 |
{
|
97 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
98 |
$address = $this->getTotal()->getAddress();
|
99 |
|
100 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
101 |
$exclTax = $address->getPostnlCodFee();
|
102 |
if (!$inclTax) {
|
103 |
return $exclTax;
|
104 |
}
|
105 |
|
106 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
107 |
$inclTax = $exclTax + $address->getPostnlCodFeeTax();
|
108 |
return $inclTax;
|
109 |
}
|
110 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Create_CodFee extends Mage_Adminhtml_Block_Template
|
@@ -131,8 +131,10 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Create_CodFee extends Ma
|
|
131 |
{
|
132 |
$source = $this->getSource();
|
133 |
|
|
|
134 |
$feeAmount = $source->getBasePostnlCodFee();
|
135 |
if ($this->getFeeIsInclTax()) {
|
|
|
136 |
$feeAmount += $source->getBasePostnlCodFeeTax();
|
137 |
}
|
138 |
|
@@ -149,9 +151,13 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Create_CodFee extends Ma
|
|
149 |
{
|
150 |
$source = $this->getSource();
|
151 |
|
152 |
-
|
|
|
|
|
153 |
|
154 |
-
|
|
|
|
|
155 |
|
156 |
return $label;
|
157 |
}
|
@@ -163,10 +169,11 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Create_CodFee extends Ma
|
|
163 |
*/
|
164 |
protected function _toHtml()
|
165 |
{
|
|
|
166 |
if (!$this->_source->getPostnlCodFee()) {
|
167 |
return '';
|
168 |
}
|
169 |
|
170 |
return parent::_toHtml();
|
171 |
}
|
172 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Create_CodFee extends Mage_Adminhtml_Block_Template
|
131 |
{
|
132 |
$source = $this->getSource();
|
133 |
|
134 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
135 |
$feeAmount = $source->getBasePostnlCodFee();
|
136 |
if ($this->getFeeIsInclTax()) {
|
137 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
138 |
$feeAmount += $source->getBasePostnlCodFeeTax();
|
139 |
}
|
140 |
|
151 |
{
|
152 |
$source = $this->getSource();
|
153 |
|
154 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
155 |
+
$helper = Mage::helper('postnl/payment');
|
156 |
+
$label = $helper->getPostnlCodFeeLabel($source->getStoreId());
|
157 |
|
158 |
+
/** @var Mage_Tax_Helper_Data $taxHelper */
|
159 |
+
$taxHelper = Mage::helper('tax');
|
160 |
+
$label .= ' ' . $taxHelper->getIncExcTaxLabel($this->getFeeIsInclTax());
|
161 |
|
162 |
return $label;
|
163 |
}
|
169 |
*/
|
170 |
protected function _toHtml()
|
171 |
{
|
172 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
173 |
if (!$this->_source->getPostnlCodFee()) {
|
174 |
return '';
|
175 |
}
|
176 |
|
177 |
return parent::_toHtml();
|
178 |
}
|
179 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Totals_CodFee
|
@@ -65,7 +65,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Totals_CodFee
|
|
65 |
$parent = $this->getParentBlock();
|
66 |
$creditmemo = $this->getCreditmemo();
|
67 |
|
|
|
68 |
$fee = $creditmemo->getPostnlCodFee();
|
|
|
69 |
$baseFee = $creditmemo->getBasePostnlCodFee();
|
70 |
|
71 |
if ($fee < 0.01 || $baseFee < 0.01) {
|
@@ -73,7 +75,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Totals_CodFee
|
|
73 |
}
|
74 |
|
75 |
$displayMode = $this->getDisplayMode();
|
76 |
-
|
|
|
|
|
77 |
|
78 |
if ($displayMode === self::DISPLAY_MODE_EXCL
|
79 |
|| $displayMode === self::DISPLAY_MODE_BOTH
|
@@ -85,6 +89,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Totals_CodFee
|
|
85 |
}
|
86 |
|
87 |
$total = new Varien_Object();
|
|
|
88 |
$total->setLabel($label)
|
89 |
->setValue($fee)
|
90 |
->setBaseValue($baseFee)
|
@@ -103,6 +108,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Totals_CodFee
|
|
103 |
}
|
104 |
|
105 |
$totalInclTax = new Varien_Object();
|
|
|
106 |
$totalInclTax->setLabel($label)
|
107 |
->setValue($fee + $creditmemo->getPostnlCodFeeTax())
|
108 |
->setBaseValue($baseFee + $creditmemo->getBasePostnlCodFeeTax())
|
@@ -121,7 +127,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Totals_CodFee
|
|
121 |
*/
|
122 |
public function getDisplayMode()
|
123 |
{
|
124 |
-
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE
|
125 |
|
126 |
return $displayMode;
|
127 |
}
|
@@ -135,8 +141,10 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Totals_CodFee
|
|
135 |
*/
|
136 |
public function getTaxLabel($inclTax = false)
|
137 |
{
|
138 |
-
|
|
|
|
|
139 |
|
140 |
return $taxLabel;
|
141 |
}
|
142 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Creditmemo_Totals_CodFee
|
65 |
$parent = $this->getParentBlock();
|
66 |
$creditmemo = $this->getCreditmemo();
|
67 |
|
68 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
69 |
$fee = $creditmemo->getPostnlCodFee();
|
70 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
71 |
$baseFee = $creditmemo->getBasePostnlCodFee();
|
72 |
|
73 |
if ($fee < 0.01 || $baseFee < 0.01) {
|
75 |
}
|
76 |
|
77 |
$displayMode = $this->getDisplayMode();
|
78 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
79 |
+
$helper = Mage::helper('postnl/payment');
|
80 |
+
$baseLabel = $helper->getPostnlCodFeeLabel($creditmemo->getStoreId());
|
81 |
|
82 |
if ($displayMode === self::DISPLAY_MODE_EXCL
|
83 |
|| $displayMode === self::DISPLAY_MODE_BOTH
|
89 |
}
|
90 |
|
91 |
$total = new Varien_Object();
|
92 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
93 |
$total->setLabel($label)
|
94 |
->setValue($fee)
|
95 |
->setBaseValue($baseFee)
|
108 |
}
|
109 |
|
110 |
$totalInclTax = new Varien_Object();
|
111 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
112 |
$totalInclTax->setLabel($label)
|
113 |
->setValue($fee + $creditmemo->getPostnlCodFeeTax())
|
114 |
->setBaseValue($baseFee + $creditmemo->getBasePostnlCodFeeTax())
|
127 |
*/
|
128 |
public function getDisplayMode()
|
129 |
{
|
130 |
+
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE);
|
131 |
|
132 |
return $displayMode;
|
133 |
}
|
141 |
*/
|
142 |
public function getTaxLabel($inclTax = false)
|
143 |
{
|
144 |
+
/** @var Mage_Tax_Helper_Data $taxHelper */
|
145 |
+
$taxHelper = Mage::helper('tax');
|
146 |
+
$taxLabel = $taxHelper->getIncExcText($inclTax);
|
147 |
|
148 |
return $taxLabel;
|
149 |
}
|
150 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Invoice_Totals_CodFee
|
@@ -76,7 +76,10 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Invoice_Totals_CodFee
|
|
76 |
}
|
77 |
|
78 |
$displayMode = $this->getDisplayMode();
|
79 |
-
|
|
|
|
|
|
|
80 |
|
81 |
if ($displayMode === self::DISPLAY_MODE_EXCL || $displayMode === self::DISPLAY_MODE_BOTH) {
|
82 |
$label = $baseLabel;
|
@@ -85,6 +88,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Invoice_Totals_CodFee
|
|
85 |
}
|
86 |
|
87 |
$total = new Varien_Object();
|
|
|
88 |
$total->setLabel($label)
|
89 |
->setValue($fee)
|
90 |
->setBaseValue($baseFee)
|
@@ -100,6 +104,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Invoice_Totals_CodFee
|
|
100 |
}
|
101 |
|
102 |
$totalInclTax = new Varien_Object();
|
|
|
103 |
$totalInclTax->setLabel($label)
|
104 |
->setValue($fee + $invoice->getPostnlCodFeeTax())
|
105 |
->setBaseValue($baseFee + $invoice->getBasePostnlCodFeeTax())
|
@@ -118,7 +123,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Invoice_Totals_CodFee
|
|
118 |
*/
|
119 |
public function getDisplayMode()
|
120 |
{
|
121 |
-
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE
|
122 |
|
123 |
return $displayMode;
|
124 |
}
|
@@ -132,8 +137,10 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Invoice_Totals_CodFee
|
|
132 |
*/
|
133 |
public function getTaxLabel($inclTax = false)
|
134 |
{
|
135 |
-
|
|
|
|
|
136 |
|
137 |
return $taxLabel;
|
138 |
}
|
139 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Invoice_Totals_CodFee
|
76 |
}
|
77 |
|
78 |
$displayMode = $this->getDisplayMode();
|
79 |
+
|
80 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
81 |
+
$helper = Mage::helper('postnl/payment');
|
82 |
+
$baseLabel = $helper->getPostnlCodFeeLabel($invoice->getStoreId());
|
83 |
|
84 |
if ($displayMode === self::DISPLAY_MODE_EXCL || $displayMode === self::DISPLAY_MODE_BOTH) {
|
85 |
$label = $baseLabel;
|
88 |
}
|
89 |
|
90 |
$total = new Varien_Object();
|
91 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
92 |
$total->setLabel($label)
|
93 |
->setValue($fee)
|
94 |
->setBaseValue($baseFee)
|
104 |
}
|
105 |
|
106 |
$totalInclTax = new Varien_Object();
|
107 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
108 |
$totalInclTax->setLabel($label)
|
109 |
->setValue($fee + $invoice->getPostnlCodFeeTax())
|
110 |
->setBaseValue($baseFee + $invoice->getBasePostnlCodFeeTax())
|
123 |
*/
|
124 |
public function getDisplayMode()
|
125 |
{
|
126 |
+
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE);
|
127 |
|
128 |
return $displayMode;
|
129 |
}
|
137 |
*/
|
138 |
public function getTaxLabel($inclTax = false)
|
139 |
{
|
140 |
+
/** @var Mage_Tax_Helper_Data $helper */
|
141 |
+
$helper = Mage::helper('tax');
|
142 |
+
$taxLabel = $helper->getIncExcText($inclTax);
|
143 |
|
144 |
return $taxLabel;
|
145 |
}
|
146 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasExtraCoverProductOptions()
|
@@ -59,8 +59,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_ProductOptions extends TIG_PostNL_B
|
|
59 |
return $this->_getData('extra_cover_product_options');
|
60 |
}
|
61 |
|
62 |
-
$
|
63 |
-
|
|
|
64 |
|
65 |
$this->setExtraCoverProductOptions($productOptions);
|
66 |
return $productOptions;
|
@@ -77,14 +78,15 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_ProductOptions extends TIG_PostNL_B
|
|
77 |
return $this->_getData('globalpack_product_option');
|
78 |
}
|
79 |
|
80 |
-
$
|
81 |
-
|
|
|
82 |
|
83 |
if (empty($globalPackProductOption)) {
|
84 |
return '';
|
85 |
}
|
86 |
|
87 |
-
$optionValue = $globalPackProductOption[
|
88 |
$this->setGlobalpackProductOption($optionValue);
|
89 |
return $optionValue;
|
90 |
}
|
@@ -96,7 +98,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_ProductOptions extends TIG_PostNL_B
|
|
96 |
*/
|
97 |
public function getShipmentTypes()
|
98 |
{
|
99 |
-
|
|
|
|
|
100 |
|
101 |
return $shipmentTypes;
|
102 |
}
|
@@ -110,7 +114,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_ProductOptions extends TIG_PostNL_B
|
|
110 |
*/
|
111 |
protected function _toHtml()
|
112 |
{
|
113 |
-
|
|
|
|
|
114 |
return '';
|
115 |
}
|
116 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasExtraCoverProductOptions()
|
59 |
return $this->_getData('extra_cover_product_options');
|
60 |
}
|
61 |
|
62 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $sourceModel */
|
63 |
+
$sourceModel = Mage::getModel('postnl_core/system_config_source_allProductOptions');
|
64 |
+
$productOptions = $sourceModel->getExtraCoverOptions(true);
|
65 |
|
66 |
$this->setExtraCoverProductOptions($productOptions);
|
67 |
return $productOptions;
|
78 |
return $this->_getData('globalpack_product_option');
|
79 |
}
|
80 |
|
81 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_GlobalProductOptions $sourceModel */
|
82 |
+
$sourceModel = Mage::getModel('postnl_core/system_config_source_globalProductOptions');
|
83 |
+
$globalPackProductOption = $sourceModel->getAvailableOptions();
|
84 |
|
85 |
if (empty($globalPackProductOption)) {
|
86 |
return '';
|
87 |
}
|
88 |
|
89 |
+
$optionValue = current($globalPackProductOption)['value'];
|
90 |
$this->setGlobalpackProductOption($optionValue);
|
91 |
return $optionValue;
|
92 |
}
|
98 |
*/
|
99 |
public function getShipmentTypes()
|
100 |
{
|
101 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
102 |
+
$helper = Mage::helper('postnl/cif');
|
103 |
+
$shipmentTypes = $helper->getShipmentTypes();
|
104 |
|
105 |
return $shipmentTypes;
|
106 |
}
|
114 |
*/
|
115 |
protected function _toHtml()
|
116 |
{
|
117 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
118 |
+
$helper = Mage::helper('postnl');
|
119 |
+
if (!$helper->isEnabled()) {
|
120 |
return '';
|
121 |
}
|
122 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasShipment()
|
@@ -92,6 +92,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
92 |
|
93 |
$shipment = $this->getShipment();
|
94 |
|
|
|
95 |
$postnlOrder = Mage::getModel('postnl_core/order')->load($shipment->getOrderId(), 'order_id');
|
96 |
|
97 |
$this->setPostnlOrder($postnlOrder);
|
@@ -111,7 +112,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
111 |
|
112 |
$shipment = $this->getShipment();
|
113 |
|
114 |
-
|
|
|
|
|
115 |
|
116 |
$this->setProductOptions($productOptions);
|
117 |
return $productOptions;
|
@@ -128,7 +131,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
128 |
return $this->getData('buspakje_product_options');
|
129 |
}
|
130 |
|
131 |
-
|
|
|
|
|
132 |
|
133 |
$this->setBuspakjeProductOptions($productOptions);
|
134 |
return $productOptions;
|
@@ -148,9 +153,13 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
148 |
$shipment = $this->getShipment();
|
149 |
|
150 |
try {
|
151 |
-
|
|
|
|
|
152 |
} catch (Exception $e) {
|
153 |
-
|
|
|
|
|
154 |
|
155 |
$productOption = '';
|
156 |
}
|
@@ -170,14 +179,17 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
170 |
return $this->_getData('default_buspakje_option');
|
171 |
}
|
172 |
|
173 |
-
$postnlShipment
|
174 |
-
|
175 |
-
|
|
|
176 |
|
177 |
try {
|
178 |
$productOption = $postnlShipment->getDefaultProductCode();
|
179 |
} catch (Exception $e) {
|
180 |
-
|
|
|
|
|
181 |
|
182 |
$productOption = '';
|
183 |
}
|
@@ -193,7 +205,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
193 |
*/
|
194 |
public function getShipmentTypes()
|
195 |
{
|
196 |
-
|
|
|
|
|
197 |
|
198 |
return $shipmentTypes;
|
199 |
}
|
@@ -222,7 +236,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
222 |
{
|
223 |
$shipment = $this->getShipment();
|
224 |
|
225 |
-
|
|
|
|
|
226 |
if ($parcelCount < 1) {
|
227 |
$parcelCount = 1;
|
228 |
}
|
@@ -248,7 +264,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
248 |
$orderItems[] = $item->getOrderItem()->setQtyOrdered($item->getQty());
|
249 |
}
|
250 |
|
251 |
-
|
|
|
|
|
252 |
|
253 |
if (!$fits) {
|
254 |
return $fits;
|
@@ -295,6 +313,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
295 |
*/
|
296 |
protected function _toHtml()
|
297 |
{
|
|
|
298 |
$helper = Mage::helper('postnl');
|
299 |
if (!$helper->isEnabled()) {
|
300 |
return '';
|
@@ -302,11 +321,15 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
302 |
|
303 |
$shipment = $this->getShipment();
|
304 |
|
305 |
-
|
|
|
|
|
306 |
return '';
|
307 |
}
|
308 |
|
309 |
-
|
|
|
|
|
310 |
return '';
|
311 |
}
|
312 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasShipment()
|
92 |
|
93 |
$shipment = $this->getShipment();
|
94 |
|
95 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
96 |
$postnlOrder = Mage::getModel('postnl_core/order')->load($shipment->getOrderId(), 'order_id');
|
97 |
|
98 |
$this->setPostnlOrder($postnlOrder);
|
112 |
|
113 |
$shipment = $this->getShipment();
|
114 |
|
115 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
116 |
+
$helper = Mage::helper('postnl/cif');
|
117 |
+
$productOptions = $helper->getProductOptionsForShipment($shipment);
|
118 |
|
119 |
$this->setProductOptions($productOptions);
|
120 |
return $productOptions;
|
131 |
return $this->getData('buspakje_product_options');
|
132 |
}
|
133 |
|
134 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
135 |
+
$helper = Mage::helper('postnl/cif');
|
136 |
+
$productOptions = $helper->getBuspakjeProductCodes(false);
|
137 |
|
138 |
$this->setBuspakjeProductOptions($productOptions);
|
139 |
return $productOptions;
|
153 |
$shipment = $this->getShipment();
|
154 |
|
155 |
try {
|
156 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
157 |
+
$helper = Mage::helper('postnl/cif');
|
158 |
+
$productOption = $helper->getDefaultProductOptionForShipment($shipment);
|
159 |
} catch (Exception $e) {
|
160 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
161 |
+
$helper = Mage::helper('postnl');
|
162 |
+
$helper->logException($e);
|
163 |
|
164 |
$productOption = '';
|
165 |
}
|
179 |
return $this->_getData('default_buspakje_option');
|
180 |
}
|
181 |
|
182 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
183 |
+
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
184 |
+
$postnlShipment->setShipmentType('buspakje')
|
185 |
+
->setStoreId($this->getShipment()->getStoreId());
|
186 |
|
187 |
try {
|
188 |
$productOption = $postnlShipment->getDefaultProductCode();
|
189 |
} catch (Exception $e) {
|
190 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
191 |
+
$helper = Mage::helper('postnl');
|
192 |
+
$helper->logException($e);
|
193 |
|
194 |
$productOption = '';
|
195 |
}
|
205 |
*/
|
206 |
public function getShipmentTypes()
|
207 |
{
|
208 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
209 |
+
$helper = Mage::helper('postnl/cif');
|
210 |
+
$shipmentTypes = $helper->getShipmentTypes();
|
211 |
|
212 |
return $shipmentTypes;
|
213 |
}
|
236 |
{
|
237 |
$shipment = $this->getShipment();
|
238 |
|
239 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
240 |
+
$helper = Mage::helper('postnl/cif');
|
241 |
+
$parcelCount = (int) $helper->getParcelCount($shipment);
|
242 |
if ($parcelCount < 1) {
|
243 |
$parcelCount = 1;
|
244 |
}
|
264 |
$orderItems[] = $item->getOrderItem()->setQtyOrdered($item->getQty());
|
265 |
}
|
266 |
|
267 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
268 |
+
$helper = Mage::helper('postnl');
|
269 |
+
$fits = $helper->fitsAsBuspakje($orderItems, true);
|
270 |
|
271 |
if (!$fits) {
|
272 |
return $fits;
|
313 |
*/
|
314 |
protected function _toHtml()
|
315 |
{
|
316 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
317 |
$helper = Mage::helper('postnl');
|
318 |
if (!$helper->isEnabled()) {
|
319 |
return '';
|
321 |
|
322 |
$shipment = $this->getShipment();
|
323 |
|
324 |
+
/** @var TIG_PostNL_Helper_Carrier $carrierHelper */
|
325 |
+
$carrierHelper = Mage::helper('postnl/carrier');
|
326 |
+
if (!$carrierHelper->isPostnlShippingMethod($shipment->getOrder()->getShippingMethod())) {
|
327 |
return '';
|
328 |
}
|
329 |
|
330 |
+
/** @var TIG_PostNL_Helper_Cif $cifHelper */
|
331 |
+
$cifHelper = Mage::helper('postnl/cif');
|
332 |
+
if ($cifHelper->isGlobalShipment($shipment) && !$helper->isGlobalAllowed()) {
|
333 |
return '';
|
334 |
}
|
335 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlShipment()
|
@@ -110,7 +110,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_DeliveryOptions
|
|
110 |
|
111 |
$shipment = $this->getShipment();
|
112 |
|
113 |
-
$postnlShipment
|
|
|
|
|
114 |
|
115 |
$this->setPostnlShipment($postnlShipment);
|
116 |
return $postnlShipment;
|
@@ -146,7 +148,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_DeliveryOptions
|
|
146 |
|
147 |
$shipment = $this->getPostnlShipment();
|
148 |
|
149 |
-
|
|
|
|
|
150 |
|
151 |
$this->setProductOptions($productOptions);
|
152 |
return $productOptions;
|
@@ -181,6 +185,10 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_DeliveryOptions
|
|
181 |
break;
|
182 |
case $postnlShipment::SHIPMENT_TYPE_PG:
|
183 |
$shipmentType = $this->__('Post Office');
|
|
|
|
|
|
|
|
|
184 |
break;
|
185 |
case $postnlShipment::SHIPMENT_TYPE_PG_COD:
|
186 |
$shipmentType = $this->__('Post Office');
|
@@ -213,6 +221,15 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_DeliveryOptions
|
|
213 |
case $postnlShipment::SHIPMENT_TYPE_MONDAY:
|
214 |
$shipmentType = $this->__('Monday Delivery');
|
215 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
|
218 |
return $shipmentType;
|
@@ -250,7 +267,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_DeliveryOptions
|
|
250 |
/**
|
251 |
* Check if the current user is allowed to perform this action.
|
252 |
*/
|
253 |
-
|
|
|
|
|
254 |
return false;
|
255 |
}
|
256 |
|
@@ -343,7 +362,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_DeliveryOptions
|
|
343 |
/**
|
344 |
* Check if the current user is allowed to perform this action.
|
345 |
*/
|
346 |
-
|
|
|
|
|
347 |
return false;
|
348 |
}
|
349 |
|
@@ -397,6 +418,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_DeliveryOptions
|
|
397 |
'timezone_differ' => false,
|
398 |
);
|
399 |
|
|
|
400 |
$dateModel = Mage::getSingleton('core/date');
|
401 |
$utcTimeZone = new DateTimeZone('UTC');
|
402 |
|
@@ -420,4 +442,4 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_DeliveryOptions
|
|
420 |
|
421 |
return $info;
|
422 |
}
|
423 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlShipment()
|
110 |
|
111 |
$shipment = $this->getShipment();
|
112 |
|
113 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
114 |
+
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
115 |
+
$postnlShipment->loadByShipment($shipment);
|
116 |
|
117 |
$this->setPostnlShipment($postnlShipment);
|
118 |
return $postnlShipment;
|
148 |
|
149 |
$shipment = $this->getPostnlShipment();
|
150 |
|
151 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
152 |
+
$helper = Mage::helper('postnl/cif');
|
153 |
+
$productOptions = $helper->getProductOptionsForShipment($shipment);
|
154 |
|
155 |
$this->setProductOptions($productOptions);
|
156 |
return $productOptions;
|
185 |
break;
|
186 |
case $postnlShipment::SHIPMENT_TYPE_PG:
|
187 |
$shipmentType = $this->__('Post Office');
|
188 |
+
|
189 |
+
if ($postnlShipment->isBelgiumShipment()) {
|
190 |
+
$this->setSubType($this->__('Belgium'));
|
191 |
+
}
|
192 |
break;
|
193 |
case $postnlShipment::SHIPMENT_TYPE_PG_COD:
|
194 |
$shipmentType = $this->__('Post Office');
|
221 |
case $postnlShipment::SHIPMENT_TYPE_MONDAY:
|
222 |
$shipmentType = $this->__('Monday Delivery');
|
223 |
break;
|
224 |
+
case $postnlShipment::SHIPMENT_TYPE_SAMEDAY:
|
225 |
+
$shipmentType = $this->__('Same Day Delivery');
|
226 |
+
break;
|
227 |
+
case $postnlShipment::SHIPMENT_TYPE_FOOD:
|
228 |
+
$shipmentType = $this->__('Food Delivery');
|
229 |
+
break;
|
230 |
+
case $postnlShipment::SHIPMENT_TYPE_COOLED:
|
231 |
+
$shipmentType = $this->__('Cooled Food Delivery');
|
232 |
+
break;
|
233 |
}
|
234 |
|
235 |
return $shipmentType;
|
267 |
/**
|
268 |
* Check if the current user is allowed to perform this action.
|
269 |
*/
|
270 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
271 |
+
$helper = Mage::helper('postnl');
|
272 |
+
if (!$helper->checkIsPostnlActionAllowed(array('change_product_code'))) {
|
273 |
return false;
|
274 |
}
|
275 |
|
362 |
/**
|
363 |
* Check if the current user is allowed to perform this action.
|
364 |
*/
|
365 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
366 |
+
$helper = Mage::helper('postnl');
|
367 |
+
if (!$helper->checkIsPostnlActionAllowed(array('change_parcel_count'))) {
|
368 |
return false;
|
369 |
}
|
370 |
|
418 |
'timezone_differ' => false,
|
419 |
);
|
420 |
|
421 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
422 |
$dateModel = Mage::getSingleton('core/date');
|
423 |
$utcTimeZone = new DateTimeZone('UTC');
|
424 |
|
442 |
|
443 |
return $info;
|
444 |
}
|
445 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_ShippingStatus extends TIG_PostNL_Block_Adminhtml_Template
|
@@ -164,7 +164,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_ShippingStatus extend
|
|
164 |
*/
|
165 |
protected function _toHtml()
|
166 |
{
|
167 |
-
|
|
|
|
|
168 |
return '';
|
169 |
}
|
170 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_ShippingStatus extends TIG_PostNL_Block_Adminhtml_Template
|
164 |
*/
|
165 |
protected function _toHtml()
|
166 |
{
|
167 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
168 |
+
$helper = Mage::helper('postnl');
|
169 |
+
if (!$helper->isEnabled()) {
|
170 |
return '';
|
171 |
}
|
172 |
|
@@ -33,11 +33,12 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Core_Shipment getPostnlShipment()
|
40 |
* @method TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory setPostnlShipment(TIG_PostNL_Model_Core_Shipment $value)
|
|
|
41 |
*/
|
42 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory extends Mage_Adminhtml_Block_Widget_Grid
|
43 |
{
|
@@ -78,6 +79,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory ext
|
|
78 |
{
|
79 |
$postnlShipmentId = $this->getPostnlShipment()->getId();
|
80 |
|
|
|
81 |
$collection = Mage::getResourceModel('postnl_core/shipment_status_history_collection');
|
82 |
$collection->addFieldToFilter('parent_id', array('eq' => $postnlShipmentId));
|
83 |
|
@@ -96,7 +98,8 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory ext
|
|
96 |
*/
|
97 |
protected function _prepareColumns()
|
98 |
{
|
99 |
-
$helper
|
|
|
100 |
|
101 |
$this->addColumn(
|
102 |
'date',
|
@@ -124,7 +127,8 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory ext
|
|
124 |
);
|
125 |
|
126 |
$postnlShipment = $this->getPostnlShipment();
|
127 |
-
|
|
|
128 |
$this->addColumn(
|
129 |
'shipment_type',
|
130 |
array(
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Core_Shipment getPostnlShipment()
|
40 |
* @method TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory setPostnlShipment(TIG_PostNL_Model_Core_Shipment $value)
|
41 |
+
* @method TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory setUseAjax($value)
|
42 |
*/
|
43 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory extends Mage_Adminhtml_Block_Widget_Grid
|
44 |
{
|
79 |
{
|
80 |
$postnlShipmentId = $this->getPostnlShipment()->getId();
|
81 |
|
82 |
+
/** @var TIG_PostNL_Model_Core_Resource_Shipment_Status_History_Collection $collection */
|
83 |
$collection = Mage::getResourceModel('postnl_core/shipment_status_history_collection');
|
84 |
$collection->addFieldToFilter('parent_id', array('eq' => $postnlShipmentId));
|
85 |
|
98 |
*/
|
99 |
protected function _prepareColumns()
|
100 |
{
|
101 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
102 |
+
$helper = Mage::helper('postnl/cif');
|
103 |
|
104 |
$this->addColumn(
|
105 |
'date',
|
127 |
);
|
128 |
|
129 |
$postnlShipment = $this->getPostnlShipment();
|
130 |
+
|
131 |
+
if ($helper->isReturnsEnabled() && $postnlShipment->hasReturnLabelsPrinted()) {
|
132 |
$this->addColumn(
|
133 |
'shipment_type',
|
134 |
array(
|
@@ -33,8 +33,10 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
|
|
|
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
40 |
{
|
@@ -79,14 +81,19 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tabs extends Mage_Adm
|
|
79 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
80 |
*/
|
81 |
$shipment = Mage::registry('current_shipment');
|
82 |
-
|
|
|
|
|
|
|
83 |
|
84 |
/**
|
85 |
* Only show the status history tab if a postnl shipment entity was found for the current shipment and the
|
86 |
* current admin user is allowed to view the complete shipment status history. If the shipment uses a custom
|
87 |
* barcode we also can't show the status history, because custom barcodes can't be tracked.
|
88 |
*/
|
89 |
-
|
|
|
|
|
90 |
if ($historyAllowed && $postnlShipment->getId() && !$postnlShipment->hasCustomBarcode()) {
|
91 |
/**
|
92 |
* Add the status history tab. This is added by PostNL
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*
|
39 |
+
* @method TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tabs setTitle($title)
|
40 |
*/
|
41 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
42 |
{
|
81 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
82 |
*/
|
83 |
$shipment = Mage::registry('current_shipment');
|
84 |
+
|
85 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
86 |
+
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
87 |
+
$postnlShipment->loadByShipment($shipment);
|
88 |
|
89 |
/**
|
90 |
* Only show the status history tab if a postnl shipment entity was found for the current shipment and the
|
91 |
* current admin user is allowed to view the complete shipment status history. If the shipment uses a custom
|
92 |
* barcode we also can't show the status history, because custom barcodes can't be tracked.
|
93 |
*/
|
94 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
95 |
+
$helper = Mage::helper('postnl');
|
96 |
+
$historyAllowed = $helper->checkIsPostnlActionAllowed('view_complete_status');
|
97 |
if ($historyAllowed && $postnlShipment->getId() && !$postnlShipment->hasCustomBarcode()) {
|
98 |
/**
|
99 |
* Add the status history tab. This is added by PostNL
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Totals_CodFee extends Mage_Adminhtml_Block_Sales_Order_Totals
|
@@ -60,7 +60,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Totals_CodFee extends Mage_Adminhtm
|
|
60 |
$parent = $this->getParentBlock();
|
61 |
$order = $this->getOrder();
|
62 |
|
|
|
63 |
$fee = $order->getPostnlCodFee();
|
|
|
64 |
$baseFee = $order->getBasePostnlCodFee();
|
65 |
|
66 |
if ($fee < 0.01 || $baseFee < 0.01) {
|
@@ -68,7 +70,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Totals_CodFee extends Mage_Adminhtm
|
|
68 |
}
|
69 |
|
70 |
$displayMode = $this->getDisplayMode();
|
71 |
-
|
|
|
|
|
72 |
|
73 |
if ($displayMode === self::DISPLAY_MODE_EXCL || $displayMode === self::DISPLAY_MODE_BOTH) {
|
74 |
$label = $baseLabel;
|
@@ -77,11 +81,13 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Totals_CodFee extends Mage_Adminhtm
|
|
77 |
}
|
78 |
|
79 |
$total = new Varien_Object();
|
|
|
80 |
$total->setLabel($label)
|
81 |
->setValue($fee)
|
82 |
->setBaseValue($baseFee)
|
83 |
->setCode('postnl_cod_fee');
|
84 |
|
|
|
85 |
$parent->addTotalBefore($total, 'shipping');
|
86 |
}
|
87 |
|
@@ -92,11 +98,13 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Totals_CodFee extends Mage_Adminhtm
|
|
92 |
}
|
93 |
|
94 |
$totalInclTax = new Varien_Object();
|
|
|
95 |
$totalInclTax->setLabel($label)
|
96 |
->setValue($fee + $order->getPostnlCodFeeTax())
|
97 |
->setBaseValue($baseFee + $order->getBasePostnlCodFeeTax())
|
98 |
->setCode('postnl_cod_fee_incl_tax');
|
99 |
|
|
|
100 |
$parent->addTotalBefore($totalInclTax, 'shipping');
|
101 |
}
|
102 |
|
@@ -110,7 +118,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Totals_CodFee extends Mage_Adminhtm
|
|
110 |
*/
|
111 |
public function getDisplayMode()
|
112 |
{
|
113 |
-
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE
|
114 |
|
115 |
return $displayMode;
|
116 |
}
|
@@ -124,8 +132,10 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Totals_CodFee extends Mage_Adminhtm
|
|
124 |
*/
|
125 |
public function getTaxLabel($inclTax = false)
|
126 |
{
|
127 |
-
|
|
|
|
|
128 |
|
129 |
return $taxLabel;
|
130 |
}
|
131 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Order_Totals_CodFee extends Mage_Adminhtml_Block_Sales_Order_Totals
|
60 |
$parent = $this->getParentBlock();
|
61 |
$order = $this->getOrder();
|
62 |
|
63 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
64 |
$fee = $order->getPostnlCodFee();
|
65 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
66 |
$baseFee = $order->getBasePostnlCodFee();
|
67 |
|
68 |
if ($fee < 0.01 || $baseFee < 0.01) {
|
70 |
}
|
71 |
|
72 |
$displayMode = $this->getDisplayMode();
|
73 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
74 |
+
$helper = Mage::helper('postnl/payment');
|
75 |
+
$baseLabel = $helper->getPostnlCodFeeLabel($order->getStoreId());
|
76 |
|
77 |
if ($displayMode === self::DISPLAY_MODE_EXCL || $displayMode === self::DISPLAY_MODE_BOTH) {
|
78 |
$label = $baseLabel;
|
81 |
}
|
82 |
|
83 |
$total = new Varien_Object();
|
84 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
85 |
$total->setLabel($label)
|
86 |
->setValue($fee)
|
87 |
->setBaseValue($baseFee)
|
88 |
->setCode('postnl_cod_fee');
|
89 |
|
90 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
91 |
$parent->addTotalBefore($total, 'shipping');
|
92 |
}
|
93 |
|
98 |
}
|
99 |
|
100 |
$totalInclTax = new Varien_Object();
|
101 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
102 |
$totalInclTax->setLabel($label)
|
103 |
->setValue($fee + $order->getPostnlCodFeeTax())
|
104 |
->setBaseValue($baseFee + $order->getBasePostnlCodFeeTax())
|
105 |
->setCode('postnl_cod_fee_incl_tax');
|
106 |
|
107 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
108 |
$parent->addTotalBefore($totalInclTax, 'shipping');
|
109 |
}
|
110 |
|
118 |
*/
|
119 |
public function getDisplayMode()
|
120 |
{
|
121 |
+
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE);
|
122 |
|
123 |
return $displayMode;
|
124 |
}
|
132 |
*/
|
133 |
public function getTaxLabel($inclTax = false)
|
134 |
{
|
135 |
+
/** @var Mage_Tax_Helper_Data $helper */
|
136 |
+
$helper = Mage::helper('tax');
|
137 |
+
$taxLabel = $helper->getIncExcText($inclTax);
|
138 |
|
139 |
return $taxLabel;
|
140 |
}
|
141 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasOrder()
|
@@ -85,7 +85,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_View_DeliveryOptions extends TIG_Po
|
|
85 |
|
86 |
$order = $this->getOrder();
|
87 |
|
88 |
-
$postnlOrder
|
|
|
|
|
89 |
|
90 |
$this->setPostnlOrder($postnlOrder);
|
91 |
return $postnlOrder;
|
@@ -101,14 +103,17 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_View_DeliveryOptions extends TIG_Po
|
|
101 |
$order = $this->getOrder();
|
102 |
$postnlOrder = $this->getPostnlOrder();
|
103 |
|
|
|
|
|
|
|
104 |
$paymentMethod = $order->getPayment()->getMethod();
|
105 |
-
$codPaymentMethods =
|
106 |
if (in_array($paymentMethod, $codPaymentMethods)) {
|
107 |
$this->setIsCod(true);
|
108 |
}
|
109 |
|
110 |
$countryId = $order->getShippingAddress()->getCountryId();
|
111 |
-
$domesticCountry =
|
112 |
|
113 |
$shipmentType = false;
|
114 |
switch ($postnlOrder->getType()) {
|
@@ -121,6 +126,10 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_View_DeliveryOptions extends TIG_Po
|
|
121 |
break;
|
122 |
case 'PG':
|
123 |
$shipmentType = $this->__('Post Office');
|
|
|
|
|
|
|
|
|
124 |
break;
|
125 |
case 'Avond':
|
126 |
$this->setSubType($this->__('Evening Delivery'));
|
@@ -132,25 +141,43 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_View_DeliveryOptions extends TIG_Po
|
|
132 |
case 'Monday':
|
133 |
$shipmentType = $this->__('Monday Delivery');
|
134 |
break;
|
|
|
|
|
|
|
135 |
case 'Overdag':
|
136 |
if ($countryId != $domesticCountry) {
|
137 |
continue;
|
138 |
}
|
139 |
$shipmentType = $this->__('Domestic');
|
140 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
}
|
142 |
|
143 |
if ($shipmentType) {
|
144 |
return $shipmentType;
|
145 |
}
|
146 |
|
147 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
$shipmentType = $this->__('Domestic');
|
149 |
|
150 |
return $shipmentType;
|
151 |
}
|
152 |
|
153 |
-
$
|
|
|
|
|
154 |
if (in_array($countryId, $euCountries)) {
|
155 |
$shipmentType = $this->__('EPS');
|
156 |
|
@@ -248,6 +275,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_View_DeliveryOptions extends TIG_Po
|
|
248 |
'timezone_differ' => false,
|
249 |
);
|
250 |
|
|
|
251 |
$dateModel = Mage::getSingleton('core/date');
|
252 |
$utcTimeZone = new DateTimeZone('UTC');
|
253 |
|
@@ -271,4 +299,4 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_View_DeliveryOptions extends TIG_Po
|
|
271 |
|
272 |
return $info;
|
273 |
}
|
274 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasOrder()
|
85 |
|
86 |
$order = $this->getOrder();
|
87 |
|
88 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
89 |
+
$postnlOrder = Mage::getModel('postnl_core/order');
|
90 |
+
$postnlOrder->loadByOrder($order);
|
91 |
|
92 |
$this->setPostnlOrder($postnlOrder);
|
93 |
return $postnlOrder;
|
103 |
$order = $this->getOrder();
|
104 |
$postnlOrder = $this->getPostnlOrder();
|
105 |
|
106 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
107 |
+
$helper = Mage::helper('postnl/payment');
|
108 |
+
|
109 |
$paymentMethod = $order->getPayment()->getMethod();
|
110 |
+
$codPaymentMethods = $helper->getCodPaymentMethods();
|
111 |
if (in_array($paymentMethod, $codPaymentMethods)) {
|
112 |
$this->setIsCod(true);
|
113 |
}
|
114 |
|
115 |
$countryId = $order->getShippingAddress()->getCountryId();
|
116 |
+
$domesticCountry = $helper->getDomesticCountry();
|
117 |
|
118 |
$shipmentType = false;
|
119 |
switch ($postnlOrder->getType()) {
|
126 |
break;
|
127 |
case 'PG':
|
128 |
$shipmentType = $this->__('Post Office');
|
129 |
+
|
130 |
+
if ($countryId == 'BE') {
|
131 |
+
$this->setSubType($this->__('Belgium'));
|
132 |
+
}
|
133 |
break;
|
134 |
case 'Avond':
|
135 |
$this->setSubType($this->__('Evening Delivery'));
|
141 |
case 'Monday':
|
142 |
$shipmentType = $this->__('Monday Delivery');
|
143 |
break;
|
144 |
+
case 'Sameday':
|
145 |
+
$shipmentType = $this->__('Same Day Delivery');
|
146 |
+
break;
|
147 |
case 'Overdag':
|
148 |
if ($countryId != $domesticCountry) {
|
149 |
continue;
|
150 |
}
|
151 |
$shipmentType = $this->__('Domestic');
|
152 |
break;
|
153 |
+
case 'Food':
|
154 |
+
$shipmentType = $this->__('Food Delivery');
|
155 |
+
break;
|
156 |
+
case 'Cooledfood':
|
157 |
+
$shipmentType = $this->__('Cooled Food Delivery');
|
158 |
+
break;
|
159 |
}
|
160 |
|
161 |
if ($shipmentType) {
|
162 |
return $shipmentType;
|
163 |
}
|
164 |
|
165 |
+
if (
|
166 |
+
$countryId == $domesticCountry ||
|
167 |
+
(
|
168 |
+
$domesticCountry == 'BE' &&
|
169 |
+
$countryId == 'NL' &&
|
170 |
+
Mage::helper('postnl/deliveryOptions')->canUseDutchProducts()
|
171 |
+
)
|
172 |
+
) {
|
173 |
$shipmentType = $this->__('Domestic');
|
174 |
|
175 |
return $shipmentType;
|
176 |
}
|
177 |
|
178 |
+
/** @var TIG_PostNL_Helper_Cif $cifHelper */
|
179 |
+
$cifHelper = Mage::helper('postnl/cif');
|
180 |
+
$euCountries = $cifHelper->getEuCountries();
|
181 |
if (in_array($countryId, $euCountries)) {
|
182 |
$shipmentType = $this->__('EPS');
|
183 |
|
275 |
'timezone_differ' => false,
|
276 |
);
|
277 |
|
278 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
279 |
$dateModel = Mage::getSingleton('core/date');
|
280 |
$utcTimeZone = new DateTimeZone('UTC');
|
281 |
|
299 |
|
300 |
return $info;
|
301 |
}
|
302 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Returns extends Mage_Adminhtml_Block_Sales_Shipment
|
@@ -41,6 +41,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Returns extends Mage_Adminhtml_Block_Sale
|
|
41 |
/**
|
42 |
* Constructor to set the title, block group and controller names as well as to remove the add button.
|
43 |
*/
|
|
|
44 |
public function __construct()
|
45 |
{
|
46 |
$this->_blockGroup = 'postnl_adminhtml';
|
@@ -49,4 +50,4 @@ class TIG_PostNL_Block_Adminhtml_Sales_Returns extends Mage_Adminhtml_Block_Sale
|
|
49 |
Mage_Adminhtml_Block_Widget_Grid_Container::__construct();
|
50 |
$this->_removeButton('add');
|
51 |
}
|
52 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Returns extends Mage_Adminhtml_Block_Sales_Shipment
|
41 |
/**
|
42 |
* Constructor to set the title, block group and controller names as well as to remove the add button.
|
43 |
*/
|
44 |
+
/** @noinspection PhpMissingParentConstructorInspection */
|
45 |
public function __construct()
|
46 |
{
|
47 |
$this->_blockGroup = 'postnl_adminhtml';
|
50 |
Mage_Adminhtml_Block_Widget_Grid_Container::__construct();
|
51 |
$this->_removeButton('add');
|
52 |
}
|
53 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Returns_Grid extends Mage_Adminhtml_Block_Sales_Shipment_Grid
|
@@ -58,6 +58,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Returns_Grid extends Mage_Adminhtml_Block
|
|
58 |
/** @var Mage_Sales_Model_Resource_Order_Shipment_Collection $collection */
|
59 |
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
60 |
|
|
|
61 |
$resource = Mage::getSingleton('core/resource');
|
62 |
|
63 |
$select = $collection->getSelect();
|
@@ -102,6 +103,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Returns_Grid extends Mage_Adminhtml_Block
|
|
102 |
);
|
103 |
|
104 |
/** @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment */
|
|
|
105 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
106 |
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
107 |
$colloNotFoundStatus = $postnlShipmentModelClass::SHIPPING_PHASE_NOT_APPLICABLE;
|
@@ -140,6 +142,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Returns_Grid extends Mage_Adminhtml_Block
|
|
140 |
protected function _prepareColumns()
|
141 |
{
|
142 |
$salesHelper = Mage::helper('sales');
|
|
|
143 |
$postnlHelper = Mage::helper('postnl/cif');
|
144 |
|
145 |
$this->addColumn(
|
@@ -276,8 +279,10 @@ class TIG_PostNL_Block_Adminhtml_Sales_Returns_Grid extends Mage_Adminhtml_Block
|
|
276 |
/**
|
277 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
278 |
*/
|
|
|
279 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
280 |
|
|
|
281 |
switch ($row->getData($column->getIndex())) {
|
282 |
case null: //rows with no value (non-PostNL shipments) or unconfirmed shipments.
|
283 |
$class = '';
|
@@ -324,7 +329,9 @@ class TIG_PostNL_Block_Adminhtml_Sales_Returns_Grid extends Mage_Adminhtml_Block
|
|
324 |
*/
|
325 |
public function getRowUrl($row)
|
326 |
{
|
327 |
-
|
|
|
|
|
328 |
return false;
|
329 |
}
|
330 |
|
@@ -335,4 +342,4 @@ class TIG_PostNL_Block_Adminhtml_Sales_Returns_Grid extends Mage_Adminhtml_Block
|
|
335 |
)
|
336 |
);
|
337 |
}
|
338 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Sales_Returns_Grid extends Mage_Adminhtml_Block_Sales_Shipment_Grid
|
58 |
/** @var Mage_Sales_Model_Resource_Order_Shipment_Collection $collection */
|
59 |
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
60 |
|
61 |
+
/** @var Mage_Core_Model_Resource $resource */
|
62 |
$resource = Mage::getSingleton('core/resource');
|
63 |
|
64 |
$select = $collection->getSelect();
|
103 |
);
|
104 |
|
105 |
/** @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment */
|
106 |
+
/** @noinspection PhpParamsInspection */
|
107 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
108 |
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
109 |
$colloNotFoundStatus = $postnlShipmentModelClass::SHIPPING_PHASE_NOT_APPLICABLE;
|
142 |
protected function _prepareColumns()
|
143 |
{
|
144 |
$salesHelper = Mage::helper('sales');
|
145 |
+
/** @var TIG_PostNL_Helper_Cif $postnlHelper */
|
146 |
$postnlHelper = Mage::helper('postnl/cif');
|
147 |
|
148 |
$this->addColumn(
|
279 |
/**
|
280 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
281 |
*/
|
282 |
+
/** @noinspection PhpParamsInspection */
|
283 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
284 |
|
285 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
286 |
switch ($row->getData($column->getIndex())) {
|
287 |
case null: //rows with no value (non-PostNL shipments) or unconfirmed shipments.
|
288 |
$class = '';
|
329 |
*/
|
330 |
public function getRowUrl($row)
|
331 |
{
|
332 |
+
/** @var Mage_Admin_Model_Session $adminSession */
|
333 |
+
$adminSession = Mage::getSingleton('admin/session');
|
334 |
+
if (!$adminSession->isAllowed('sales/order/shipment')) {
|
335 |
return false;
|
336 |
}
|
337 |
|
342 |
)
|
343 |
);
|
344 |
}
|
345 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasFieldsetParam()
|
@@ -98,6 +98,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
98 |
if (!$this->_canShowField($section)) {
|
99 |
continue;
|
100 |
}
|
|
|
101 |
foreach ($section->groups as $groups){
|
102 |
$groups = (array)$groups;
|
103 |
usort($groups, array($this, '_sortForm'));
|
@@ -147,7 +148,9 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
147 |
*/
|
148 |
protected function _initGroup($form, $group, $section, $parentElement = null)
|
149 |
{
|
|
|
150 |
if ($group->frontend_model) {
|
|
|
151 |
$fieldsetRenderer = Mage::getBlockSingleton((string)$group->frontend_model);
|
152 |
} else {
|
153 |
$fieldsetRenderer = $this->_defaultFieldsetRenderer;
|
@@ -158,6 +161,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
158 |
|
159 |
if ($this->_configFields->hasChildren($group, $this->getWebsiteCode(), $this->getStoreCode())) {
|
160 |
$helperName = $this->_configFields->getAttributeModule($section, $group);
|
|
|
161 |
$fieldsetConfig = array('legend' => Mage::helper($helperName)->__((string)$group->label));
|
162 |
if (!empty($group->comment)) {
|
163 |
if (!empty($group->comment_url)) {
|
@@ -195,11 +199,13 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
195 |
}
|
196 |
|
197 |
$fieldset = new Varien_Data_Form_Element_Fieldset($fieldsetConfig);
|
|
|
198 |
$fieldset->setId($section->getName() . '_' . $group->getName())
|
199 |
-
|
200 |
-
|
201 |
|
202 |
if ($parentElement) {
|
|
|
203 |
$fieldset->setIsNested(true);
|
204 |
$parentElement->addElement($fieldset);
|
205 |
} else {
|
@@ -211,8 +217,11 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
211 |
|
212 |
$this->_fieldsets[$group->getName()] = $fieldset;
|
213 |
|
|
|
214 |
if ($group->clone_fields) {
|
|
|
215 |
if ($group->clone_model) {
|
|
|
216 |
$cloneModel = Mage::getModel((string)$group->clone_model);
|
217 |
} else {
|
218 |
throw new TIG_PostNL_Exception(
|
@@ -220,6 +229,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
220 |
'POSTNL-0095'
|
221 |
);
|
222 |
}
|
|
|
223 |
foreach ($cloneModel->getPrefixes() as $prefix) {
|
224 |
$this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']);
|
225 |
}
|
@@ -252,10 +262,13 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
252 |
// Extends for config data
|
253 |
$configDataAdditionalGroups = array();
|
254 |
|
|
|
255 |
foreach ($group->fields as $elements) {
|
256 |
$elements = (array)$elements;
|
257 |
// sort either by sort_order or by child node values bypassing the sort_order
|
|
|
258 |
if ($group->sort_fields && $group->sort_fields->by) {
|
|
|
259 |
$fieldset->setSortElementsByAttribute(
|
260 |
(string)$group->sort_fields->by,
|
261 |
$group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC
|
@@ -269,6 +282,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
269 |
continue;
|
270 |
}
|
271 |
|
|
|
272 |
if ((string)$element->getAttribute('type') == 'group') {
|
273 |
$this->_initGroup($fieldset->getForm(), $element, $section, $fieldset);
|
274 |
continue;
|
@@ -279,6 +293,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
279 |
*/
|
280 |
$path = (string)$element->config_path;
|
281 |
if (empty($path)) {
|
|
|
282 |
$path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $element->getName();
|
283 |
} elseif (strrpos($path, '/') > 0) {
|
284 |
// Extend config data with new section group
|
@@ -301,7 +316,9 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
301 |
* backwards compatibility for those versions.
|
302 |
*/
|
303 |
$version = Mage::getVersion();
|
304 |
-
|
|
|
|
|
305 |
|
306 |
/**
|
307 |
* Get the minimum version requirement for the current Magento edition.
|
@@ -342,6 +359,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
342 |
|
343 |
$helperName = $this->_configFields->getAttributeModule($section, $group, $element);
|
344 |
$fieldType = (string)$element->frontend_type ? (string)$element->frontend_type : 'text';
|
|
|
345 |
$name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix.$element->getName() . '][value]';
|
346 |
$label = Mage::helper($helperName)->__($labelPrefix) . ' '
|
347 |
. Mage::helper($helperName)->__((string)$element->label);
|
@@ -352,6 +370,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
352 |
if (!$model instanceof Mage_Core_Model_Config_Data) {
|
353 |
Mage::throwException('Invalid config field backend model: '.(string)$element->backend_model);
|
354 |
}
|
|
|
355 |
$model->setPath($path)
|
356 |
->setValue($data)
|
357 |
->setWebsite($this->getWebsiteCode())
|
@@ -362,6 +381,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
362 |
|
363 |
$comment = $this->_prepareFieldComment($element, $helperName, $data);
|
364 |
$tooltip = $this->_prepareFieldTooltip($element, $helperName);
|
|
|
365 |
$id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $element->getName();
|
366 |
|
367 |
if ($element->depends) {
|
@@ -378,6 +398,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
378 |
}
|
379 |
|
380 |
$dependentFieldNameValue = $dependent->getName();
|
|
|
381 |
$dependentFieldGroup = $dependentFieldGroupName == $group->getName()
|
382 |
? $group
|
383 |
: $this->_fieldsets[$dependentFieldGroupName]->getGroup();
|
@@ -395,7 +416,8 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
395 |
$dependentValue = array('eval' => (string) $dependent->eval);
|
396 |
}
|
397 |
$dependentFieldName = $fieldPrefix . $dependent->getName();
|
398 |
-
|
|
|
399 |
/*
|
400 |
* If dependent field can't be shown in current scope and real dependent config value
|
401 |
* is not equal to preferred one, then hide dependence fields by adding dependence
|
@@ -457,6 +479,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
457 |
}
|
458 |
|
459 |
if (isset($element->autocomplete)) {
|
|
|
460 |
$field->setAutocomplete($element->autocomplete);
|
461 |
}
|
462 |
|
@@ -464,6 +487,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
464 |
&& 'multiselect' === (string)$element->frontend_type
|
465 |
&& isset($element->can_be_empty)
|
466 |
) {
|
|
|
467 |
$field->setCanBeEmpty(true);
|
468 |
}
|
469 |
|
@@ -480,6 +504,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
480 |
|
481 |
$sourceModel = Mage::getSingleton($factoryName);
|
482 |
if ($sourceModel instanceof Varien_Object) {
|
|
|
483 |
$sourceModel->setPath($path);
|
484 |
}
|
485 |
if ($method) {
|
@@ -492,8 +517,10 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
492 |
}
|
493 |
}
|
494 |
} else {
|
|
|
495 |
$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
|
496 |
}
|
|
|
497 |
$field->setValues($optionArray);
|
498 |
}
|
499 |
}
|
@@ -547,12 +574,16 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
547 |
*/
|
548 |
protected function _prepareFieldTooltip($element, $helper)
|
549 |
{
|
|
|
550 |
if ($element->tooltip_block) {
|
|
|
|
|
551 |
return $this->getLayout()
|
552 |
->createBlock((string)$element->tooltip_block)
|
553 |
->setElement($element)
|
554 |
->toHtml();
|
555 |
-
} elseif ($element->tooltip) {
|
|
|
556 |
return Mage::helper($helper)->__((string)$element->tooltip);
|
557 |
}
|
558 |
|
@@ -571,6 +602,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
571 |
return false;
|
572 |
}
|
573 |
|
|
|
574 |
$ifModuleEnabled = trim((string)$field->if_module_enabled);
|
575 |
if ($ifModuleEnabled && !Mage::helper('Core')->isModuleEnabled($ifModuleEnabled)) {
|
576 |
return false;
|
@@ -578,12 +610,15 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
578 |
|
579 |
switch ($this->getScope()) {
|
580 |
case self::SCOPE_DEFAULT:
|
|
|
581 |
return (int)$field->show_in_default;
|
582 |
break;
|
583 |
case self::SCOPE_WEBSITES:
|
|
|
584 |
return (int)$field->show_in_website;
|
585 |
break;
|
586 |
case self::SCOPE_STORES:
|
|
|
587 |
return (int)$field->show_in_store;
|
588 |
break;
|
589 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasFieldsetParam()
|
98 |
if (!$this->_canShowField($section)) {
|
99 |
continue;
|
100 |
}
|
101 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
102 |
foreach ($section->groups as $groups){
|
103 |
$groups = (array)$groups;
|
104 |
usort($groups, array($this, '_sortForm'));
|
148 |
*/
|
149 |
protected function _initGroup($form, $group, $section, $parentElement = null)
|
150 |
{
|
151 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
152 |
if ($group->frontend_model) {
|
153 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
154 |
$fieldsetRenderer = Mage::getBlockSingleton((string)$group->frontend_model);
|
155 |
} else {
|
156 |
$fieldsetRenderer = $this->_defaultFieldsetRenderer;
|
161 |
|
162 |
if ($this->_configFields->hasChildren($group, $this->getWebsiteCode(), $this->getStoreCode())) {
|
163 |
$helperName = $this->_configFields->getAttributeModule($section, $group);
|
164 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
165 |
$fieldsetConfig = array('legend' => Mage::helper($helperName)->__((string)$group->label));
|
166 |
if (!empty($group->comment)) {
|
167 |
if (!empty($group->comment_url)) {
|
199 |
}
|
200 |
|
201 |
$fieldset = new Varien_Data_Form_Element_Fieldset($fieldsetConfig);
|
202 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
203 |
$fieldset->setId($section->getName() . '_' . $group->getName())
|
204 |
+
->setRenderer($fieldsetRenderer)
|
205 |
+
->setGroup($group);
|
206 |
|
207 |
if ($parentElement) {
|
208 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
209 |
$fieldset->setIsNested(true);
|
210 |
$parentElement->addElement($fieldset);
|
211 |
} else {
|
217 |
|
218 |
$this->_fieldsets[$group->getName()] = $fieldset;
|
219 |
|
220 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
221 |
if ($group->clone_fields) {
|
222 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
223 |
if ($group->clone_model) {
|
224 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
225 |
$cloneModel = Mage::getModel((string)$group->clone_model);
|
226 |
} else {
|
227 |
throw new TIG_PostNL_Exception(
|
229 |
'POSTNL-0095'
|
230 |
);
|
231 |
}
|
232 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
233 |
foreach ($cloneModel->getPrefixes() as $prefix) {
|
234 |
$this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']);
|
235 |
}
|
262 |
// Extends for config data
|
263 |
$configDataAdditionalGroups = array();
|
264 |
|
265 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
266 |
foreach ($group->fields as $elements) {
|
267 |
$elements = (array)$elements;
|
268 |
// sort either by sort_order or by child node values bypassing the sort_order
|
269 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
270 |
if ($group->sort_fields && $group->sort_fields->by) {
|
271 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
272 |
$fieldset->setSortElementsByAttribute(
|
273 |
(string)$group->sort_fields->by,
|
274 |
$group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC
|
282 |
continue;
|
283 |
}
|
284 |
|
285 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
286 |
if ((string)$element->getAttribute('type') == 'group') {
|
287 |
$this->_initGroup($fieldset->getForm(), $element, $section, $fieldset);
|
288 |
continue;
|
293 |
*/
|
294 |
$path = (string)$element->config_path;
|
295 |
if (empty($path)) {
|
296 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
297 |
$path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $element->getName();
|
298 |
} elseif (strrpos($path, '/') > 0) {
|
299 |
// Extend config data with new section group
|
316 |
* backwards compatibility for those versions.
|
317 |
*/
|
318 |
$version = Mage::getVersion();
|
319 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
320 |
+
$helper = Mage::helper('postnl');
|
321 |
+
$isEnterprise = $helper->isEnterprise();
|
322 |
|
323 |
/**
|
324 |
* Get the minimum version requirement for the current Magento edition.
|
359 |
|
360 |
$helperName = $this->_configFields->getAttributeModule($section, $group, $element);
|
361 |
$fieldType = (string)$element->frontend_type ? (string)$element->frontend_type : 'text';
|
362 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
363 |
$name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix.$element->getName() . '][value]';
|
364 |
$label = Mage::helper($helperName)->__($labelPrefix) . ' '
|
365 |
. Mage::helper($helperName)->__((string)$element->label);
|
370 |
if (!$model instanceof Mage_Core_Model_Config_Data) {
|
371 |
Mage::throwException('Invalid config field backend model: '.(string)$element->backend_model);
|
372 |
}
|
373 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
374 |
$model->setPath($path)
|
375 |
->setValue($data)
|
376 |
->setWebsite($this->getWebsiteCode())
|
381 |
|
382 |
$comment = $this->_prepareFieldComment($element, $helperName, $data);
|
383 |
$tooltip = $this->_prepareFieldTooltip($element, $helperName);
|
384 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
385 |
$id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $element->getName();
|
386 |
|
387 |
if ($element->depends) {
|
398 |
}
|
399 |
|
400 |
$dependentFieldNameValue = $dependent->getName();
|
401 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
402 |
$dependentFieldGroup = $dependentFieldGroupName == $group->getName()
|
403 |
? $group
|
404 |
: $this->_fieldsets[$dependentFieldGroupName]->getGroup();
|
416 |
$dependentValue = array('eval' => (string) $dependent->eval);
|
417 |
}
|
418 |
$dependentFieldName = $fieldPrefix . $dependent->getName();
|
419 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
420 |
+
$dependentField = $dependentFieldGroup->fields->$dependentFieldName;
|
421 |
/*
|
422 |
* If dependent field can't be shown in current scope and real dependent config value
|
423 |
* is not equal to preferred one, then hide dependence fields by adding dependence
|
479 |
}
|
480 |
|
481 |
if (isset($element->autocomplete)) {
|
482 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
483 |
$field->setAutocomplete($element->autocomplete);
|
484 |
}
|
485 |
|
487 |
&& 'multiselect' === (string)$element->frontend_type
|
488 |
&& isset($element->can_be_empty)
|
489 |
) {
|
490 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
491 |
$field->setCanBeEmpty(true);
|
492 |
}
|
493 |
|
504 |
|
505 |
$sourceModel = Mage::getSingleton($factoryName);
|
506 |
if ($sourceModel instanceof Varien_Object) {
|
507 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
508 |
$sourceModel->setPath($path);
|
509 |
}
|
510 |
if ($method) {
|
517 |
}
|
518 |
}
|
519 |
} else {
|
520 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
521 |
$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
|
522 |
}
|
523 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
524 |
$field->setValues($optionArray);
|
525 |
}
|
526 |
}
|
574 |
*/
|
575 |
protected function _prepareFieldTooltip($element, $helper)
|
576 |
{
|
577 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
578 |
if ($element->tooltip_block) {
|
579 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
580 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
581 |
return $this->getLayout()
|
582 |
->createBlock((string)$element->tooltip_block)
|
583 |
->setElement($element)
|
584 |
->toHtml();
|
585 |
+
} /** @noinspection PhpUndefinedFieldInspection */ elseif ($element->tooltip) {
|
586 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
587 |
return Mage::helper($helper)->__((string)$element->tooltip);
|
588 |
}
|
589 |
|
602 |
return false;
|
603 |
}
|
604 |
|
605 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
606 |
$ifModuleEnabled = trim((string)$field->if_module_enabled);
|
607 |
if ($ifModuleEnabled && !Mage::helper('Core')->isModuleEnabled($ifModuleEnabled)) {
|
608 |
return false;
|
610 |
|
611 |
switch ($this->getScope()) {
|
612 |
case self::SCOPE_DEFAULT:
|
613 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
614 |
return (int)$field->show_in_default;
|
615 |
break;
|
616 |
case self::SCOPE_WEBSITES:
|
617 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
618 |
return (int)$field->show_in_website;
|
619 |
break;
|
620 |
case self::SCOPE_STORES:
|
621 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
622 |
return (int)$field->show_in_store;
|
623 |
break;
|
624 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton setElement(Varien_Data_Form_Element_Abstract $value)
|
@@ -65,6 +65,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton
|
|
65 |
$label = $this->__('Send security keys');
|
66 |
}
|
67 |
|
|
|
68 |
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
69 |
->setId($element->getHtmlId())
|
70 |
->setType('button')
|
@@ -86,6 +87,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton
|
|
86 |
*/
|
87 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
88 |
{
|
|
|
89 |
$element->setScopeLabel('');
|
90 |
return parent::render($element);
|
91 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton setElement(Varien_Data_Form_Element_Abstract $value)
|
65 |
$label = $this->__('Send security keys');
|
66 |
}
|
67 |
|
68 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
69 |
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
70 |
->setId($element->getHtmlId())
|
71 |
->setType('button')
|
87 |
*/
|
88 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
89 |
{
|
90 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
91 |
$element->setScopeLabel('');
|
92 |
return parent::render($element);
|
93 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivatedFieldHeader
|
@@ -63,6 +63,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivatedFieldHeader
|
|
63 |
}
|
64 |
|
65 |
$element = $this->getElement();
|
|
|
66 |
$label = $element->getLabel();
|
67 |
|
68 |
$section = $this->getRequest()->getParam('section');
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivatedFieldHeader
|
63 |
}
|
64 |
|
65 |
$element = $this->getElement();
|
66 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
67 |
$label = $element->getLabel();
|
68 |
|
69 |
$section = $this->getRequest()->getParam('section');
|
@@ -33,19 +33,23 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_AddressLines
|
40 |
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Hidden
|
41 |
{
|
42 |
/**
|
|
|
|
|
43 |
* @return int|string
|
44 |
*/
|
45 |
protected function _getValue(Varien_Data_Form_Element_Abstract $element)
|
46 |
{
|
47 |
-
|
|
|
|
|
48 |
|
49 |
return $value;
|
50 |
}
|
51 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_AddressLines
|
40 |
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Hidden
|
41 |
{
|
42 |
/**
|
43 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
44 |
+
*
|
45 |
* @return int|string
|
46 |
*/
|
47 |
protected function _getValue(Varien_Data_Form_Element_Abstract $element)
|
48 |
{
|
49 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
50 |
+
$helper = Mage::helper('postnl/addressValidation');
|
51 |
+
$value = $helper->getAddressLineCount();
|
52 |
|
53 |
return $value;
|
54 |
}
|
55 |
+
}
|
@@ -33,8 +33,15 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Anchor
|
40 |
extends Varien_Data_Form_Element_Link
|
@@ -47,8 +54,9 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Anchor
|
|
47 |
*/
|
48 |
public function getElementHtml()
|
49 |
{
|
|
|
50 |
$originalData = $this->getElement()->getOriginalData();
|
51 |
-
$anchorName
|
52 |
|
53 |
$html = $this->getBeforeElementHtml();
|
54 |
$html .= '<a name="' . $anchorName . '"></a>';
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*
|
39 |
+
* @method Varien_Data_Form_Element_Abstract getElement()
|
40 |
+
* @method string getBeforeElementHtml()
|
41 |
+
*
|
42 |
+
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Anchor setElement(Varien_Data_Form_Element_Abstract $element)
|
43 |
+
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Anchor setBeforeElementHtml($html)
|
44 |
+
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Anchor setAfterElementHtml($html)
|
45 |
*/
|
46 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Anchor
|
47 |
extends Varien_Data_Form_Element_Link
|
54 |
*/
|
55 |
public function getElementHtml()
|
56 |
{
|
57 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
58 |
$originalData = $this->getElement()->getOriginalData();
|
59 |
+
$anchorName = $originalData['anchor_name'];
|
60 |
|
61 |
$html = $this->getBeforeElementHtml();
|
62 |
$html .= '<a name="' . $anchorName . '"></a>';
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_CheckForWarningBox
|
40 |
+
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventPrefix = 'postnl_adminhtml_system_config_form_field_check_for_warningbox';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Template file used
|
49 |
+
*
|
50 |
+
* @var string
|
51 |
+
*/
|
52 |
+
protected $_template = 'TIG/PostNL/system/config/form/field/check_for_warning_box.phtml';
|
53 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method mixed getValue()
|
@@ -108,4 +108,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Checkbox extends Varie
|
|
108 |
$this->setIsChecked($checked);
|
109 |
return $checked;
|
110 |
}
|
111 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method mixed getValue()
|
108 |
$this->setIsChecked($checked);
|
109 |
return $checked;
|
110 |
}
|
111 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlHelper()
|
@@ -53,6 +53,14 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck
|
|
53 |
const XPATH_USE_GLOBALPACK = 'postnl/cif_globalpack_settings/use_globalpack';
|
54 |
const XPATH_USE_CHECKOUT = 'postnl/cif/use_checkout';
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
/**
|
57 |
* Template file used by this element.
|
58 |
*
|
@@ -71,6 +79,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck
|
|
71 |
return $this->getData('postnl_helper');
|
72 |
}
|
73 |
|
|
|
74 |
$helper = Mage::helper('postnl');
|
75 |
|
76 |
$this->setPostnlHelper($helper);
|
@@ -165,6 +174,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck
|
|
165 |
*/
|
166 |
public function isCheckoutEnabled()
|
167 |
{
|
|
|
168 |
$helper = Mage::helper('postnl/checkout');
|
169 |
|
170 |
if (!$helper->isCheckoutActive()) {
|
@@ -188,4 +198,46 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck
|
|
188 |
|
189 |
return $configErrors;
|
190 |
}
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlHelper()
|
53 |
const XPATH_USE_GLOBALPACK = 'postnl/cif_globalpack_settings/use_globalpack';
|
54 |
const XPATH_USE_CHECKOUT = 'postnl/cif/use_checkout';
|
55 |
|
56 |
+
/**
|
57 |
+
* XML paths to check the Dutch products.
|
58 |
+
*/
|
59 |
+
const XPATH_USE_DUTCH_PRODUCTS = 'postnl/cif_labels_and_confirming/use_dutch_products';
|
60 |
+
const XPATH_USE_DUTCH_ADDRESS = 'postnl/cif_address/use_dutch_address';
|
61 |
+
const XPATH_DUTCH_CUSTOMER_CODE = 'postnl/cif/dutch_customer_code';
|
62 |
+
const XPATH_DUTCH_CUSTOMER_NUMBER = 'postnl/cif/dutch_customer_number';
|
63 |
+
|
64 |
/**
|
65 |
* Template file used by this element.
|
66 |
*
|
79 |
return $this->getData('postnl_helper');
|
80 |
}
|
81 |
|
82 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
83 |
$helper = Mage::helper('postnl');
|
84 |
|
85 |
$this->setPostnlHelper($helper);
|
174 |
*/
|
175 |
public function isCheckoutEnabled()
|
176 |
{
|
177 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
178 |
$helper = Mage::helper('postnl/checkout');
|
179 |
|
180 |
if (!$helper->isCheckoutActive()) {
|
198 |
|
199 |
return $configErrors;
|
200 |
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Check if there is a dutch address needed.
|
204 |
+
*
|
205 |
+
* @return bool
|
206 |
+
*/
|
207 |
+
public function needsDutchAddress()
|
208 |
+
{
|
209 |
+
$country = $this->helper('postnl')->getDomesticCountry();
|
210 |
+
|
211 |
+
if ($country == 'BE') {
|
212 |
+
$useDutchProducts = Mage::getStoreConfig(self::XPATH_USE_DUTCH_PRODUCTS);
|
213 |
+
$useDutchAddress = Mage::getStoreConfig(self::XPATH_USE_DUTCH_ADDRESS);
|
214 |
+
|
215 |
+
if ($useDutchProducts == '1' && $useDutchAddress == '0') {
|
216 |
+
return true;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
return false;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Check if the dutch customer code and customer number are entered.
|
225 |
+
*
|
226 |
+
* @return bool
|
227 |
+
*/
|
228 |
+
public function needsDutchCustomerCodeOrNumber(){
|
229 |
+
$country = $this->helper('postnl')->getDomesticCountry();
|
230 |
+
|
231 |
+
if ($country == 'BE') {
|
232 |
+
$useDutchProducts = Mage::getStoreConfig(self::XPATH_USE_DUTCH_PRODUCTS);
|
233 |
+
$dutchCustomerCode = Mage::getStoreConfig(self::XPATH_DUTCH_CUSTOMER_CODE);
|
234 |
+
$dutchCustomerNumber = Mage::getStoreConfig(self::XPATH_DUTCH_CUSTOMER_NUMBER);
|
235 |
+
|
236 |
+
if ($useDutchProducts == '1' && (empty($dutchCustomerCode) || empty($dutchCustomerNumber))) {
|
237 |
+
return true;
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
return false;
|
242 |
+
}
|
243 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_GoMageDeliveryDateConflicts
|
@@ -50,8 +50,9 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_GoMageDeliveryDateConf
|
|
50 |
{
|
51 |
$storeId = $this->_getStoreId();
|
52 |
|
53 |
-
|
54 |
-
|
|
|
55 |
|
56 |
return (int) $goMageDeliveryDateConflicts;
|
57 |
}
|
@@ -69,6 +70,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_GoMageDeliveryDateConf
|
|
69 |
$store = $request->getparam('store');
|
70 |
$storeId = Mage::app()->getStore($store)->getId();
|
71 |
} elseif ($request->getParam('website')) {
|
|
|
72 |
$website = Mage::getModel('core/website')->load($request->getparam('website'), 'code');
|
73 |
$store = $website->getDefaultStore();
|
74 |
$storeId = $store->getId();
|
@@ -78,4 +80,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_GoMageDeliveryDateConf
|
|
78 |
|
79 |
return $storeId;
|
80 |
}
|
81 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_GoMageDeliveryDateConflicts
|
50 |
{
|
51 |
$storeId = $this->_getStoreId();
|
52 |
|
53 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
54 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
55 |
+
$goMageDeliveryDateConflicts = $helper->checkGoMageDeliveryDateConflicts($storeId);
|
56 |
|
57 |
return (int) $goMageDeliveryDateConflicts;
|
58 |
}
|
70 |
$store = $request->getparam('store');
|
71 |
$storeId = Mage::app()->getStore($store)->getId();
|
72 |
} elseif ($request->getParam('website')) {
|
73 |
+
/** @var Mage_Core_Model_Website $website */
|
74 |
$website = Mage::getModel('core/website')->load($request->getparam('website'), 'code');
|
75 |
$store = $website->getDefaultStore();
|
76 |
$storeId = $store->getId();
|
80 |
|
81 |
return $storeId;
|
82 |
}
|
83 |
+
}
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_GooglePlacesActive
|
40 |
+
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Hidden
|
41 |
+
{
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Get whether OSC is installed and enabled and Google places is active.
|
45 |
+
*
|
46 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
47 |
+
*
|
48 |
+
* @return int
|
49 |
+
*/
|
50 |
+
protected function _getValue(Varien_Data_Form_Element_Abstract $element)
|
51 |
+
{
|
52 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
53 |
+
$helper = Mage::helper('postnl/addressValidation');
|
54 |
+
$extensionEnabled = $helper->checkGooglePlacesActive(Mage_Core_Model_App::ADMIN_STORE_ID);
|
55 |
+
|
56 |
+
return (int) $extensionEnabled;
|
57 |
+
}
|
58 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Hidden
|
@@ -61,48 +61,60 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Hidden
|
|
61 |
{
|
62 |
$id = $element->getHtmlId();
|
63 |
|
|
|
64 |
$html = '<td class="label"><label for="'.$id.'">'.$element->getLabel().'</label></td>';
|
65 |
|
66 |
//$isDefault = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
|
|
|
67 |
$isMultiple = $element->getExtType()==='multiple';
|
68 |
|
69 |
// replace [value] with [inherit]
|
70 |
$namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName());
|
71 |
|
|
|
72 |
$options = $element->getValues();
|
73 |
|
74 |
$addInheritCheckbox = false;
|
|
|
|
|
75 |
if ($element->getCanUseWebsiteValue()) {
|
76 |
$addInheritCheckbox = true;
|
77 |
$checkboxLabel = $this->__('Use Website');
|
78 |
-
}
|
79 |
-
elseif ($element->getCanUseDefaultValue()) {
|
80 |
$addInheritCheckbox = true;
|
81 |
$checkboxLabel = $this->__('Use Default');
|
82 |
}
|
83 |
|
|
|
84 |
if ($addInheritCheckbox) {
|
|
|
85 |
$inherit = $element->getInherit()==1 ? 'checked="checked"' : '';
|
86 |
if ($inherit) {
|
|
|
87 |
$element->setDisabled(true);
|
88 |
}
|
89 |
}
|
90 |
|
|
|
91 |
if ($element->getTooltip()) {
|
92 |
$html .= '<td class="value with-tooltip">';
|
93 |
$html .= $this->_getElementHtml($element);
|
|
|
94 |
$html .= '<div class="field-tooltip"><div>' . $element->getTooltip() . '</div></div>';
|
95 |
} else {
|
96 |
$html .= '<td class="value">';
|
97 |
$html .= $this->_getElementHtml($element);
|
98 |
};
|
|
|
99 |
if ($element->getComment()) {
|
|
|
100 |
$html.= '<p class="note"><span>'.$element->getComment().'</span></p>';
|
101 |
}
|
102 |
$html.= '</td>';
|
103 |
|
104 |
if ($addInheritCheckbox) {
|
105 |
|
|
|
106 |
$defText = $element->getDefaultValue();
|
107 |
if ($options) {
|
108 |
$defTextArr = array();
|
@@ -137,14 +149,18 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Hidden
|
|
137 |
}
|
138 |
|
139 |
$html.= '<td class="scope-label">';
|
|
|
140 |
if ($element->getScope()) {
|
|
|
141 |
$html .= $element->getScopeLabel();
|
142 |
}
|
143 |
$html.= '</td>';
|
144 |
|
145 |
$html.= '<td class="">';
|
|
|
146 |
if ($element->getHint()) {
|
147 |
$html.= '<div class="hint" >';
|
|
|
148 |
$html.= '<div style="display: none;">' . $element->getHint() . '</div>';
|
149 |
$html.= '</div>';
|
150 |
}
|
@@ -168,13 +184,17 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Hidden
|
|
168 |
$html.= $element->getAfterElementHtml();
|
169 |
return $html;
|
170 |
}
|
|
|
171 |
/**
|
|
|
|
|
172 |
* @return int|string
|
173 |
*/
|
174 |
protected function _getValue(Varien_Data_Form_Element_Abstract $element)
|
175 |
{
|
|
|
176 |
$value = $element->getValue();
|
177 |
|
178 |
return $value;
|
179 |
}
|
180 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Hidden
|
61 |
{
|
62 |
$id = $element->getHtmlId();
|
63 |
|
64 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
65 |
$html = '<td class="label"><label for="'.$id.'">'.$element->getLabel().'</label></td>';
|
66 |
|
67 |
//$isDefault = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
|
68 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
69 |
$isMultiple = $element->getExtType()==='multiple';
|
70 |
|
71 |
// replace [value] with [inherit]
|
72 |
$namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName());
|
73 |
|
74 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
75 |
$options = $element->getValues();
|
76 |
|
77 |
$addInheritCheckbox = false;
|
78 |
+
$checkboxLabel = '';
|
79 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
80 |
if ($element->getCanUseWebsiteValue()) {
|
81 |
$addInheritCheckbox = true;
|
82 |
$checkboxLabel = $this->__('Use Website');
|
83 |
+
} /** @noinspection PhpUndefinedMethodInspection */ elseif ($element->getCanUseDefaultValue()) {
|
|
|
84 |
$addInheritCheckbox = true;
|
85 |
$checkboxLabel = $this->__('Use Default');
|
86 |
}
|
87 |
|
88 |
+
$inherit = '';
|
89 |
if ($addInheritCheckbox) {
|
90 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
91 |
$inherit = $element->getInherit()==1 ? 'checked="checked"' : '';
|
92 |
if ($inherit) {
|
93 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
94 |
$element->setDisabled(true);
|
95 |
}
|
96 |
}
|
97 |
|
98 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
99 |
if ($element->getTooltip()) {
|
100 |
$html .= '<td class="value with-tooltip">';
|
101 |
$html .= $this->_getElementHtml($element);
|
102 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
103 |
$html .= '<div class="field-tooltip"><div>' . $element->getTooltip() . '</div></div>';
|
104 |
} else {
|
105 |
$html .= '<td class="value">';
|
106 |
$html .= $this->_getElementHtml($element);
|
107 |
};
|
108 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
109 |
if ($element->getComment()) {
|
110 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
111 |
$html.= '<p class="note"><span>'.$element->getComment().'</span></p>';
|
112 |
}
|
113 |
$html.= '</td>';
|
114 |
|
115 |
if ($addInheritCheckbox) {
|
116 |
|
117 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
118 |
$defText = $element->getDefaultValue();
|
119 |
if ($options) {
|
120 |
$defTextArr = array();
|
149 |
}
|
150 |
|
151 |
$html.= '<td class="scope-label">';
|
152 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
153 |
if ($element->getScope()) {
|
154 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
155 |
$html .= $element->getScopeLabel();
|
156 |
}
|
157 |
$html.= '</td>';
|
158 |
|
159 |
$html.= '<td class="">';
|
160 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
161 |
if ($element->getHint()) {
|
162 |
$html.= '<div class="hint" >';
|
163 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
164 |
$html.= '<div style="display: none;">' . $element->getHint() . '</div>';
|
165 |
$html.= '</div>';
|
166 |
}
|
184 |
$html.= $element->getAfterElementHtml();
|
185 |
return $html;
|
186 |
}
|
187 |
+
|
188 |
/**
|
189 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
190 |
+
*
|
191 |
* @return int|string
|
192 |
*/
|
193 |
protected function _getValue(Varien_Data_Form_Element_Abstract $element)
|
194 |
{
|
195 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
196 |
$value = $element->getValue();
|
197 |
|
198 |
return $value;
|
199 |
}
|
200 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_HourMinute
|
@@ -49,6 +49,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_HourMinute
|
|
49 |
{
|
50 |
$id = $element->getHtmlId();
|
51 |
|
|
|
52 |
$html = '<td class="label"><label for="'.$id.'">'.$element->getLabel().'</label></td>';
|
53 |
|
54 |
// replace [value] with [inherit]
|
@@ -56,40 +57,49 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_HourMinute
|
|
56 |
|
57 |
$addInheritCheckbox = false;
|
58 |
$checkboxLabel = '';
|
|
|
59 |
if ($element->getCanUseWebsiteValue()) {
|
60 |
$addInheritCheckbox = true;
|
61 |
$checkboxLabel = Mage::helper('adminhtml')->__('Use Website');
|
62 |
-
}
|
63 |
-
elseif ($element->getCanUseDefaultValue()) {
|
64 |
$addInheritCheckbox = true;
|
65 |
$checkboxLabel = Mage::helper('adminhtml')->__('Use Default');
|
66 |
}
|
67 |
|
68 |
$inherit = '';
|
69 |
if ($addInheritCheckbox) {
|
|
|
70 |
$inherit = $element->getInherit()==1 ? 'checked="checked"' : '';
|
71 |
if ($inherit) {
|
|
|
72 |
$element->setDisabled(true);
|
73 |
}
|
74 |
}
|
75 |
|
|
|
76 |
if ($element->getTooltip()) {
|
77 |
$html .= '<td class="value with-tooltip">';
|
78 |
$html .= '<div id="' . $element->getHtmlId() . '">';
|
79 |
$html .= $this->_getElementHtml($element);
|
|
|
80 |
$html .= '<div class="field-tooltip"><div>' . $element->getTooltip() . '</div></div>';
|
81 |
} else {
|
82 |
$html .= '<td class="value">';
|
83 |
$html .= '<div id="' . $element->getHtmlId() . '">';
|
84 |
$html .= $this->_getElementHtml($element);
|
85 |
};
|
|
|
|
|
86 |
if ($element->getComment()) {
|
|
|
87 |
$html.= '<p class="note"><span>'.$element->getComment().'</span></p>';
|
88 |
}
|
|
|
89 |
$html .= '</div>';
|
90 |
$html.= '</td>';
|
91 |
|
92 |
if ($addInheritCheckbox) {
|
|
|
93 |
$defText = $element->getDefaultValue();
|
94 |
|
95 |
// default value
|
@@ -103,14 +113,18 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_HourMinute
|
|
103 |
}
|
104 |
|
105 |
$html.= '<td class="scope-label">';
|
|
|
106 |
if ($element->getScope()) {
|
|
|
107 |
$html .= $element->getScopeLabel();
|
108 |
}
|
109 |
$html.= '</td>';
|
110 |
|
111 |
$html.= '<td class="">';
|
|
|
112 |
if ($element->getHint()) {
|
113 |
$html.= '<div class="hint" >';
|
|
|
114 |
$html.= '<div style="display: none;">' . $element->getHint() . '</div>';
|
115 |
$html.= '</div>';
|
116 |
}
|
@@ -147,6 +161,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_HourMinute
|
|
147 |
$minute = $value[1];
|
148 |
}
|
149 |
|
|
|
150 |
$options = $element->getValues();
|
151 |
|
152 |
/**
|
@@ -166,10 +181,10 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_HourMinute
|
|
166 |
foreach ($options['hour'] as $option) {
|
167 |
$selected = '';
|
168 |
if ($option['value'] == $hour) {
|
169 |
-
$selected = '
|
170 |
}
|
171 |
|
172 |
-
$html .= "<option value=\"{$option['value']}\"{$selected}>{$option['label']}</option>";
|
173 |
}
|
174 |
|
175 |
/**
|
@@ -199,10 +214,10 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_HourMinute
|
|
199 |
foreach ($options['minute'] as $option) {
|
200 |
$selected = '';
|
201 |
if ($option['value'] == $minute) {
|
202 |
-
$selected = '
|
203 |
}
|
204 |
|
205 |
-
$html .= "<option value=\"{$option['value']}\"{$selected}>{$option['label']}</option>";
|
206 |
}
|
207 |
|
208 |
/**
|
@@ -257,4 +272,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_HourMinute
|
|
257 |
{
|
258 |
return '<tr id="row_' . $element->getHtmlId() . '">' . $html . '</tr>';
|
259 |
}
|
260 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_HourMinute
|
49 |
{
|
50 |
$id = $element->getHtmlId();
|
51 |
|
52 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
53 |
$html = '<td class="label"><label for="'.$id.'">'.$element->getLabel().'</label></td>';
|
54 |
|
55 |
// replace [value] with [inherit]
|
57 |
|
58 |
$addInheritCheckbox = false;
|
59 |
$checkboxLabel = '';
|
60 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
61 |
if ($element->getCanUseWebsiteValue()) {
|
62 |
$addInheritCheckbox = true;
|
63 |
$checkboxLabel = Mage::helper('adminhtml')->__('Use Website');
|
64 |
+
} /** @noinspection PhpUndefinedMethodInspection */ elseif ($element->getCanUseDefaultValue()) {
|
|
|
65 |
$addInheritCheckbox = true;
|
66 |
$checkboxLabel = Mage::helper('adminhtml')->__('Use Default');
|
67 |
}
|
68 |
|
69 |
$inherit = '';
|
70 |
if ($addInheritCheckbox) {
|
71 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
72 |
$inherit = $element->getInherit()==1 ? 'checked="checked"' : '';
|
73 |
if ($inherit) {
|
74 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
75 |
$element->setDisabled(true);
|
76 |
}
|
77 |
}
|
78 |
|
79 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
80 |
if ($element->getTooltip()) {
|
81 |
$html .= '<td class="value with-tooltip">';
|
82 |
$html .= '<div id="' . $element->getHtmlId() . '">';
|
83 |
$html .= $this->_getElementHtml($element);
|
84 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
85 |
$html .= '<div class="field-tooltip"><div>' . $element->getTooltip() . '</div></div>';
|
86 |
} else {
|
87 |
$html .= '<td class="value">';
|
88 |
$html .= '<div id="' . $element->getHtmlId() . '">';
|
89 |
$html .= $this->_getElementHtml($element);
|
90 |
};
|
91 |
+
|
92 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
93 |
if ($element->getComment()) {
|
94 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
95 |
$html.= '<p class="note"><span>'.$element->getComment().'</span></p>';
|
96 |
}
|
97 |
+
|
98 |
$html .= '</div>';
|
99 |
$html.= '</td>';
|
100 |
|
101 |
if ($addInheritCheckbox) {
|
102 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
103 |
$defText = $element->getDefaultValue();
|
104 |
|
105 |
// default value
|
113 |
}
|
114 |
|
115 |
$html.= '<td class="scope-label">';
|
116 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
117 |
if ($element->getScope()) {
|
118 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
119 |
$html .= $element->getScopeLabel();
|
120 |
}
|
121 |
$html.= '</td>';
|
122 |
|
123 |
$html.= '<td class="">';
|
124 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
125 |
if ($element->getHint()) {
|
126 |
$html.= '<div class="hint" >';
|
127 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
128 |
$html.= '<div style="display: none;">' . $element->getHint() . '</div>';
|
129 |
$html.= '</div>';
|
130 |
}
|
161 |
$minute = $value[1];
|
162 |
}
|
163 |
|
164 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
165 |
$options = $element->getValues();
|
166 |
|
167 |
/**
|
181 |
foreach ($options['hour'] as $option) {
|
182 |
$selected = '';
|
183 |
if ($option['value'] == $hour) {
|
184 |
+
$selected = 'selected="selected"';
|
185 |
}
|
186 |
|
187 |
+
$html .= "<option value=\"{$option['value']}\" {$selected}>{$option['label']}</option>";
|
188 |
}
|
189 |
|
190 |
/**
|
214 |
foreach ($options['minute'] as $option) {
|
215 |
$selected = '';
|
216 |
if ($option['value'] == $minute) {
|
217 |
+
$selected = 'selected="selected"';
|
218 |
}
|
219 |
|
220 |
+
$html .= "<option value=\"{$option['value']}\" {$selected}>{$option['label']}</option>";
|
221 |
}
|
222 |
|
223 |
/**
|
272 |
{
|
273 |
return '<tr id="row_' . $element->getHtmlId() . '">' . $html . '</tr>';
|
274 |
}
|
275 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_InfoBox
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_InfoBox
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_MatrixrateExport
|
@@ -53,8 +53,10 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_MatrixrateExport
|
|
53 |
'website' => $buttonBlock->getRequest()->getParam('website')
|
54 |
);
|
55 |
|
|
|
|
|
56 |
$onClick = 'setLocation(\''
|
57 |
-
.
|
58 |
. '\')';
|
59 |
|
60 |
$data = array(
|
@@ -65,7 +67,8 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_MatrixrateExport
|
|
65 |
'class' => 'scalable postnl-button',
|
66 |
);
|
67 |
|
68 |
-
$
|
|
|
69 |
|
70 |
return $html;
|
71 |
}
|
@@ -79,4 +82,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_MatrixrateExport
|
|
79 |
{
|
80 |
return parent::render($element);
|
81 |
}
|
82 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_MatrixrateExport
|
53 |
'website' => $buttonBlock->getRequest()->getParam('website')
|
54 |
);
|
55 |
|
56 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
57 |
+
$helper = Mage::helper('adminhtml');
|
58 |
$onClick = 'setLocation(\''
|
59 |
+
. $helper->getUrl("adminhtml/postnlAdminhtml_config/exportMatrixrates", $params)
|
60 |
. '\')';
|
61 |
|
62 |
$data = array(
|
67 |
'class' => 'scalable postnl-button',
|
68 |
);
|
69 |
|
70 |
+
$buttonBlock->setData($data);
|
71 |
+
$html = $buttonBlock->toHtml();
|
72 |
|
73 |
return $html;
|
74 |
}
|
82 |
{
|
83 |
return parent::render($element);
|
84 |
}
|
85 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_MatrixrateImport
|
@@ -56,4 +56,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_MatrixrateImport
|
|
56 |
|
57 |
return $html;
|
58 |
}
|
59 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_MatrixrateImport
|
56 |
|
57 |
return $html;
|
58 |
}
|
59 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Obscure
|
@@ -87,4 +87,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Obscure
|
|
87 |
|
88 |
return $attributes;
|
89 |
}
|
90 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Obscure
|
87 |
|
88 |
return $attributes;
|
89 |
}
|
90 |
+
}
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_OscDeliveryDateActive
|
40 |
+
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Hidden
|
41 |
+
{
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Get whether OSC is installed and enabled and Google places is active.
|
45 |
+
*
|
46 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
47 |
+
*
|
48 |
+
* @return int
|
49 |
+
*/
|
50 |
+
protected function _getValue(Varien_Data_Form_Element_Abstract $element)
|
51 |
+
{
|
52 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
53 |
+
$helper = Mage::helper('postnl/addressValidation');
|
54 |
+
$extensionEnabled = $helper->checkOscDeliveryDateActive(Mage_Core_Model_App::ADMIN_STORE_ID);
|
55 |
+
|
56 |
+
return (int) $extensionEnabled;
|
57 |
+
}
|
58 |
+
}
|
@@ -33,8 +33,10 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
|
|
|
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_PackingSlipItemColumns
|
40 |
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
@@ -49,13 +51,15 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_PackingSlipItemColumns
|
|
49 |
*/
|
50 |
public function __construct()
|
51 |
{
|
|
|
|
|
52 |
$this->addColumn(
|
53 |
'field',
|
54 |
array(
|
55 |
'label' => $this->__('Field'),
|
56 |
'style' => 'width:120px',
|
57 |
'type' => 'select',
|
58 |
-
'options' =>
|
59 |
'class' => 'required-entry validate-select',
|
60 |
)
|
61 |
);
|
@@ -131,6 +135,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_PackingSlipItemColumns
|
|
131 |
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
132 |
|
133 |
if ($column['renderer']) {
|
|
|
134 |
return $column['renderer']->setInputName($inputName)
|
135 |
->setColumnName($columnName)
|
136 |
->setColumn($column)
|
@@ -172,4 +177,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_PackingSlipItemColumns
|
|
172 |
|
173 |
return $html;
|
174 |
}
|
175 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*
|
39 |
+
* @method Varien_Data_Form_Element_Abstract getElement()
|
40 |
*/
|
41 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_PackingSlipItemColumns
|
42 |
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
51 |
*/
|
52 |
public function __construct()
|
53 |
{
|
54 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_PackingSlipItemFields $sourceModel */
|
55 |
+
$sourceModel = Mage::getModel('postnl_core/system_config_source_packingSlipItemFields');
|
56 |
$this->addColumn(
|
57 |
'field',
|
58 |
array(
|
59 |
'label' => $this->__('Field'),
|
60 |
'style' => 'width:120px',
|
61 |
'type' => 'select',
|
62 |
+
'options' => $sourceModel->toOptionArray(),
|
63 |
'class' => 'required-entry validate-select',
|
64 |
)
|
65 |
);
|
135 |
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
136 |
|
137 |
if ($column['renderer']) {
|
138 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
139 |
return $column['renderer']->setInputName($inputName)
|
140 |
->setColumnName($columnName)
|
141 |
->setColumn($column)
|
177 |
|
178 |
return $html;
|
179 |
}
|
180 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_PostcodeNlExtensionActive
|
@@ -48,9 +48,10 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_PostcodeNlExtensionAct
|
|
48 |
*/
|
49 |
protected function _getValue(Varien_Data_Form_Element_Abstract $element)
|
50 |
{
|
51 |
-
|
52 |
-
|
|
|
53 |
|
54 |
return (int) $extensionEnabled;
|
55 |
}
|
56 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_PostcodeNlExtensionActive
|
48 |
*/
|
49 |
protected function _getValue(Varien_Data_Form_Element_Abstract $element)
|
50 |
{
|
51 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
52 |
+
$helper = Mage::helper('postnl/addressValidation');
|
53 |
+
$extensionEnabled = $helper->checkPostcodeNlExtensionActive(Mage_Core_Model_App::ADMIN_STORE_ID);
|
54 |
|
55 |
return (int) $extensionEnabled;
|
56 |
}
|
57 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method string getValue()
|
@@ -136,6 +136,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Radios extends Varien_
|
|
136 |
. $option['label']
|
137 |
. '</label>';
|
138 |
} else if ($option instanceof Varien_Object) {
|
|
|
139 |
$html .= 'id="'
|
140 |
. $this->getHtmlId()
|
141 |
. $option->getValue()
|
@@ -150,12 +151,14 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Radios extends Varien_
|
|
150 |
)
|
151 |
);
|
152 |
|
|
|
153 |
if (in_array($option->getValue(), $selected)) {
|
154 |
$html .= ' checked="checked"';
|
155 |
}
|
156 |
|
157 |
$html .= ' />';
|
158 |
|
|
|
159 |
$html .= '<label class="inline" for="'
|
160 |
. $this->getHtmlId()
|
161 |
. $option->getValue()
|
@@ -168,4 +171,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Radios extends Varien_
|
|
168 |
|
169 |
return $html;
|
170 |
}
|
171 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method string getValue()
|
136 |
. $option['label']
|
137 |
. '</label>';
|
138 |
} else if ($option instanceof Varien_Object) {
|
139 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
140 |
$html .= 'id="'
|
141 |
. $this->getHtmlId()
|
142 |
. $option->getValue()
|
151 |
)
|
152 |
);
|
153 |
|
154 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
155 |
if (in_array($option->getValue(), $selected)) {
|
156 |
$html .= ' checked="checked"';
|
157 |
}
|
158 |
|
159 |
$html .= ' />';
|
160 |
|
161 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
162 |
$html .= '<label class="inline" for="'
|
163 |
. $this->getHtmlId()
|
164 |
. $option->getValue()
|
171 |
|
172 |
return $html;
|
173 |
}
|
174 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SplitAddressCheck
|
@@ -70,6 +70,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SplitAddressCheck
|
|
70 |
$store = $request->getparam('store');
|
71 |
$storeId = Mage::app()->getStore($store)->getId();
|
72 |
} elseif ($request->getParam('website')) {
|
|
|
73 |
$website = Mage::getModel('core/website')->load($request->getparam('website'), 'code');
|
74 |
$store = $website->getDefaultStore();
|
75 |
$storeId = $store->getId();
|
@@ -77,6 +78,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SplitAddressCheck
|
|
77 |
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
78 |
}
|
79 |
|
|
|
80 |
$helper = Mage::helper('postnl/addressValidation');
|
81 |
if ($helper->isPostcodeCheckEnabled($storeId)) {
|
82 |
return true;
|
@@ -94,7 +96,9 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SplitAddressCheck
|
|
94 |
*/
|
95 |
protected function _toHtml()
|
96 |
{
|
97 |
-
|
|
|
|
|
98 |
|
99 |
if (!empty($hiddenNotifications['split_address_warning'])) {
|
100 |
return '';
|
@@ -102,4 +106,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SplitAddressCheck
|
|
102 |
|
103 |
return parent::_toHtml();
|
104 |
}
|
105 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SplitAddressCheck
|
70 |
$store = $request->getparam('store');
|
71 |
$storeId = Mage::app()->getStore($store)->getId();
|
72 |
} elseif ($request->getParam('website')) {
|
73 |
+
/** @var Mage_Core_Model_Website $website */
|
74 |
$website = Mage::getModel('core/website')->load($request->getparam('website'), 'code');
|
75 |
$store = $website->getDefaultStore();
|
76 |
$storeId = $store->getId();
|
78 |
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
79 |
}
|
80 |
|
81 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
82 |
$helper = Mage::helper('postnl/addressValidation');
|
83 |
if ($helper->isPostcodeCheckEnabled($storeId)) {
|
84 |
return true;
|
96 |
*/
|
97 |
protected function _toHtml()
|
98 |
{
|
99 |
+
/** @var TIG_PostNL_Helper_Adminhtml $helper */
|
100 |
+
$helper = Mage::helper('postnl/adminhtml');
|
101 |
+
$hiddenNotifications = $helper->getHiddenNotifications();
|
102 |
|
103 |
if (!empty($hiddenNotifications['split_address_warning'])) {
|
104 |
return '';
|
106 |
|
107 |
return parent::_toHtml();
|
108 |
}
|
109 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SupportTab
|
@@ -53,6 +53,8 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SupportTab
|
|
53 |
const INSTALLATION_MANUAL_URL_XPATH = 'postnl/general/installation_manual_url';
|
54 |
const USER_GUIDE_URL_XPATH = 'postnl/general/user_guide_url';
|
55 |
const KB_URL_XPATH = 'postnl/general/kb_url';
|
|
|
|
|
56 |
|
57 |
/**
|
58 |
* Template file used
|
@@ -66,11 +68,91 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SupportTab
|
|
66 |
*/
|
67 |
public function getVersion()
|
68 |
{
|
69 |
-
$
|
|
|
|
|
70 |
|
71 |
return $version;
|
72 |
}
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
/**
|
75 |
* @return string
|
76 |
*/
|
@@ -121,12 +203,34 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SupportTab
|
|
121 |
return $url;
|
122 |
}
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
/**
|
125 |
* @return string
|
126 |
*/
|
127 |
public function getChangelogUrl()
|
128 |
{
|
129 |
-
|
|
|
|
|
130 |
|
131 |
return $url;
|
132 |
}
|
@@ -140,4 +244,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SupportTab
|
|
140 |
|
141 |
return $url;
|
142 |
}
|
143 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SupportTab
|
53 |
const INSTALLATION_MANUAL_URL_XPATH = 'postnl/general/installation_manual_url';
|
54 |
const USER_GUIDE_URL_XPATH = 'postnl/general/user_guide_url';
|
55 |
const KB_URL_XPATH = 'postnl/general/kb_url';
|
56 |
+
const POSTNL_DOCUMENTATION_URL = 'postnl/general/postnl_documentation_url';
|
57 |
+
const CIT_SERVICEDESK_EMAIL = 'postnl/general/cit_servicedesk_email';
|
58 |
|
59 |
/**
|
60 |
* Template file used
|
68 |
*/
|
69 |
public function getVersion()
|
70 |
{
|
71 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
72 |
+
$helper = Mage::helper('postnl');
|
73 |
+
$version = $helper->getModuleVersion();
|
74 |
|
75 |
return $version;
|
76 |
}
|
77 |
|
78 |
+
/**
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function getStability()
|
82 |
+
{
|
83 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
84 |
+
$helper = Mage::helper('postnl');
|
85 |
+
$version = $helper->getModuleStability();
|
86 |
+
|
87 |
+
return $version;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @return array|Mage_Core_Model_Config_Element|string|false
|
92 |
+
*/
|
93 |
+
public function getCompatibility()
|
94 |
+
{
|
95 |
+
$postnlConfig = Mage::app()->getConfig()->getNode('tig/compatibility/postnl');
|
96 |
+
|
97 |
+
if ($postnlConfig) {
|
98 |
+
$postnlConfig = $postnlConfig->asArray();
|
99 |
+
}
|
100 |
+
|
101 |
+
return $postnlConfig;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @param string $extensionKey
|
106 |
+
*
|
107 |
+
* @return string
|
108 |
+
*/
|
109 |
+
public function getCompatibleExtensionLabel($extensionKey)
|
110 |
+
{
|
111 |
+
switch ($extensionKey) {
|
112 |
+
case 'Idev_OneStepCheckout':
|
113 |
+
$label = "Idev's OneStepCheckout";
|
114 |
+
break;
|
115 |
+
case 'Bpost_ShippingManager':
|
116 |
+
$label = "Bpost Shipping Manager";
|
117 |
+
break;
|
118 |
+
case 'GoMage_Checkout':
|
119 |
+
$label = "GoMage's Checkout";
|
120 |
+
break;
|
121 |
+
case 'Picqer_PostNL':
|
122 |
+
$label = "Picqer's PostNL add-on";
|
123 |
+
break;
|
124 |
+
default:
|
125 |
+
$label = $extensionKey;
|
126 |
+
break;
|
127 |
+
}
|
128 |
+
|
129 |
+
return $label;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @param $versions
|
134 |
+
*
|
135 |
+
* @return string
|
136 |
+
*/
|
137 |
+
public function formatCompatibleVersion($versions)
|
138 |
+
{
|
139 |
+
$versionString = '';
|
140 |
+
$versions = explode(',', $versions);
|
141 |
+
|
142 |
+
$count = count($versions);
|
143 |
+
foreach (array_values($versions) as $index => $version) {
|
144 |
+
if ($index > 0 && $index < $count) {
|
145 |
+
$versionString .= ', ';
|
146 |
+
} elseif ($index > 0) {
|
147 |
+
$versionString .= ' & ';
|
148 |
+
}
|
149 |
+
|
150 |
+
$versionString .= 'v' . $version;
|
151 |
+
}
|
152 |
+
|
153 |
+
return $versionString;
|
154 |
+
}
|
155 |
+
|
156 |
/**
|
157 |
* @return string
|
158 |
*/
|
203 |
return $url;
|
204 |
}
|
205 |
|
206 |
+
/**
|
207 |
+
* @return string
|
208 |
+
*/
|
209 |
+
public function getPostnlDocumentationUrl()
|
210 |
+
{
|
211 |
+
$url = Mage::getStoreConfig(self::POSTNL_DOCUMENTATION_URL, Mage_Core_Model_App::ADMIN_STORE_ID);
|
212 |
+
|
213 |
+
return $url;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* @return string
|
218 |
+
*/
|
219 |
+
public function getCitServicedeskEmail()
|
220 |
+
{
|
221 |
+
$url = Mage::getStoreConfig(self::CIT_SERVICEDESK_EMAIL, Mage_Core_Model_App::ADMIN_STORE_ID);
|
222 |
+
|
223 |
+
return $url;
|
224 |
+
}
|
225 |
+
|
226 |
/**
|
227 |
* @return string
|
228 |
*/
|
229 |
public function getChangelogUrl()
|
230 |
{
|
231 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
232 |
+
$helper = Mage::helper('postnl');
|
233 |
+
$url = $helper->getChangelogUrl();
|
234 |
|
235 |
return $url;
|
236 |
}
|
244 |
|
245 |
return $url;
|
246 |
}
|
247 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateExport
|
@@ -53,8 +53,10 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateExport
|
|
53 |
'website' => $buttonBlock->getRequest()->getParam('website')
|
54 |
);
|
55 |
|
|
|
|
|
56 |
$onClick = 'setLocation(\''
|
57 |
-
.
|
58 |
. 'conditionName/\' + $(\'carriers_postnl_condition_name\').value + \'/tablerates.csv\' )';
|
59 |
|
60 |
$data = array(
|
@@ -65,7 +67,8 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateExport
|
|
65 |
'class' => 'scalable postnl-button',
|
66 |
);
|
67 |
|
68 |
-
$
|
|
|
69 |
|
70 |
return $html;
|
71 |
}
|
@@ -79,4 +82,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateExport
|
|
79 |
{
|
80 |
return parent::render($element);
|
81 |
}
|
82 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateExport
|
53 |
'website' => $buttonBlock->getRequest()->getParam('website')
|
54 |
);
|
55 |
|
56 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
57 |
+
$helper = Mage::helper('adminhtml');
|
58 |
$onClick = 'setLocation(\''
|
59 |
+
. $helper->getUrl("adminhtml/postnlAdminhtml_config/exportTablerates", $params)
|
60 |
. 'conditionName/\' + $(\'carriers_postnl_condition_name\').value + \'/tablerates.csv\' )';
|
61 |
|
62 |
$data = array(
|
67 |
'class' => 'scalable postnl-button',
|
68 |
);
|
69 |
|
70 |
+
$buttonBlock->setData($data);
|
71 |
+
$html = $buttonBlock->toHtml();
|
72 |
|
73 |
return $html;
|
74 |
}
|
82 |
{
|
83 |
return parent::render($element);
|
84 |
}
|
85 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateImport
|
@@ -87,4 +87,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateImport
|
|
87 |
|
88 |
return $html;
|
89 |
}
|
90 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateImport
|
87 |
|
88 |
return $html;
|
89 |
}
|
90 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Varien_Data_Form_Element_Abstract getElement()
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Varien_Data_Form_Element_Abstract getElement()
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Mage_Core_Model_Config_Element getElement()
|
@@ -46,11 +46,15 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Tooltip_HourMinute ext
|
|
46 |
protected function _toHtml()
|
47 |
{
|
48 |
$element = $this->getElement();
|
|
|
|
|
|
|
|
|
49 |
$tooltipText = $this->__(
|
50 |
$element->tooltip,
|
51 |
-
|
52 |
);
|
53 |
|
54 |
return $tooltipText;
|
55 |
}
|
56 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Mage_Core_Model_Config_Element getElement()
|
46 |
protected function _toHtml()
|
47 |
{
|
48 |
$element = $this->getElement();
|
49 |
+
|
50 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
51 |
+
$helper = Mage::helper('postnl');
|
52 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
53 |
$tooltipText = $this->__(
|
54 |
$element->tooltip,
|
55 |
+
$helper->getStoreTimeZone(Mage_Core_Model_App::ADMIN_STORE_ID)
|
56 |
);
|
57 |
|
58 |
return $tooltipText;
|
59 |
}
|
60 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton setElement(Varien_Data_Form_Element_Abstract $value)
|
@@ -56,6 +56,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_UninstallButton
|
|
56 |
$warningTitle = 'Uninstall PostNL Extension';
|
57 |
|
58 |
$warningMessage = array();
|
|
|
59 |
$warningMessage[] = "<br><div class=\'module-message warning\'><h4>" . $this->__('Warning: this action cannot be undone!') ."</h4></div>";
|
60 |
$warningMessage[] = $this->__('The following changes will be made:');
|
61 |
$warningMessage[] = "<br>- " . $this->__('The extension will be disabled in the app/etc/modules/TIG_PostNL.xml file');
|
@@ -74,6 +75,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_UninstallButton
|
|
74 |
$confirmTitle = $this->__($warningTitle);
|
75 |
$uninstallUrl = $this->getUrl('adminhtml/postnlAdminhtml_extensionControl/uninstall');
|
76 |
|
|
|
77 |
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
78 |
->setId($element->getHtmlId())
|
79 |
->setType('button')
|
@@ -95,6 +97,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_UninstallButton
|
|
95 |
*/
|
96 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
97 |
{
|
|
|
98 |
$element->setScopeLabel('');
|
99 |
return parent::render($element);
|
100 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton setElement(Varien_Data_Form_Element_Abstract $value)
|
56 |
$warningTitle = 'Uninstall PostNL Extension';
|
57 |
|
58 |
$warningMessage = array();
|
59 |
+
/** @noinspection HtmlUnknownAttribute */
|
60 |
$warningMessage[] = "<br><div class=\'module-message warning\'><h4>" . $this->__('Warning: this action cannot be undone!') ."</h4></div>";
|
61 |
$warningMessage[] = $this->__('The following changes will be made:');
|
62 |
$warningMessage[] = "<br>- " . $this->__('The extension will be disabled in the app/etc/modules/TIG_PostNL.xml file');
|
75 |
$confirmTitle = $this->__($warningTitle);
|
76 |
$uninstallUrl = $this->getUrl('adminhtml/postnlAdminhtml_extensionControl/uninstall');
|
77 |
|
78 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
79 |
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
80 |
->setId($element->getHtmlId())
|
81 |
->setType('button')
|
97 |
*/
|
98 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
99 |
{
|
100 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
101 |
$element->setScopeLabel('');
|
102 |
return parent::render($element);
|
103 |
}
|
@@ -33,8 +33,10 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
|
|
|
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ValidateButton
|
40 |
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
@@ -51,6 +53,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ValidateButton
|
|
51 |
{
|
52 |
$this->setElement($element);
|
53 |
|
|
|
54 |
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
55 |
->setId($element->getHtmlId())
|
56 |
->setType('button')
|
@@ -72,6 +75,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ValidateButton
|
|
72 |
*/
|
73 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
74 |
{
|
|
|
75 |
$element->unsScope()
|
76 |
->unsCanUseWebsiteValue()
|
77 |
->unsCanUseDefaultValue();
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*
|
39 |
+
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ValidateButton setElement(Varien_Data_Form_Element_Abstract $element)
|
40 |
*/
|
41 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ValidateButton
|
42 |
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
53 |
{
|
54 |
$this->setElement($element);
|
55 |
|
56 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
57 |
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
58 |
->setId($element->getHtmlId())
|
59 |
->setType('button')
|
75 |
*/
|
76 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
77 |
{
|
78 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
79 |
$element->unsScope()
|
80 |
->unsCanUseWebsiteValue()
|
81 |
->unsCanUseDefaultValue();
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_WarningBox
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_WarningBox
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton setElement(Varien_Data_Form_Element_Abstract $value)
|
@@ -53,6 +53,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_WizardSaveButton
|
|
53 |
{
|
54 |
$this->setElement($element);
|
55 |
|
|
|
56 |
$elementOriginalData = $element->getOriginalData();
|
57 |
|
58 |
/**
|
@@ -69,6 +70,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_WizardSaveButton
|
|
69 |
* @var Varien_Data_Form_Element_Fieldset $container
|
70 |
*/
|
71 |
$currentStepRel = '';
|
|
|
72 |
$container = $element->getContainer();
|
73 |
if ($container) {
|
74 |
$currentStepRel = $container->getHtmlId();
|
@@ -82,6 +84,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_WizardSaveButton
|
|
82 |
$button = $this->getLayout()
|
83 |
->createBlock('adminhtml/widget_button');
|
84 |
|
|
|
85 |
$html = $button->setType('button')
|
86 |
->setId($element->getHtmlId())
|
87 |
->setClass('scalable postnl-button')
|
@@ -104,16 +107,20 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_WizardSaveButton
|
|
104 |
{
|
105 |
$html = '<td class="label"></td>';
|
106 |
|
|
|
107 |
if ($element->getTooltip()) {
|
108 |
$html .= '<td class="value with-tooltip">';
|
109 |
$html .= $this->_getElementHtml($element);
|
|
|
110 |
$html .= '<div class="field-tooltip"><div>' . $element->getTooltip() . '</div></div>';
|
111 |
} else {
|
112 |
$html .= '<td class="value">';
|
113 |
$html .= $this->_getElementHtml($element);
|
114 |
};
|
115 |
|
|
|
116 |
if ($element->getComment()) {
|
|
|
117 |
$html.= '<p class="note"><span>'.$element->getComment().'</span></p>';
|
118 |
}
|
119 |
|
@@ -122,8 +129,10 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_WizardSaveButton
|
|
122 |
$html.= '<td class="scope-label"></td>';
|
123 |
|
124 |
$html.= '<td class="">';
|
|
|
125 |
if ($element->getHint()) {
|
126 |
$html.= '<div class="hint" >';
|
|
|
127 |
$html.= '<div style="display: none;">' . $element->getHint() . '</div>';
|
128 |
$html.= '</div>';
|
129 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton setElement(Varien_Data_Form_Element_Abstract $value)
|
53 |
{
|
54 |
$this->setElement($element);
|
55 |
|
56 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
57 |
$elementOriginalData = $element->getOriginalData();
|
58 |
|
59 |
/**
|
70 |
* @var Varien_Data_Form_Element_Fieldset $container
|
71 |
*/
|
72 |
$currentStepRel = '';
|
73 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
74 |
$container = $element->getContainer();
|
75 |
if ($container) {
|
76 |
$currentStepRel = $container->getHtmlId();
|
84 |
$button = $this->getLayout()
|
85 |
->createBlock('adminhtml/widget_button');
|
86 |
|
87 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
88 |
$html = $button->setType('button')
|
89 |
->setId($element->getHtmlId())
|
90 |
->setClass('scalable postnl-button')
|
107 |
{
|
108 |
$html = '<td class="label"></td>';
|
109 |
|
110 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
111 |
if ($element->getTooltip()) {
|
112 |
$html .= '<td class="value with-tooltip">';
|
113 |
$html .= $this->_getElementHtml($element);
|
114 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
115 |
$html .= '<div class="field-tooltip"><div>' . $element->getTooltip() . '</div></div>';
|
116 |
} else {
|
117 |
$html .= '<td class="value">';
|
118 |
$html .= $this->_getElementHtml($element);
|
119 |
};
|
120 |
|
121 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
122 |
if ($element->getComment()) {
|
123 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
124 |
$html.= '<p class="note"><span>'.$element->getComment().'</span></p>';
|
125 |
}
|
126 |
|
129 |
$html.= '<td class="scope-label"></td>';
|
130 |
|
131 |
$html.= '<td class="">';
|
132 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
133 |
if ($element->getHint()) {
|
134 |
$html.= '<div class="hint" >';
|
135 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
136 |
$html.= '<div style="display: none;">' . $element->getHint() . '</div>';
|
137 |
$html.= '</div>';
|
138 |
}
|
@@ -33,10 +33,13 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* This entire class is extended from Magento's core class for backwards compatibility on Magento 1.6.
|
|
|
|
|
|
|
40 |
*/
|
41 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
42 |
{
|
@@ -49,6 +52,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
49 |
*/
|
50 |
protected function _getHeaderCommentHtml($element)
|
51 |
{
|
|
|
52 |
$comment = $element->getComment();
|
53 |
if (!$comment) {
|
54 |
return '';
|
@@ -74,7 +78,9 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
74 |
$this->setElement($element);
|
75 |
$html = $this->_getHeaderHtml($element);
|
76 |
|
|
|
77 |
foreach ($element->getSortedElements() as $field) {
|
|
|
78 |
$html.= $field->toHtml();
|
79 |
}
|
80 |
|
@@ -91,6 +97,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
91 |
*/
|
92 |
protected function _getHeaderHtml($element)
|
93 |
{
|
|
|
94 |
if ($element->getIsNested()) {
|
95 |
$html = '<tr class="nested"><td colspan="4"><div class="' . $this->_getFrontendClass($element) . '">';
|
96 |
} else {
|
@@ -102,6 +109,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
102 |
$html .= '<input id="'.$element->getHtmlId() . '-state" name="config_state[' . $element->getId()
|
103 |
. ']" type="hidden" value="' . (int)$this->_getCollapseState($element) . '" />';
|
104 |
$html .= '<fieldset class="' . $this->_getFieldsetCss($element) . '" id="' . $element->getHtmlId() . '">';
|
|
|
105 |
$html .= '<legend>' . $element->getLegend() . '</legend>';
|
106 |
|
107 |
$html .= $this->_getHeaderCommentHtml($element);
|
@@ -124,6 +132,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
124 |
*/
|
125 |
protected function _getFrontendClass($element)
|
126 |
{
|
|
|
127 |
$frontendClass = (string)$this->getGroup($element)->frontend_class;
|
128 |
return 'section-config' . (empty($frontendClass) ? '' : (' ' . $frontendClass));
|
129 |
}
|
@@ -139,7 +148,9 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
139 |
if (is_null($element)) {
|
140 |
$element = $this->getElement();
|
141 |
}
|
|
|
142 |
if ($element && $element->getGroup() instanceof Mage_Core_Model_Config_Element) {
|
|
|
143 |
return $element->getGroup();
|
144 |
}
|
145 |
|
@@ -154,6 +165,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
154 |
*/
|
155 |
protected function _getHeaderTitleHtml($element)
|
156 |
{
|
|
|
157 |
return '<div class="entry-edit-head collapseable" ><a id="' . $element->getHtmlId()
|
158 |
. '-head" rel="' . $element->getHtmlId() . '-head" href="#" onclick="Fieldset.toggleCollapse(\''
|
159 |
. $element->getHtmlId() . '\', \'' . $this->getUrl('*/*/state') . '\'); return false;">'
|
@@ -168,6 +180,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
168 |
*/
|
169 |
protected function _getFieldsetCss($element = null)
|
170 |
{
|
|
|
171 |
$configCss = (string)$this->getGroup($element)->fieldset_css;
|
172 |
return 'config collapseable' . ($configCss ? ' ' . $configCss : '');
|
173 |
}
|
@@ -185,6 +198,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
185 |
$html = '</tbody></table>';
|
186 |
$html .= '</fieldset>' . $this->_getExtraJs($element, $tooltipsExist);
|
187 |
|
|
|
188 |
if ($element->getIsNested()) {
|
189 |
$html .= '</div></td></tr>';
|
190 |
} else {
|
@@ -206,7 +220,10 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
206 |
{
|
207 |
$id = $element->getHtmlId();
|
208 |
$js = "Fieldset.applyCollapse('{$id}');";
|
209 |
-
|
|
|
|
|
|
|
210 |
}
|
211 |
|
212 |
/**
|
@@ -217,10 +234,15 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
217 |
*/
|
218 |
protected function _getCollapseState($element)
|
219 |
{
|
|
|
220 |
if ($element->getExpanded() !== null) {
|
221 |
return 1;
|
222 |
}
|
223 |
-
|
|
|
|
|
|
|
|
|
224 |
if (isset($extra['configState'][$element->getId()])) {
|
225 |
return $extra['configState'][$element->getId()];
|
226 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* This entire class is extended from Magento's core class for backwards compatibility on Magento 1.6.
|
40 |
+
*
|
41 |
+
* @method Varien_Data_Form_Element_Abstract getElement()
|
42 |
+
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset setElement(Varien_Data_Form_Element_Abstract $element)
|
43 |
*/
|
44 |
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
45 |
{
|
52 |
*/
|
53 |
protected function _getHeaderCommentHtml($element)
|
54 |
{
|
55 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
56 |
$comment = $element->getComment();
|
57 |
if (!$comment) {
|
58 |
return '';
|
78 |
$this->setElement($element);
|
79 |
$html = $this->_getHeaderHtml($element);
|
80 |
|
81 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
82 |
foreach ($element->getSortedElements() as $field) {
|
83 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
84 |
$html.= $field->toHtml();
|
85 |
}
|
86 |
|
97 |
*/
|
98 |
protected function _getHeaderHtml($element)
|
99 |
{
|
100 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
101 |
if ($element->getIsNested()) {
|
102 |
$html = '<tr class="nested"><td colspan="4"><div class="' . $this->_getFrontendClass($element) . '">';
|
103 |
} else {
|
109 |
$html .= '<input id="'.$element->getHtmlId() . '-state" name="config_state[' . $element->getId()
|
110 |
. ']" type="hidden" value="' . (int)$this->_getCollapseState($element) . '" />';
|
111 |
$html .= '<fieldset class="' . $this->_getFieldsetCss($element) . '" id="' . $element->getHtmlId() . '">';
|
112 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
113 |
$html .= '<legend>' . $element->getLegend() . '</legend>';
|
114 |
|
115 |
$html .= $this->_getHeaderCommentHtml($element);
|
132 |
*/
|
133 |
protected function _getFrontendClass($element)
|
134 |
{
|
135 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
136 |
$frontendClass = (string)$this->getGroup($element)->frontend_class;
|
137 |
return 'section-config' . (empty($frontendClass) ? '' : (' ' . $frontendClass));
|
138 |
}
|
148 |
if (is_null($element)) {
|
149 |
$element = $this->getElement();
|
150 |
}
|
151 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
152 |
if ($element && $element->getGroup() instanceof Mage_Core_Model_Config_Element) {
|
153 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
154 |
return $element->getGroup();
|
155 |
}
|
156 |
|
165 |
*/
|
166 |
protected function _getHeaderTitleHtml($element)
|
167 |
{
|
168 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
169 |
return '<div class="entry-edit-head collapseable" ><a id="' . $element->getHtmlId()
|
170 |
. '-head" rel="' . $element->getHtmlId() . '-head" href="#" onclick="Fieldset.toggleCollapse(\''
|
171 |
. $element->getHtmlId() . '\', \'' . $this->getUrl('*/*/state') . '\'); return false;">'
|
180 |
*/
|
181 |
protected function _getFieldsetCss($element = null)
|
182 |
{
|
183 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
184 |
$configCss = (string)$this->getGroup($element)->fieldset_css;
|
185 |
return 'config collapseable' . ($configCss ? ' ' . $configCss : '');
|
186 |
}
|
198 |
$html = '</tbody></table>';
|
199 |
$html .= '</fieldset>' . $this->_getExtraJs($element, $tooltipsExist);
|
200 |
|
201 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
202 |
if ($element->getIsNested()) {
|
203 |
$html .= '</div></td></tr>';
|
204 |
} else {
|
220 |
{
|
221 |
$id = $element->getHtmlId();
|
222 |
$js = "Fieldset.applyCollapse('{$id}');";
|
223 |
+
|
224 |
+
/** @var Mage_Adminhtml_Helper_Js $helper */
|
225 |
+
$helper = Mage::helper('adminhtml/js');
|
226 |
+
return $helper->getScript($js);
|
227 |
}
|
228 |
|
229 |
/**
|
234 |
*/
|
235 |
protected function _getCollapseState($element)
|
236 |
{
|
237 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
238 |
if ($element->getExpanded() !== null) {
|
239 |
return 1;
|
240 |
}
|
241 |
+
|
242 |
+
/** @var Mage_Admin_Model_Session $session */
|
243 |
+
$session = Mage::getSingleton('admin/session');
|
244 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
245 |
+
$extra = $session->getUser()->getExtra();
|
246 |
if (isset($extra['configState'][$element->getId()])) {
|
247 |
return $extra['configState'][$element->getId()];
|
248 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Js extends TIG_PostNL_Block_Adminhtml_Template
|
@@ -83,6 +83,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Js extends TIG_PostNL_Block_Admin
|
|
83 |
/**
|
84 |
* For Magento 1.6 and 1.11 we need to add another css file.
|
85 |
*/
|
|
|
86 |
$helper = Mage::helper('postnl');
|
87 |
$isEnterprise = $helper->isEnterprise();
|
88 |
|
@@ -116,7 +117,12 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Js extends TIG_PostNL_Block_Admin
|
|
116 |
/**
|
117 |
* Get the current admin user and it's saved extra data.
|
118 |
*/
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
120 |
$extra = $adminUser->getExtra();
|
121 |
|
122 |
/**
|
@@ -192,4 +198,4 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Js extends TIG_PostNL_Block_Admin
|
|
192 |
|
193 |
return parent::_toHtml();
|
194 |
}
|
195 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_System_Config_Js extends TIG_PostNL_Block_Adminhtml_Template
|
83 |
/**
|
84 |
* For Magento 1.6 and 1.11 we need to add another css file.
|
85 |
*/
|
86 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
87 |
$helper = Mage::helper('postnl');
|
88 |
$isEnterprise = $helper->isEnterprise();
|
89 |
|
117 |
/**
|
118 |
* Get the current admin user and it's saved extra data.
|
119 |
*/
|
120 |
+
|
121 |
+
/** @var Mage_Admin_Model_Session $session */
|
122 |
+
$session = Mage::getSingleton('admin/session');
|
123 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
124 |
+
/** @var Mage_Admin_Model_User $adminUser */
|
125 |
+
$adminUser = $session->getUser();
|
126 |
$extra = $adminUser->getExtra();
|
127 |
|
128 |
/**
|
198 |
|
199 |
return parent::_toHtml();
|
200 |
}
|
201 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Block_Adminhtml_Template extends Mage_Adminhtml_Block_Abstract
|
@@ -57,4 +57,4 @@ abstract class TIG_PostNL_Block_Adminhtml_Template extends Mage_Adminhtml_Block_
|
|
57 |
Mage::dispatchEvent($this->_eventPrefix . '_to_html_after');
|
58 |
return $html;
|
59 |
}
|
60 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Block_Adminhtml_Template extends Mage_Adminhtml_Block_Abstract
|
57 |
Mage::dispatchEvent($this->_eventPrefix . '_to_html_after');
|
58 |
return $html;
|
59 |
}
|
60 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_UpgradeNotification extends TIG_PostNL_Block_Adminhtml_Template
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_UpgradeNotification extends TIG_PostNL_Block_Adminhtml_Template
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Form element dependencies mapper
|
@@ -67,10 +67,13 @@ class TIG_PostNL_Block_Adminhtml_Widget_Form_Element_Dependence
|
|
67 |
if (!$this->_depends) {
|
68 |
return '';
|
69 |
}
|
|
|
|
|
|
|
70 |
return '<script type="text/javascript">'
|
71 |
. 'var formElementDependenceController = new FormElementDependenceController('
|
72 |
. $this->_getDependsJson()
|
73 |
-
. ($this->_configOptions ? ', ' .
|
74 |
. '); </script>';
|
75 |
}
|
76 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Form element dependencies mapper
|
67 |
if (!$this->_depends) {
|
68 |
return '';
|
69 |
}
|
70 |
+
|
71 |
+
/** @var Mage_Core_Helper_Data $helper */
|
72 |
+
$helper = Mage::helper('core');
|
73 |
return '<script type="text/javascript">'
|
74 |
. 'var formElementDependenceController = new FormElementDependenceController('
|
75 |
. $this->_getDependsJson()
|
76 |
+
. ($this->_configOptions ? ', ' . $helper->jsonEncode($this->_configOptions) : '')
|
77 |
. '); </script>';
|
78 |
}
|
79 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Filter_ConfirmDate
|
@@ -137,9 +137,9 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Filter_ConfirmDate
|
|
137 |
+ dimensionsButton.width + "px",
|
138 |
"top" : offset[1] + scrollOffset[1] + dimensionsButton.height + "px"
|
139 |
});
|
140 |
-
}
|
141 |
});
|
142 |
-
}
|
143 |
|
144 |
var confirmDateDatePicker = function() {
|
145 |
if ($("' . $this->_getHtmlId() . '").getValue() == "pick_date") {
|
@@ -175,7 +175,10 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Filter_ConfirmDate
|
|
175 |
if (is_array($value)) {
|
176 |
$value['datetime'] = true;
|
177 |
}
|
|
|
178 |
if (!empty($value['to']) && !$this->getColumn()->getFilterTime()) {
|
|
|
|
|
179 |
$datetimeTo = $value['to'];
|
180 |
|
181 |
//calculate end date considering timezone specification
|
@@ -237,4 +240,4 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Filter_ConfirmDate
|
|
237 |
$this->setData('value', $value);
|
238 |
return $this;
|
239 |
}
|
240 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Filter_ConfirmDate
|
137 |
+ dimensionsButton.width + "px",
|
138 |
"top" : offset[1] + scrollOffset[1] + dimensionsButton.height + "px"
|
139 |
});
|
140 |
+
}
|
141 |
});
|
142 |
+
}
|
143 |
|
144 |
var confirmDateDatePicker = function() {
|
145 |
if ($("' . $this->_getHtmlId() . '").getValue() == "pick_date") {
|
175 |
if (is_array($value)) {
|
176 |
$value['datetime'] = true;
|
177 |
}
|
178 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
179 |
if (!empty($value['to']) && !$this->getColumn()->getFilterTime()) {
|
180 |
+
/** @noinspection PhpUndefinedClassInspection */
|
181 |
+
/** @var Zend_Date $datetimeTo */
|
182 |
$datetimeTo = $value['to'];
|
183 |
|
184 |
//calculate end date considering timezone specification
|
240 |
$this->setData('value', $value);
|
241 |
return $this;
|
242 |
}
|
243 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
@@ -57,6 +57,8 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
|
57 |
*/
|
58 |
public function render(Varien_Object $row)
|
59 |
{
|
|
|
|
|
60 |
$actions = $this->getColumn()->getActions();
|
61 |
if (empty($actions) || !is_array($actions)) {
|
62 |
return ' ';
|
@@ -121,9 +123,11 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
|
121 |
/**
|
122 |
* If this is a PostNL action, but this shipment was not shipped using PosTNL, skip it
|
123 |
*/
|
|
|
|
|
124 |
if (isset($action['is_postnl'])
|
125 |
&& $action['is_postnl']
|
126 |
-
&&
|
127 |
) {
|
128 |
unset($action['is_postnl']);
|
129 |
return false;
|
@@ -143,7 +147,9 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
|
143 |
*/
|
144 |
protected function _checkDisableAction($row, $action)
|
145 |
{
|
|
|
146 |
$helper = Mage::helper('postnl/cif');
|
|
|
147 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
148 |
|
149 |
$euCountries = $helper->getEuCountries();
|
@@ -175,6 +181,19 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
|
175 |
return $action;
|
176 |
}
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
/**
|
179 |
* If this shipment uses a custom barcode it does not need to be confirmed.
|
180 |
*/
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
57 |
*/
|
58 |
public function render(Varien_Object $row)
|
59 |
{
|
60 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
61 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
62 |
$actions = $this->getColumn()->getActions();
|
63 |
if (empty($actions) || !is_array($actions)) {
|
64 |
return ' ';
|
123 |
/**
|
124 |
* If this is a PostNL action, but this shipment was not shipped using PosTNL, skip it
|
125 |
*/
|
126 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
127 |
+
$helper = Mage::helper('postnl/carrier');
|
128 |
if (isset($action['is_postnl'])
|
129 |
&& $action['is_postnl']
|
130 |
+
&& !$helper->isPostnlShippingMethod($shippingMethod)
|
131 |
) {
|
132 |
unset($action['is_postnl']);
|
133 |
return false;
|
147 |
*/
|
148 |
protected function _checkDisableAction($row, $action)
|
149 |
{
|
150 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
151 |
$helper = Mage::helper('postnl/cif');
|
152 |
+
/** @noinspection PhpParamsInspection */
|
153 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
154 |
|
155 |
$euCountries = $helper->getEuCountries();
|
181 |
return $action;
|
182 |
}
|
183 |
|
184 |
+
/**
|
185 |
+
* @todo remove this once PostNL has fixed the issue with manually confirming GlobalPack shipments.
|
186 |
+
*/
|
187 |
+
if (!in_array($countryId, $euCountries)) {
|
188 |
+
$message = $helper->__(
|
189 |
+
"You cannot manually confirm GlobalPack shipments. Please use the 'print label & confirm' massaction" .
|
190 |
+
" instead."
|
191 |
+
);
|
192 |
+
$action = $this->_disableAction($action, $message);
|
193 |
+
|
194 |
+
return $action;
|
195 |
+
}
|
196 |
+
|
197 |
/**
|
198 |
* If this shipment uses a custom barcode it does not need to be confirmed.
|
199 |
*/
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
@@ -62,7 +62,9 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
|
62 |
* The shipment was not shipped using PostNL
|
63 |
*/
|
64 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
65 |
-
|
|
|
|
|
66 |
return '';
|
67 |
}
|
68 |
|
@@ -71,6 +73,7 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
|
71 |
*
|
72 |
* @var $postnlShipmentClassName TIG_PostNL_Model_Core_Shipment
|
73 |
*/
|
|
|
74 |
$postnlShipmentClassName = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
75 |
if ($row->getData(self::CONFIRM_STATUS_COLUMN) == $postnlShipmentClassName::CONFIRM_STATUS_BUSPAKJE) {
|
76 |
return '';
|
@@ -79,6 +82,8 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
|
79 |
/**
|
80 |
* Check if any data is available.
|
81 |
*/
|
|
|
|
|
82 |
$value = $row->getData($this->getColumn()->getIndex());
|
83 |
if (!$value) {
|
84 |
$value = Mage::helper('postnl')->__('No barcode available.');
|
@@ -102,7 +107,7 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
|
102 |
'postcode' => $postcode,
|
103 |
);
|
104 |
|
105 |
-
$barcodeUrl =
|
106 |
|
107 |
$barcodeHtml = "<a href='{$barcodeUrl}' target='_blank'>{$value}</a>";
|
108 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
62 |
* The shipment was not shipped using PostNL
|
63 |
*/
|
64 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
65 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
66 |
+
$helper = Mage::helper('postnl/carrier');
|
67 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
68 |
return '';
|
69 |
}
|
70 |
|
73 |
*
|
74 |
* @var $postnlShipmentClassName TIG_PostNL_Model_Core_Shipment
|
75 |
*/
|
76 |
+
/** @noinspection PhpParamsInspection */
|
77 |
$postnlShipmentClassName = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
78 |
if ($row->getData(self::CONFIRM_STATUS_COLUMN) == $postnlShipmentClassName::CONFIRM_STATUS_BUSPAKJE) {
|
79 |
return '';
|
82 |
/**
|
83 |
* Check if any data is available.
|
84 |
*/
|
85 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
86 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
87 |
$value = $row->getData($this->getColumn()->getIndex());
|
88 |
if (!$value) {
|
89 |
$value = Mage::helper('postnl')->__('No barcode available.');
|
107 |
'postcode' => $postcode,
|
108 |
);
|
109 |
|
110 |
+
$barcodeUrl = $helper->getBarcodeUrl($value, $destinationData, false, true);
|
111 |
|
112 |
$barcodeHtml = "<a href='{$barcodeUrl}' target='_blank'>{$value}</a>";
|
113 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate
|
@@ -55,11 +55,16 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate
|
|
55 |
{
|
56 |
/** @var Mage_Sales_Model_Order $row */
|
57 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
58 |
-
|
|
|
|
|
59 |
return '';
|
60 |
}
|
61 |
|
|
|
62 |
$helper = Mage::helper('postnl/deliveryOptions');
|
|
|
|
|
63 |
$value = $row->getData($this->getColumn()->getIndex());
|
64 |
|
65 |
$value = new DateTime($value, new DateTimeZone('UTC'));
|
@@ -67,6 +72,8 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate
|
|
67 |
/**
|
68 |
* Update the row's value for the decorator later.
|
69 |
*/
|
|
|
|
|
70 |
$row->setData($this->getColumn()->getIndex(), $value->format('Y-m-d H:i:s'));
|
71 |
|
72 |
$adminTimeZone = $helper->getStoreTimeZone(Mage_Core_Model_App::ADMIN_STORE_ID, true);
|
@@ -123,22 +130,30 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate
|
|
123 |
*/
|
124 |
$format = $this->_getFormat();
|
125 |
|
126 |
-
$timeZone =
|
127 |
$value = $value->setTimezone($timeZone)->format('Y-m-d H:i:s');
|
128 |
try {
|
|
|
|
|
129 |
if($this->getColumn()->getGmtoffset()) {
|
130 |
$data = Mage::app()->getLocale()
|
131 |
->date($value, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
|
132 |
} else {
|
133 |
-
$
|
134 |
-
|
|
|
|
|
135 |
}
|
136 |
} catch (Exception $e) {
|
|
|
|
|
137 |
if($this->getColumn()->getTimezone()) {
|
138 |
$data = Mage::app()->getLocale()
|
139 |
->date($value, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
|
140 |
} else {
|
141 |
-
|
|
|
|
|
142 |
}
|
143 |
}
|
144 |
return $data;
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate
|
55 |
{
|
56 |
/** @var Mage_Sales_Model_Order $row */
|
57 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
58 |
+
/** @var TIG_PostNL_Helper_Carrier $carrierHelper */
|
59 |
+
$carrierHelper = Mage::helper('postnl/carrier');
|
60 |
+
if (!$carrierHelper->isPostnlShippingMethod($shippingMethod)) {
|
61 |
return '';
|
62 |
}
|
63 |
|
64 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
65 |
$helper = Mage::helper('postnl/deliveryOptions');
|
66 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
67 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
68 |
$value = $row->getData($this->getColumn()->getIndex());
|
69 |
|
70 |
$value = new DateTime($value, new DateTimeZone('UTC'));
|
72 |
/**
|
73 |
* Update the row's value for the decorator later.
|
74 |
*/
|
75 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
76 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
77 |
$row->setData($this->getColumn()->getIndex(), $value->format('Y-m-d H:i:s'));
|
78 |
|
79 |
$adminTimeZone = $helper->getStoreTimeZone(Mage_Core_Model_App::ADMIN_STORE_ID, true);
|
130 |
*/
|
131 |
$format = $this->_getFormat();
|
132 |
|
133 |
+
$timeZone = $helper->getStoreTimeZone($row->getData('store_id'), true);
|
134 |
$value = $value->setTimezone($timeZone)->format('Y-m-d H:i:s');
|
135 |
try {
|
136 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
137 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
138 |
if($this->getColumn()->getGmtoffset()) {
|
139 |
$data = Mage::app()->getLocale()
|
140 |
->date($value, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
|
141 |
} else {
|
142 |
+
/** @var Mage_Core_Model_Locale $localeModel */
|
143 |
+
$localeModel = Mage::getSingleton('core/locale');
|
144 |
+
/** @noinspection PhpUndefinedClassInspection */
|
145 |
+
$data = $localeModel->date($value, Zend_Date::ISO_8601, null, false)->toString($format);
|
146 |
}
|
147 |
} catch (Exception $e) {
|
148 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
149 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
150 |
if($this->getColumn()->getTimezone()) {
|
151 |
$data = Mage::app()->getLocale()
|
152 |
->date($value, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
|
153 |
} else {
|
154 |
+
/** @var Mage_Core_Model_Locale $localeModel */
|
155 |
+
$localeModel = Mage::getSingleton('core/locale');
|
156 |
+
$data = $localeModel->date($value, null, null, false)->toString($format);
|
157 |
}
|
158 |
}
|
159 |
return $data;
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmStatus
|
@@ -58,23 +58,27 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmStatus
|
|
58 |
* The shipment was not shipped using PostNL
|
59 |
*/
|
60 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
61 |
-
|
|
|
|
|
|
|
62 |
return '';
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
* Check if any data is available
|
67 |
*/
|
|
|
|
|
68 |
$values = $row->getData($this->getColumn()->getIndex());
|
69 |
if (is_null($values) || $values === '') {
|
70 |
return parent::render($row);
|
71 |
}
|
72 |
|
73 |
-
$helper = Mage::helper('postnl');
|
74 |
-
|
75 |
/**
|
76 |
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
77 |
*/
|
|
|
78 |
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
79 |
$values = explode(',', $values);
|
80 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmStatus
|
58 |
* The shipment was not shipped using PostNL
|
59 |
*/
|
60 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
61 |
+
|
62 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
63 |
+
$helper = Mage::helper('postnl/carrier');
|
64 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
65 |
return '';
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
* Check if any data is available
|
70 |
*/
|
71 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
72 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
73 |
$values = $row->getData($this->getColumn()->getIndex());
|
74 |
if (is_null($values) || $values === '') {
|
75 |
return parent::render($row);
|
76 |
}
|
77 |
|
|
|
|
|
78 |
/**
|
79 |
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
80 |
*/
|
81 |
+
/** @noinspection PhpParamsInspection */
|
82 |
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
83 |
$values = explode(',', $values);
|
84 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_CountryArray
|
@@ -72,6 +72,8 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_CountryArray
|
|
72 |
*/
|
73 |
public function renderExport(Varien_Object $row)
|
74 |
{
|
|
|
|
|
75 |
$value = $row->getDataUsingMethod($this->getColumn()->getIndex());
|
76 |
|
77 |
$formattedCountryArray = array();
|
@@ -85,4 +87,4 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_CountryArray
|
|
85 |
|
86 |
return implode(',', $formattedCountryArray);
|
87 |
}
|
88 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_CountryArray
|
72 |
*/
|
73 |
public function renderExport(Varien_Object $row)
|
74 |
{
|
75 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
76 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
77 |
$value = $row->getDataUsingMethod($this->getColumn()->getIndex());
|
78 |
|
79 |
$formattedCountryArray = array();
|
87 |
|
88 |
return implode(',', $formattedCountryArray);
|
89 |
}
|
90 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_DeliveryDate
|
@@ -56,15 +56,20 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_DeliveryDate
|
|
56 |
public function render(Varien_Object $row)
|
57 |
{
|
58 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
59 |
-
|
|
|
|
|
|
|
60 |
return '';
|
61 |
}
|
62 |
|
63 |
-
$domesticCountry =
|
64 |
if ($row->getData(self::COUNTRY_ID_COLUMN) != $domesticCountry) {
|
65 |
return Mage::helper('postnl')->__('N/A');
|
66 |
}
|
67 |
|
|
|
|
|
68 |
$value = $row->getData($this->getColumn()->getIndex());
|
69 |
|
70 |
/**
|
@@ -80,9 +85,11 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_DeliveryDate
|
|
80 |
$deliveryDate = new DateTime($value, new DateTimeZone('UTC'));
|
81 |
}
|
82 |
|
83 |
-
$timeZone =
|
84 |
$deliveryDate = $deliveryDate->setTimezone($timeZone)->format('Y-m-d H:i:s');
|
85 |
|
|
|
|
|
86 |
$row->setData($this->getColumn()->getIndex(), $deliveryDate);
|
87 |
|
88 |
/**
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_DeliveryDate
|
56 |
public function render(Varien_Object $row)
|
57 |
{
|
58 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
59 |
+
|
60 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
61 |
+
$helper = Mage::helper('postnl/carrier');
|
62 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
63 |
return '';
|
64 |
}
|
65 |
|
66 |
+
$domesticCountry = $helper->getDomesticCountry();
|
67 |
if ($row->getData(self::COUNTRY_ID_COLUMN) != $domesticCountry) {
|
68 |
return Mage::helper('postnl')->__('N/A');
|
69 |
}
|
70 |
|
71 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
72 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
73 |
$value = $row->getData($this->getColumn()->getIndex());
|
74 |
|
75 |
/**
|
85 |
$deliveryDate = new DateTime($value, new DateTimeZone('UTC'));
|
86 |
}
|
87 |
|
88 |
+
$timeZone = $helper->getStoreTimeZone($row->getData('store_id'), true);
|
89 |
$deliveryDate = $deliveryDate->setTimezone($timeZone)->format('Y-m-d H:i:s');
|
90 |
|
91 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
92 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
93 |
$row->setData($this->getColumn()->getIndex(), $deliveryDate);
|
94 |
|
95 |
/**
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated 1.6.0 This class has been moved to TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate. A
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated 1.6.0 This class has been moved to TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate. A
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_OrderConfirmStatus
|
@@ -58,14 +58,18 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_OrderConfirmStatus
|
|
58 |
* The shipment was not shipped using PostNL
|
59 |
*/
|
60 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
61 |
-
|
|
|
|
|
62 |
return '';
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
* Check if any data is available.
|
67 |
*/
|
68 |
-
|
|
|
|
|
69 |
if (is_null($values)) {
|
70 |
return Mage::helper('postnl')->__('No shipments found');
|
71 |
}
|
@@ -73,34 +77,31 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_OrderConfirmStatus
|
|
73 |
/**
|
74 |
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
75 |
*/
|
|
|
76 |
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
77 |
$values = explode(',', $values);
|
78 |
|
79 |
$labels = array();
|
80 |
foreach ($values as $value) {
|
81 |
if ($value == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
|
82 |
-
$labels[] =
|
83 |
-
->__('Confirmed');
|
84 |
|
85 |
continue;
|
86 |
}
|
87 |
|
88 |
if ($value == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED) {
|
89 |
-
$labels[] =
|
90 |
-
->__('Unconfirmed');
|
91 |
|
92 |
continue;
|
93 |
}
|
94 |
|
95 |
if ($value == $postnlShipmentClass::CONFIRM_STATUS_CONFIRM_EXPIRED) {
|
96 |
-
$labels[] =
|
97 |
-
->__('Confirmation Expired');
|
98 |
continue;
|
99 |
}
|
100 |
|
101 |
if ($value == $postnlShipmentClass::CONFIRM_STATUS_BUSPAKJE) {
|
102 |
-
$labels[] =
|
103 |
-
->__('No Confirmation Required');
|
104 |
continue;
|
105 |
}
|
106 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_OrderConfirmStatus
|
58 |
* The shipment was not shipped using PostNL
|
59 |
*/
|
60 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
61 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
62 |
+
$helper = Mage::helper('postnl/carrier');
|
63 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
64 |
return '';
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
* Check if any data is available.
|
69 |
*/
|
70 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
71 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
72 |
+
$values = $row->getData($this->getColumn()->getIndex());
|
73 |
if (is_null($values)) {
|
74 |
return Mage::helper('postnl')->__('No shipments found');
|
75 |
}
|
77 |
/**
|
78 |
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
79 |
*/
|
80 |
+
/** @noinspection PhpParamsInspection */
|
81 |
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
82 |
$values = explode(',', $values);
|
83 |
|
84 |
$labels = array();
|
85 |
foreach ($values as $value) {
|
86 |
if ($value == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
|
87 |
+
$labels[] = $helper->__('Confirmed');
|
|
|
88 |
|
89 |
continue;
|
90 |
}
|
91 |
|
92 |
if ($value == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED) {
|
93 |
+
$labels[] = $helper->__('Unconfirmed');
|
|
|
94 |
|
95 |
continue;
|
96 |
}
|
97 |
|
98 |
if ($value == $postnlShipmentClass::CONFIRM_STATUS_CONFIRM_EXPIRED) {
|
99 |
+
$labels[] = $helper->__('Confirmation Expired');
|
|
|
100 |
continue;
|
101 |
}
|
102 |
|
103 |
if ($value == $postnlShipmentClass::CONFIRM_STATUS_BUSPAKJE) {
|
104 |
+
$labels[] = $helper->__('No Confirmation Required');
|
|
|
105 |
continue;
|
106 |
}
|
107 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_OrderType
|
@@ -51,19 +51,23 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_OrderType
|
|
51 |
/**
|
52 |
* @var Mage_Adminhtml_Block_Widget_Grid_Column $column
|
53 |
*/
|
|
|
54 |
$column = $this->getColumn();
|
55 |
|
56 |
/**
|
57 |
* The shipment was not shipped using PostNL.
|
58 |
*/
|
59 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
60 |
-
|
|
|
|
|
61 |
return '';
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
* Check if any data is available.
|
66 |
*/
|
|
|
67 |
$value = $row->getData($column->getIndex());
|
68 |
if (is_null($value) || $value === '') {
|
69 |
return '';
|
@@ -79,12 +83,8 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_OrderType
|
|
79 |
|
80 |
$renderedValues = array();
|
81 |
foreach ($types as $key => $type) {
|
82 |
-
$rowDummy =
|
83 |
-
|
84 |
-
'id' => $row->getId(),
|
85 |
-
'product_code' => $productCodes[$key],
|
86 |
-
)
|
87 |
-
);
|
88 |
|
89 |
$renderedValue = $this->getShipmentTypeRenderedValue($type, $rowDummy);
|
90 |
$renderedValue = $this->_addOptionComments($renderedValue, $row);
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_OrderType
|
51 |
/**
|
52 |
* @var Mage_Adminhtml_Block_Widget_Grid_Column $column
|
53 |
*/
|
54 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
55 |
$column = $this->getColumn();
|
56 |
|
57 |
/**
|
58 |
* The shipment was not shipped using PostNL.
|
59 |
*/
|
60 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
61 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
62 |
+
$helper = Mage::helper('postnl/carrier');
|
63 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
64 |
return '';
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
* Check if any data is available.
|
69 |
*/
|
70 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
71 |
$value = $row->getData($column->getIndex());
|
72 |
if (is_null($value) || $value === '') {
|
73 |
return '';
|
83 |
|
84 |
$renderedValues = array();
|
85 |
foreach ($types as $key => $type) {
|
86 |
+
$rowDummy = clone $row;
|
87 |
+
$rowDummy->setData('product_code', $productCodes[$key]);
|
|
|
|
|
|
|
|
|
88 |
|
89 |
$renderedValue = $this->getShipmentTypeRenderedValue($type, $rowDummy);
|
90 |
$renderedValue = $this->_addOptionComments($renderedValue, $row);
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ReturnView
|
@@ -48,12 +48,16 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ReturnView
|
|
48 |
*/
|
49 |
public function render(Varien_Object $row)
|
50 |
{
|
|
|
|
|
51 |
$actions = $this->getColumn()->getActions();
|
52 |
|
53 |
if ( empty($actions) || !is_array($actions) ) {
|
54 |
return ' ';
|
55 |
}
|
56 |
|
|
|
|
|
57 |
if(sizeof($actions)==1 && !$this->getColumn()->getNoLink()) {
|
58 |
foreach ($actions as $action) {
|
59 |
if (is_array($action)) {
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ReturnView
|
48 |
*/
|
49 |
public function render(Varien_Object $row)
|
50 |
{
|
51 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
52 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
53 |
$actions = $this->getColumn()->getActions();
|
54 |
|
55 |
if ( empty($actions) || !is_array($actions) ) {
|
56 |
return ' ';
|
57 |
}
|
58 |
|
59 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
60 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
61 |
if(sizeof($actions)==1 && !$this->getColumn()->getNoLink()) {
|
62 |
foreach ($actions as $action) {
|
63 |
if (is_array($action)) {
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShipmentType
|
@@ -51,19 +51,23 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShipmentType
|
|
51 |
/**
|
52 |
* @var Mage_Adminhtml_Block_Widget_Grid_Column $column
|
53 |
*/
|
|
|
54 |
$column = $this->getColumn();
|
55 |
|
56 |
/**
|
57 |
* The shipment was not shipped using PostNL.
|
58 |
*/
|
59 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
60 |
-
|
|
|
|
|
61 |
return '';
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
* Check if any data is available.
|
66 |
*/
|
|
|
67 |
$value = $row->getData($column->getIndex());
|
68 |
if (is_null($value) || $value === '') {
|
69 |
return '';
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShipmentType
|
51 |
/**
|
52 |
* @var Mage_Adminhtml_Block_Widget_Grid_Column $column
|
53 |
*/
|
54 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
55 |
$column = $this->getColumn();
|
56 |
|
57 |
/**
|
58 |
* The shipment was not shipped using PostNL.
|
59 |
*/
|
60 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
61 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
62 |
+
$helper = Mage::helper('postnl/carrier');
|
63 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
64 |
return '';
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
* Check if any data is available.
|
69 |
*/
|
70 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
71 |
$value = $row->getData($column->getIndex());
|
72 |
if (is_null($value) || $value === '') {
|
73 |
return '';
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingDescription
|
@@ -58,13 +58,17 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingDescription
|
|
58 |
* The shipment was not shipped using PostNL
|
59 |
*/
|
60 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
61 |
-
|
|
|
|
|
62 |
return '';
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
* Check if any data is available
|
67 |
*/
|
|
|
|
|
68 |
$value = $row->getData($this->getColumn()->getIndex());
|
69 |
if (is_null($value) || $value === '') {
|
70 |
return parent::render($row);
|
@@ -93,7 +97,11 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingDescription
|
|
93 |
*/
|
94 |
public function getProductCode(Varien_Object $row)
|
95 |
{
|
|
|
|
|
96 |
$options = $this->getColumn()->getOptions();
|
|
|
|
|
97 |
$showMissingOptionValues = (bool)$this->getColumn()->getShowMissingOptionValues();
|
98 |
|
99 |
$value = '';
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingDescription
|
58 |
* The shipment was not shipped using PostNL
|
59 |
*/
|
60 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
61 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
62 |
+
$helper = Mage::helper('postnl/carrier');
|
63 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
64 |
return '';
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
* Check if any data is available
|
69 |
*/
|
70 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
71 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
72 |
$value = $row->getData($this->getColumn()->getIndex());
|
73 |
if (is_null($value) || $value === '') {
|
74 |
return parent::render($row);
|
97 |
*/
|
98 |
public function getProductCode(Varien_Object $row)
|
99 |
{
|
100 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
101 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
102 |
$options = $this->getColumn()->getOptions();
|
103 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
104 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
105 |
$showMissingOptionValues = (bool)$this->getColumn()->getShowMissingOptionValues();
|
106 |
|
107 |
$value = '';
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingPhase
|
@@ -48,15 +48,18 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingPhase
|
|
48 |
*/
|
49 |
public function render(Varien_Object $row)
|
50 |
{
|
|
|
|
|
51 |
$values = $row->getData($this->getColumn()->getIndex());
|
52 |
|
53 |
if (empty($values)) {
|
54 |
return '';
|
55 |
}
|
56 |
|
57 |
-
$helper
|
|
|
58 |
$values = explode(',', $values);
|
59 |
-
$shippingPhases =
|
60 |
|
61 |
$labels = array();
|
62 |
foreach ($values as $value) {
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingPhase
|
48 |
*/
|
49 |
public function render(Varien_Object $row)
|
50 |
{
|
51 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
52 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
53 |
$values = $row->getData($this->getColumn()->getIndex());
|
54 |
|
55 |
if (empty($values)) {
|
56 |
return '';
|
57 |
}
|
58 |
|
59 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
60 |
+
$helper = Mage::helper('postnl/cif');
|
61 |
$values = explode(',', $values);
|
62 |
+
$shippingPhases = $helper->getShippingPhases();
|
63 |
|
64 |
$labels = array();
|
65 |
foreach ($values as $value) {
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
@@ -51,6 +51,8 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
|
51 |
*/
|
52 |
protected function _getFormat()
|
53 |
{
|
|
|
|
|
54 |
$format = $this->getColumn()->getFormat();
|
55 |
if (!$format) {
|
56 |
if (is_null(self::$_format)) {
|
@@ -60,7 +62,9 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
|
60 |
);
|
61 |
}
|
62 |
catch (Exception $e) {
|
63 |
-
|
|
|
|
|
64 |
}
|
65 |
}
|
66 |
$format = self::$_format;
|
@@ -79,6 +83,8 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
|
79 |
{
|
80 |
$data = $this->_getValue($row);
|
81 |
if (!$data) {
|
|
|
|
|
82 |
return $this->getColumn()->getDefault();
|
83 |
}
|
84 |
|
@@ -87,8 +93,12 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
|
87 |
$data = Mage::app()->getLocale()
|
88 |
->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
|
89 |
} catch (Exception $e) {
|
90 |
-
|
|
|
|
|
91 |
|
|
|
|
|
92 |
return $this->getColumn()->getDefault();
|
93 |
}
|
94 |
return $data;
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
51 |
*/
|
52 |
protected function _getFormat()
|
53 |
{
|
54 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
55 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
56 |
$format = $this->getColumn()->getFormat();
|
57 |
if (!$format) {
|
58 |
if (is_null(self::$_format)) {
|
62 |
);
|
63 |
}
|
64 |
catch (Exception $e) {
|
65 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
66 |
+
$helper = Mage::helper('postnl');
|
67 |
+
$helper->logException($e);
|
68 |
}
|
69 |
}
|
70 |
$format = self::$_format;
|
83 |
{
|
84 |
$data = $this->_getValue($row);
|
85 |
if (!$data) {
|
86 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
87 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
88 |
return $this->getColumn()->getDefault();
|
89 |
}
|
90 |
|
93 |
$data = Mage::app()->getLocale()
|
94 |
->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
|
95 |
} catch (Exception $e) {
|
96 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
97 |
+
$helper = Mage::helper('postnl');
|
98 |
+
$helper->logException($e);
|
99 |
|
100 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
101 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
102 |
return $this->getColumn()->getDefault();
|
103 |
}
|
104 |
return $data;
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Translate
|
@@ -49,6 +49,8 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Translate
|
|
49 |
public function render(Varien_Object $row)
|
50 |
{
|
51 |
$helper = Mage::helper('postnl');
|
|
|
|
|
52 |
$value = $row->getData($this->getColumn()->getIndex());
|
53 |
|
54 |
return $helper->__($value);
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Translate
|
49 |
public function render(Varien_Object $row)
|
50 |
{
|
51 |
$helper = Mage::helper('postnl');
|
52 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
53 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
54 |
$value = $row->getData($this->getColumn()->getIndex());
|
55 |
|
56 |
return $helper->__($value);
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
@@ -50,6 +50,7 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
50 |
const PAYMENT_METHOD_COLUMN = 'payment_method';
|
51 |
const OPTIONS_COLUMN = 'options';
|
52 |
const DELIVERY_DATE_COLUMN = 'delivery_date';
|
|
|
53 |
|
54 |
/**
|
55 |
* Renders a type column for a shipment type.
|
@@ -65,63 +66,76 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
65 |
|
66 |
$label = '';
|
67 |
$comment = false;
|
|
|
|
|
|
|
68 |
switch ($type) {
|
69 |
-
case
|
70 |
$label = $helper->__('Domestic');
|
71 |
break;
|
72 |
-
case
|
73 |
$label = $helper->__('Domestic');
|
74 |
$comment = $helper->__('COD');
|
75 |
break;
|
76 |
-
case
|
77 |
$label = $helper->__('Domestic');
|
78 |
$comment = $helper->__('Evening Delivery');
|
79 |
break;
|
80 |
-
case
|
81 |
$label = $helper->__('Domestic');
|
82 |
$comment = $helper->__('Evening Delivery') . ' + ' . $helper->__('COD');
|
83 |
break;
|
84 |
-
case
|
85 |
$label = $helper->__('Post Office');
|
|
|
|
|
|
|
|
|
|
|
86 |
break;
|
87 |
-
case
|
88 |
$label = $helper->__('Post Office');
|
89 |
$comment = $helper->__('COD');
|
90 |
break;
|
91 |
-
case
|
92 |
$label = $helper->__('Post Office');
|
93 |
$comment = $helper->__('Early Pickup');
|
94 |
break;
|
95 |
-
case
|
96 |
$label = $helper->__('Post Office');
|
97 |
$comment = $helper->__('Early Pickup') . ' + ' . $helper->__('COD');
|
98 |
break;
|
99 |
-
case
|
100 |
$label = $helper->__('Parcel Dispenser');
|
101 |
break;
|
102 |
-
case
|
103 |
-
$label = $helper->__('Parcel Dispenser');
|
104 |
-
$comment = $helper->__('COD');
|
105 |
-
break;
|
106 |
-
case 'eps':
|
107 |
$label = $helper->__('EPS');
|
108 |
break;
|
109 |
-
case
|
110 |
$label = $helper->__('GlobalPack');
|
111 |
break;
|
112 |
-
case
|
113 |
$label = $helper->__('Letter Box Parcel');
|
114 |
|
115 |
if ($row->getData(self::PRODUCT_CODE_COLUMN) == '2928') {
|
116 |
$comment = $helper->__('Extra');
|
117 |
}
|
118 |
break;
|
119 |
-
case
|
120 |
$label = $helper->__('Sunday Delivery');
|
121 |
break;
|
122 |
-
case
|
123 |
$label = $helper->__('Monday Delivery');
|
124 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
126 |
|
127 |
$renderedValue = "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
@@ -145,10 +159,12 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
145 |
/**
|
146 |
* @var Mage_Adminhtml_Block_Widget_Grid_Column $column
|
147 |
*/
|
|
|
148 |
$column = $this->getColumn();
|
149 |
|
150 |
$out = '';
|
151 |
if ($column->hasData('display')) {
|
|
|
152 |
$out .= " style='display:{$column->getDisplay()};'";
|
153 |
}
|
154 |
|
@@ -181,11 +197,13 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
181 |
*/
|
182 |
public function getOrderTypeRenderedValue($value, Varien_Object $row)
|
183 |
{
|
|
|
184 |
$helper = Mage::helper('postnl/cif');
|
185 |
|
186 |
/**
|
187 |
* Try to render the value based on the delivery option type.
|
188 |
*/
|
|
|
189 |
$optionType = $row->getData(self::DELIVERY_OPTION_TYPE_COLUMN);
|
190 |
if ($optionType == 'Avond') {
|
191 |
return $this->_getAvondRenderedValue($row);
|
@@ -195,17 +213,30 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
195 |
return $this->_getSundayRenderedValue($row);
|
196 |
} elseif ($optionType == 'Monday') {
|
197 |
return $this->_getMondayRenderedValue($row, $value);
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
} elseif ($row->getData(self::IS_PAKKETAUTOMAAT_COLUMN)) {
|
199 |
return $this->_getPaRenderedValue($row);
|
200 |
} elseif ($row->getData(self::IS_PAKJE_GEMAK_COLUMN)) {
|
201 |
-
return $this->_getPgRenderedValue($row);
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
-
* Check if this order is domestic
|
|
|
206 |
*/
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
return $this->_getDomesticRenderedValue($row, $value);
|
210 |
}
|
211 |
|
@@ -296,10 +327,11 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
296 |
* Render this column for a PGE shipment.
|
297 |
*
|
298 |
* @param Varien_Object $row
|
|
|
299 |
*
|
300 |
* @return string
|
301 |
*/
|
302 |
-
protected function _getPgRenderedValue(Varien_Object $row)
|
303 |
{
|
304 |
$helper = Mage::helper('postnl');
|
305 |
|
@@ -312,12 +344,20 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
312 |
$type .= '_cod';
|
313 |
}
|
314 |
|
|
|
|
|
|
|
|
|
315 |
$renderedValue = "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
316 |
|
317 |
if ($isCod) {
|
318 |
$renderedValue .= '<br /><em>' . $helper->__('COD') . '</em>';
|
319 |
}
|
320 |
|
|
|
|
|
|
|
|
|
321 |
return $renderedValue;
|
322 |
}
|
323 |
|
@@ -356,6 +396,63 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
356 |
return $this->_getDomesticRenderedValue($row, $destination, $label);
|
357 |
}
|
358 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
/**
|
360 |
* Render this column for a domestic shipment.
|
361 |
*
|
@@ -367,11 +464,11 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
367 |
*/
|
368 |
protected function _getDomesticRenderedValue(Varien_Object $row, $destination, $label = null)
|
369 |
{
|
370 |
-
$
|
371 |
$deliveryOptionsHelper = Mage::helper('postnl/deliveryOptions');
|
372 |
|
373 |
if (!$label) {
|
374 |
-
$label = $
|
375 |
}
|
376 |
$type = 'domestic';
|
377 |
|
@@ -390,7 +487,7 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
390 |
$deliveryDate = DateTime::createFromFormat('Y-m-d H:i:s', $deliveryDate, new DateTimeZone('UTC'));
|
391 |
|
392 |
if ($deliveryDate && $deliveryDate->format('N') !== '0' && $deliveryDate->format('N') !== '1') {
|
393 |
-
$label = $
|
394 |
$type = 'buspakje';
|
395 |
|
396 |
return "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
@@ -401,19 +498,19 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
401 |
$renderedValue = "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
402 |
|
403 |
if ($isCod) {
|
404 |
-
$renderedValue .= '<br /><em>' . $
|
405 |
} elseif ($destination == 'NL') {
|
406 |
/**
|
407 |
* If the buspakje calculation mode is set to manual, we can only inform the merchant that this might be a
|
408 |
* buspakje.
|
409 |
*/
|
410 |
$orderItems = Mage::getResourceModel('sales/order_item_collection')->setOrderFilter($row->getId());
|
411 |
-
if (
|
412 |
$deliveryDate = $row->getData(self::DELIVERY_DATE_COLUMN);
|
413 |
$deliveryDate = DateTime::createFromFormat('Y-m-d H:i:s', $deliveryDate, new DateTimeZone('UTC'));
|
414 |
|
415 |
if ($deliveryDate && $deliveryDate->format('N') !== '0' && $deliveryDate->format('N') !== '1') {
|
416 |
-
$renderedValue .= '<br /><em>(' . $
|
417 |
}
|
418 |
}
|
419 |
}
|
@@ -465,7 +562,9 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
|
465 |
$isCod = false;
|
466 |
$paymentMethod = $row->getData(self::PAYMENT_METHOD_COLUMN);
|
467 |
|
468 |
-
|
|
|
|
|
469 |
if (in_array($paymentMethod, $codPaymentMethods)) {
|
470 |
$isCod = true;
|
471 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Type_Abstract
|
50 |
const PAYMENT_METHOD_COLUMN = 'payment_method';
|
51 |
const OPTIONS_COLUMN = 'options';
|
52 |
const DELIVERY_DATE_COLUMN = 'delivery_date';
|
53 |
+
const COUNTRY_ID_COLUMN = 'country_id';
|
54 |
|
55 |
/**
|
56 |
* Renders a type column for a shipment type.
|
66 |
|
67 |
$label = '';
|
68 |
$comment = false;
|
69 |
+
/** @noinspection PhpParamsInspection */
|
70 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass */
|
71 |
+
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
72 |
switch ($type) {
|
73 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_DOMESTIC:
|
74 |
$label = $helper->__('Domestic');
|
75 |
break;
|
76 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_DOMESTIC_COD:
|
77 |
$label = $helper->__('Domestic');
|
78 |
$comment = $helper->__('COD');
|
79 |
break;
|
80 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_AVOND:
|
81 |
$label = $helper->__('Domestic');
|
82 |
$comment = $helper->__('Evening Delivery');
|
83 |
break;
|
84 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_AVOND_COD:
|
85 |
$label = $helper->__('Domestic');
|
86 |
$comment = $helper->__('Evening Delivery') . ' + ' . $helper->__('COD');
|
87 |
break;
|
88 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_PG:
|
89 |
$label = $helper->__('Post Office');
|
90 |
+
|
91 |
+
if ($row->getData(self::COUNTRY_ID_COLUMN) == 'BE') {
|
92 |
+
$comment = $helper->__('Belgium');
|
93 |
+
$type .= '_be';
|
94 |
+
}
|
95 |
break;
|
96 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_PG_COD:
|
97 |
$label = $helper->__('Post Office');
|
98 |
$comment = $helper->__('COD');
|
99 |
break;
|
100 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_PGE:
|
101 |
$label = $helper->__('Post Office');
|
102 |
$comment = $helper->__('Early Pickup');
|
103 |
break;
|
104 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_PGE_COD:
|
105 |
$label = $helper->__('Post Office');
|
106 |
$comment = $helper->__('Early Pickup') . ' + ' . $helper->__('COD');
|
107 |
break;
|
108 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_PA:
|
109 |
$label = $helper->__('Parcel Dispenser');
|
110 |
break;
|
111 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_EPS:
|
|
|
|
|
|
|
|
|
112 |
$label = $helper->__('EPS');
|
113 |
break;
|
114 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_GLOBALPACK:
|
115 |
$label = $helper->__('GlobalPack');
|
116 |
break;
|
117 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_BUSPAKJE:
|
118 |
$label = $helper->__('Letter Box Parcel');
|
119 |
|
120 |
if ($row->getData(self::PRODUCT_CODE_COLUMN) == '2928') {
|
121 |
$comment = $helper->__('Extra');
|
122 |
}
|
123 |
break;
|
124 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_SUNDAY:
|
125 |
$label = $helper->__('Sunday Delivery');
|
126 |
break;
|
127 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_MONDAY:
|
128 |
$label = $helper->__('Monday Delivery');
|
129 |
break;
|
130 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_SAMEDAY:
|
131 |
+
$label = $helper->__('Same Day Delivery');
|
132 |
+
break;
|
133 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_FOOD:
|
134 |
+
$label = $helper->__('Food Delivery');
|
135 |
+
break;
|
136 |
+
case $postnlShipmentClass::SHIPMENT_TYPE_COOLED:
|
137 |
+
$label = $helper->__('Cooled Food Delivery');
|
138 |
+
break;
|
139 |
}
|
140 |
|
141 |
$renderedValue = "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
159 |
/**
|
160 |
* @var Mage_Adminhtml_Block_Widget_Grid_Column $column
|
161 |
*/
|
162 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
163 |
$column = $this->getColumn();
|
164 |
|
165 |
$out = '';
|
166 |
if ($column->hasData('display')) {
|
167 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
168 |
$out .= " style='display:{$column->getDisplay()};'";
|
169 |
}
|
170 |
|
197 |
*/
|
198 |
public function getOrderTypeRenderedValue($value, Varien_Object $row)
|
199 |
{
|
200 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
201 |
$helper = Mage::helper('postnl/cif');
|
202 |
|
203 |
/**
|
204 |
* Try to render the value based on the delivery option type.
|
205 |
*/
|
206 |
+
$domesticCountry = $helper->getDomesticCountry();
|
207 |
$optionType = $row->getData(self::DELIVERY_OPTION_TYPE_COLUMN);
|
208 |
if ($optionType == 'Avond') {
|
209 |
return $this->_getAvondRenderedValue($row);
|
213 |
return $this->_getSundayRenderedValue($row);
|
214 |
} elseif ($optionType == 'Monday') {
|
215 |
return $this->_getMondayRenderedValue($row, $value);
|
216 |
+
} elseif ($optionType == 'Sameday') {
|
217 |
+
return $this->_getSameDayRenderedValue($row);
|
218 |
+
} elseif ($optionType == 'Food') {
|
219 |
+
return $this->_getFoodRenderedValue($row);
|
220 |
+
} elseif ($optionType == 'Cooledfood') {
|
221 |
+
return $this->_getCooledfoodRenderedValue($row);
|
222 |
} elseif ($row->getData(self::IS_PAKKETAUTOMAAT_COLUMN)) {
|
223 |
return $this->_getPaRenderedValue($row);
|
224 |
} elseif ($row->getData(self::IS_PAKJE_GEMAK_COLUMN)) {
|
225 |
+
return $this->_getPgRenderedValue($row, $value);
|
226 |
}
|
227 |
|
228 |
/**
|
229 |
+
* Check if this order is domestic OR
|
230 |
+
* Check if this is a BE to NL shipment with the "use dutch products" option active.
|
231 |
*/
|
232 |
+
if (
|
233 |
+
$value == $domesticCountry ||
|
234 |
+
(
|
235 |
+
$value == 'NL' &&
|
236 |
+
$domesticCountry == 'BE' &&
|
237 |
+
Mage::helper('postnl/deliveryOptions')->canUseDutchProducts()
|
238 |
+
)
|
239 |
+
) {
|
240 |
return $this->_getDomesticRenderedValue($row, $value);
|
241 |
}
|
242 |
|
327 |
* Render this column for a PGE shipment.
|
328 |
*
|
329 |
* @param Varien_Object $row
|
330 |
+
* @param string $value
|
331 |
*
|
332 |
* @return string
|
333 |
*/
|
334 |
+
protected function _getPgRenderedValue(Varien_Object $row, $value)
|
335 |
{
|
336 |
$helper = Mage::helper('postnl');
|
337 |
|
344 |
$type .= '_cod';
|
345 |
}
|
346 |
|
347 |
+
if ($value == 'BE') {
|
348 |
+
$type .= '_be';
|
349 |
+
}
|
350 |
+
|
351 |
$renderedValue = "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
352 |
|
353 |
if ($isCod) {
|
354 |
$renderedValue .= '<br /><em>' . $helper->__('COD') . '</em>';
|
355 |
}
|
356 |
|
357 |
+
if ($value == 'BE') {
|
358 |
+
$renderedValue .= '<br /><em>' . $helper->__('Belgium') . '</em>';
|
359 |
+
}
|
360 |
+
|
361 |
return $renderedValue;
|
362 |
}
|
363 |
|
396 |
return $this->_getDomesticRenderedValue($row, $destination, $label);
|
397 |
}
|
398 |
|
399 |
+
/**
|
400 |
+
* Render this column for a same day delivery shipment.
|
401 |
+
*
|
402 |
+
* @param Varien_Object $row
|
403 |
+
*
|
404 |
+
* @return string
|
405 |
+
*/
|
406 |
+
protected function _getSameDayRenderedValue(Varien_Object $row)
|
407 |
+
{
|
408 |
+
$helper = Mage::helper('postnl');
|
409 |
+
|
410 |
+
$label = $helper->__('Same Day Delivery');
|
411 |
+
$type = 'sameday';
|
412 |
+
|
413 |
+
$renderedValue = "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
414 |
+
|
415 |
+
return $renderedValue;
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Render this column for a food delivery shipment.
|
420 |
+
*
|
421 |
+
* @param Varien_Object $row
|
422 |
+
*
|
423 |
+
* @return string
|
424 |
+
*/
|
425 |
+
protected function _getFoodRenderedValue(Varien_Object $row)
|
426 |
+
{
|
427 |
+
$helper = Mage::helper('postnl');
|
428 |
+
|
429 |
+
$label = $helper->__('Food Delivery');
|
430 |
+
$type = 'food';
|
431 |
+
|
432 |
+
$renderedValue = "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
433 |
+
|
434 |
+
return $renderedValue;
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Render this column for a cooled food delivery shipment.
|
439 |
+
*
|
440 |
+
* @param Varien_Object $row
|
441 |
+
*
|
442 |
+
* @return string
|
443 |
+
*/
|
444 |
+
protected function _getCooledfoodRenderedValue(Varien_Object $row)
|
445 |
+
{
|
446 |
+
$helper = Mage::helper('postnl');
|
447 |
+
|
448 |
+
$label = $helper->__('Cooled Food Delivery');
|
449 |
+
$type = 'cooledfood';
|
450 |
+
|
451 |
+
$renderedValue = "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
452 |
+
|
453 |
+
return $renderedValue;
|
454 |
+
}
|
455 |
+
|
456 |
/**
|
457 |
* Render this column for a domestic shipment.
|
458 |
*
|
464 |
*/
|
465 |
protected function _getDomesticRenderedValue(Varien_Object $row, $destination, $label = null)
|
466 |
{
|
467 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $deliveryOptionsHelper */
|
468 |
$deliveryOptionsHelper = Mage::helper('postnl/deliveryOptions');
|
469 |
|
470 |
if (!$label) {
|
471 |
+
$label = $deliveryOptionsHelper->__('Domestic');
|
472 |
}
|
473 |
$type = 'domestic';
|
474 |
|
487 |
$deliveryDate = DateTime::createFromFormat('Y-m-d H:i:s', $deliveryDate, new DateTimeZone('UTC'));
|
488 |
|
489 |
if ($deliveryDate && $deliveryDate->format('N') !== '0' && $deliveryDate->format('N') !== '1') {
|
490 |
+
$label = $deliveryOptionsHelper->__('Letter Box Parcel');
|
491 |
$type = 'buspakje';
|
492 |
|
493 |
return "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
498 |
$renderedValue = "<b id='postnl-shipmenttype-{$row->getId()}' data-product-type='{$type}'>{$label}</b>";
|
499 |
|
500 |
if ($isCod) {
|
501 |
+
$renderedValue .= '<br /><em>' . $deliveryOptionsHelper->__('COD') . '</em>';
|
502 |
} elseif ($destination == 'NL') {
|
503 |
/**
|
504 |
* If the buspakje calculation mode is set to manual, we can only inform the merchant that this might be a
|
505 |
* buspakje.
|
506 |
*/
|
507 |
$orderItems = Mage::getResourceModel('sales/order_item_collection')->setOrderFilter($row->getId());
|
508 |
+
if ($deliveryOptionsHelper->fitsAsBuspakje($orderItems)) {
|
509 |
$deliveryDate = $row->getData(self::DELIVERY_DATE_COLUMN);
|
510 |
$deliveryDate = DateTime::createFromFormat('Y-m-d H:i:s', $deliveryDate, new DateTimeZone('UTC'));
|
511 |
|
512 |
if ($deliveryDate && $deliveryDate->format('N') !== '0' && $deliveryDate->format('N') !== '1') {
|
513 |
+
$renderedValue .= '<br /><em>(' . $deliveryOptionsHelper->__('possibly letter box parcel') . ')</em>';
|
514 |
}
|
515 |
}
|
516 |
}
|
562 |
$isCod = false;
|
563 |
$paymentMethod = $row->getData(self::PAYMENT_METHOD_COLUMN);
|
564 |
|
565 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
566 |
+
$helper = Mage::helper('postnl/payment');
|
567 |
+
$codPaymentMethods = $helper->getCodPaymentMethods();
|
568 |
if (in_array($paymentMethod, $codPaymentMethods)) {
|
569 |
$isCod = true;
|
570 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_YesNo
|
@@ -57,13 +57,17 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_YesNo
|
|
57 |
* The shipment was not shipped using PostNL
|
58 |
*/
|
59 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
60 |
-
|
|
|
|
|
61 |
return '';
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
* Check if any data is available
|
66 |
*/
|
|
|
|
|
67 |
$value = $row->getData($this->getColumn()->getIndex());
|
68 |
if (is_null($value) || $value === '') {
|
69 |
return parent::render($row);
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_YesNo
|
57 |
* The shipment was not shipped using PostNL
|
58 |
*/
|
59 |
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
60 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
61 |
+
$helper = Mage::helper('postnl/carrier');
|
62 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
63 |
return '';
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
* Check if any data is available
|
68 |
*/
|
69 |
+
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
70 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
71 |
$value = $row->getData($this->getColumn()->getIndex());
|
72 |
if (is_null($value) || $value === '') {
|
73 |
return parent::render($row);
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Observer to edit the sales > shipments grid
|
@@ -49,4 +49,4 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Massaction_Item_Additional_LabelSta
|
|
49 |
* @var string
|
50 |
*/
|
51 |
protected $_template = 'TIG/PostNL/widget/grid/massaction/label_start_pos.phtml';
|
52 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Observer to edit the sales > shipments grid
|
49 |
* @var string
|
50 |
*/
|
51 |
protected $_template = 'TIG/PostNL/widget/grid/massaction/label_start_pos.phtml';
|
52 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Massaction_Item_Additional_ProductOptions
|
@@ -58,4 +58,4 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Massaction_Item_Additional_ProductO
|
|
58 |
$this->setForm($form);
|
59 |
return $this;
|
60 |
}
|
61 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Massaction_Item_Additional_ProductOptions
|
58 |
$this->setForm($form);
|
59 |
return $this;
|
60 |
}
|
61 |
+
}
|
@@ -33,11 +33,11 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsOldMagento()
|
40 |
-
* @method TIG_PostNL_Block_Adminhtml_WindowsTheme setIsOldMagento()
|
41 |
*/
|
42 |
class TIG_PostNL_Block_Adminhtml_WindowsTheme extends TIG_PostNL_Block_Adminhtml_Template
|
43 |
{
|
@@ -64,7 +64,9 @@ class TIG_PostNL_Block_Adminhtml_WindowsTheme extends TIG_PostNL_Block_Adminhtml
|
|
64 |
}
|
65 |
|
66 |
$version = Mage::getVersion();
|
67 |
-
|
|
|
|
|
68 |
|
69 |
/**
|
70 |
* Get the minimum version requirement for the current Magento edition.
|
@@ -83,4 +85,4 @@ class TIG_PostNL_Block_Adminhtml_WindowsTheme extends TIG_PostNL_Block_Adminhtml
|
|
83 |
$this->setIsOldMagento($isOldVersion);
|
84 |
return $isOldVersion;
|
85 |
}
|
86 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsOldMagento()
|
40 |
+
* @method TIG_PostNL_Block_Adminhtml_WindowsTheme setIsOldMagento($value)
|
41 |
*/
|
42 |
class TIG_PostNL_Block_Adminhtml_WindowsTheme extends TIG_PostNL_Block_Adminhtml_Template
|
43 |
{
|
64 |
}
|
65 |
|
66 |
$version = Mage::getVersion();
|
67 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
68 |
+
$helper = Mage::helper('postnl');
|
69 |
+
$isEnterprise = $helper->isEnterprise();
|
70 |
|
71 |
/**
|
72 |
* Get the minimum version requirement for the current Magento edition.
|
85 |
$this->setIsOldMagento($isOldVersion);
|
86 |
return $isOldVersion;
|
87 |
}
|
88 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPublicWebshopId()
|
@@ -81,7 +81,9 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends TIG_PostNL_Block_Core_
|
|
81 |
*/
|
82 |
public function getCheckoutUrl()
|
83 |
{
|
84 |
-
|
|
|
|
|
85 |
|
86 |
return $url;
|
87 |
}
|
@@ -156,8 +158,11 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends TIG_PostNL_Block_Core_
|
|
156 |
*/
|
157 |
public function canUsePostnlCheckout()
|
158 |
{
|
159 |
-
|
|
|
|
|
160 |
|
|
|
161 |
$helper = Mage::helper('postnl/checkout');
|
162 |
$canUseCheckout = $helper->canUsePostnlCheckout($quote);
|
163 |
|
@@ -213,7 +218,9 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends TIG_PostNL_Block_Core_
|
|
213 |
*/
|
214 |
public function getSrc($forceDisabled = false)
|
215 |
{
|
216 |
-
|
|
|
|
|
217 |
$baseUrl = $this->getButtonTestBaseUrl();
|
218 |
} else {
|
219 |
$baseUrl = $this->getButtonLiveBaseUrl();;
|
@@ -245,7 +252,9 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends TIG_PostNL_Block_Core_
|
|
245 |
return false;
|
246 |
}
|
247 |
|
248 |
-
|
|
|
|
|
249 |
return $pageUrl;
|
250 |
}
|
251 |
|
@@ -256,6 +265,7 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends TIG_PostNL_Block_Core_
|
|
256 |
*/
|
257 |
protected function _toHtml()
|
258 |
{
|
|
|
259 |
$helper = Mage::helper('postnl/checkout');
|
260 |
if (!$helper->isCheckoutActive() && Mage::registry('postnl_checkout_logged') === null) {
|
261 |
/**
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPublicWebshopId()
|
81 |
*/
|
82 |
public function getCheckoutUrl()
|
83 |
{
|
84 |
+
/** @var Mage_Checkout_Helper_Url $helper */
|
85 |
+
$helper = Mage::helper('checkout/url');
|
86 |
+
$url = $helper->getCheckoutUrl();
|
87 |
|
88 |
return $url;
|
89 |
}
|
158 |
*/
|
159 |
public function canUsePostnlCheckout()
|
160 |
{
|
161 |
+
/** @var Mage_Checkout_Model_Session $session */
|
162 |
+
$session = Mage::getSingleton('checkout/session');
|
163 |
+
$quote = $session->getQuote();
|
164 |
|
165 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
166 |
$helper = Mage::helper('postnl/checkout');
|
167 |
$canUseCheckout = $helper->canUsePostnlCheckout($quote);
|
168 |
|
218 |
*/
|
219 |
public function getSrc($forceDisabled = false)
|
220 |
{
|
221 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
222 |
+
$helper = Mage::helper('postnl/checkout');
|
223 |
+
if ($helper->isTestMode()) {
|
224 |
$baseUrl = $this->getButtonTestBaseUrl();
|
225 |
} else {
|
226 |
$baseUrl = $this->getButtonLiveBaseUrl();;
|
252 |
return false;
|
253 |
}
|
254 |
|
255 |
+
/** @var Mage_Cms_Helper_Page $helper */
|
256 |
+
$helper = Mage::helper('cms/page');
|
257 |
+
$pageUrl = $helper->getPageUrl($instructionPage);
|
258 |
return $pageUrl;
|
259 |
}
|
260 |
|
265 |
*/
|
266 |
protected function _toHtml()
|
267 |
{
|
268 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
269 |
$helper = Mage::helper('postnl/checkout');
|
270 |
if (!$helper->isCheckoutActive() && Mage::registry('postnl_checkout_logged') === null) {
|
271 |
/**
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasWebshopId()
|
@@ -111,7 +111,9 @@ class TIG_PostNL_Block_Checkout_Cart_Js extends TIG_PostNL_Block_Core_Template
|
|
111 |
|
112 |
$storeId = Mage::app()->getStore()->getId();
|
113 |
|
114 |
-
|
|
|
|
|
115 |
$url = Mage::getStoreConfig(self::TEST_CHECKOUT_JS_URL_XPATH);
|
116 |
|
117 |
$this->setCheckoutJsUrl($url);
|
@@ -137,7 +139,9 @@ class TIG_PostNL_Block_Checkout_Cart_Js extends TIG_PostNL_Block_Core_Template
|
|
137 |
|
138 |
$storeId = Mage::app()->getStore()->getId();
|
139 |
|
140 |
-
|
|
|
|
|
141 |
$url = Mage::getStoreConfig(self::TEST_CHECKOUT_PREMIUM_JS_URL_XPATH);
|
142 |
|
143 |
$this->setCheckoutPremiumJsUrl($url);
|
@@ -163,7 +167,9 @@ class TIG_PostNL_Block_Checkout_Cart_Js extends TIG_PostNL_Block_Core_Template
|
|
163 |
|
164 |
$storeId = Mage::app()->getStore()->getId();
|
165 |
|
166 |
-
|
|
|
|
|
167 |
$environment = self::TEST_ENVIRONMENT;
|
168 |
|
169 |
$this->setEnvironment($environment);
|
@@ -209,9 +215,13 @@ class TIG_PostNL_Block_Checkout_Cart_Js extends TIG_PostNL_Block_Core_Template
|
|
209 |
*/
|
210 |
protected function _toHtml()
|
211 |
{
|
212 |
-
|
|
|
|
|
213 |
|
214 |
-
|
|
|
|
|
215 |
if (!$canUseCheckout) {
|
216 |
return '';
|
217 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasWebshopId()
|
111 |
|
112 |
$storeId = Mage::app()->getStore()->getId();
|
113 |
|
114 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
115 |
+
$helper = Mage::helper('postnl/checkout');
|
116 |
+
if ($helper->isTestMode($storeId)) {
|
117 |
$url = Mage::getStoreConfig(self::TEST_CHECKOUT_JS_URL_XPATH);
|
118 |
|
119 |
$this->setCheckoutJsUrl($url);
|
139 |
|
140 |
$storeId = Mage::app()->getStore()->getId();
|
141 |
|
142 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
143 |
+
$helper = Mage::helper('postnl/checkout');
|
144 |
+
if ($helper->isTestMode($storeId)) {
|
145 |
$url = Mage::getStoreConfig(self::TEST_CHECKOUT_PREMIUM_JS_URL_XPATH);
|
146 |
|
147 |
$this->setCheckoutPremiumJsUrl($url);
|
167 |
|
168 |
$storeId = Mage::app()->getStore()->getId();
|
169 |
|
170 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
171 |
+
$helper = Mage::helper('postnl/checkout');
|
172 |
+
if ($helper->isTestMode($storeId)) {
|
173 |
$environment = self::TEST_ENVIRONMENT;
|
174 |
|
175 |
$this->setEnvironment($environment);
|
215 |
*/
|
216 |
protected function _toHtml()
|
217 |
{
|
218 |
+
/** @var Mage_Checkout_Model_Session $session */
|
219 |
+
$session = Mage::getSingleton('checkout/session');
|
220 |
+
$quote = $session->getQuote();
|
221 |
|
222 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
223 |
+
$helper = Mage::helper('postnl/checkout');
|
224 |
+
$canUseCheckout = $helper->canUsePostnlCheckout($quote);
|
225 |
if (!$canUseCheckout) {
|
226 |
return '';
|
227 |
}
|
@@ -33,8 +33,11 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
|
|
|
|
|
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
40 |
{
|
@@ -83,6 +86,7 @@ class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
|
83 |
|
84 |
$addresses = $quote->getAddressesCollection();
|
85 |
|
|
|
86 |
foreach ($addresses as $address) {
|
87 |
if ($address->getAddressType() == self::PAKJE_GEMAK_ADDRESS_TYPE) {
|
88 |
$address = Mage::getModel('sales/quote_address')->load($address->getId());
|
@@ -100,8 +104,10 @@ class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
|
100 |
*/
|
101 |
public function getShippingDescription()
|
102 |
{
|
|
|
103 |
$address = $this->getQuote()->getShippingAddress();
|
104 |
|
|
|
105 |
if ($address->hasShippingDescription()) {
|
106 |
return $address->getShippingDescription();
|
107 |
}
|
@@ -113,6 +119,7 @@ class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
|
113 |
}
|
114 |
|
115 |
$shippingDescription = '';
|
|
|
116 |
foreach ($address->getAllShippingRates() as $rate) {
|
117 |
if ($rate->getCode() == $method) {
|
118 |
$shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
|
@@ -141,7 +148,9 @@ class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
|
141 |
return false;
|
142 |
}
|
143 |
|
144 |
-
|
|
|
|
|
145 |
if (!array_key_exists($methodCode, $optionConversionArray)) {
|
146 |
return $optionValue;
|
147 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*
|
39 |
+
* @method boolean hasQuote()
|
40 |
+
* @method TIG_PostNL_Block_Checkout_Summary setQuote(Mage_Sales_Model_Quote $quote)
|
41 |
*/
|
42 |
class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
43 |
{
|
86 |
|
87 |
$addresses = $quote->getAddressesCollection();
|
88 |
|
89 |
+
/** @var Mage_Sales_Model_Quote_Address $address */
|
90 |
foreach ($addresses as $address) {
|
91 |
if ($address->getAddressType() == self::PAKJE_GEMAK_ADDRESS_TYPE) {
|
92 |
$address = Mage::getModel('sales/quote_address')->load($address->getId());
|
104 |
*/
|
105 |
public function getShippingDescription()
|
106 |
{
|
107 |
+
/** @var Mage_Sales_Model_Quote_Address $address */
|
108 |
$address = $this->getQuote()->getShippingAddress();
|
109 |
|
110 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
111 |
if ($address->hasShippingDescription()) {
|
112 |
return $address->getShippingDescription();
|
113 |
}
|
119 |
}
|
120 |
|
121 |
$shippingDescription = '';
|
122 |
+
/** @var Mage_Sales_Model_Quote_Address_Rate $rate */
|
123 |
foreach ($address->getAllShippingRates() as $rate) {
|
124 |
if ($rate->getCode() == $method) {
|
125 |
$shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
|
148 |
return false;
|
149 |
}
|
150 |
|
151 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
152 |
+
$helper = Mage::helper('postnl/checkout');
|
153 |
+
$optionConversionArray = $helper->getOptionConversionArray();
|
154 |
if (!array_key_exists($methodCode, $optionConversionArray)) {
|
155 |
return $optionValue;
|
156 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Core_JsTranslate extends TIG_PostNL_Block_Core_Template
|
@@ -118,7 +118,9 @@ class TIG_PostNL_Block_Core_JsTranslate extends TIG_PostNL_Block_Core_Template
|
|
118 |
{
|
119 |
$messages = $this->_getTranslateData();
|
120 |
|
121 |
-
|
|
|
|
|
122 |
return $json;
|
123 |
}
|
124 |
|
@@ -201,6 +203,7 @@ class TIG_PostNL_Block_Core_JsTranslate extends TIG_PostNL_Block_Core_Template
|
|
201 |
*/
|
202 |
protected function _toHtml()
|
203 |
{
|
|
|
204 |
$helper = Mage::helper('postnl');
|
205 |
if (!$helper->isEnterprise() && version_compare(Mage::getVersion(), '1.7.0.0', '>=')) {
|
206 |
return '';
|
@@ -212,4 +215,4 @@ class TIG_PostNL_Block_Core_JsTranslate extends TIG_PostNL_Block_Core_Template
|
|
212 |
|
213 |
return parent::_toHtml();
|
214 |
}
|
215 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Core_JsTranslate extends TIG_PostNL_Block_Core_Template
|
118 |
{
|
119 |
$messages = $this->_getTranslateData();
|
120 |
|
121 |
+
/** @var Mage_Core_Helper_Data $helper */
|
122 |
+
$helper = Mage::helper('core');
|
123 |
+
$json = $helper->jsonEncode($messages);
|
124 |
return $json;
|
125 |
}
|
126 |
|
203 |
*/
|
204 |
protected function _toHtml()
|
205 |
{
|
206 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
207 |
$helper = Mage::helper('postnl');
|
208 |
if (!$helper->isEnterprise() && version_compare(Mage::getVersion(), '1.7.0.0', '>=')) {
|
209 |
return '';
|
215 |
|
216 |
return parent::_toHtml();
|
217 |
}
|
218 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Core_Order_Returns_Info extends Mage_Sales_Block_Order_Info
|
@@ -72,10 +72,11 @@ class TIG_PostNL_Block_Core_Order_Returns_Info extends Mage_Sales_Block_Order_In
|
|
72 |
/**
|
73 |
* @var Mage_Cms_Block_Block $infoBlock
|
74 |
*/
|
|
|
75 |
$infoBlock = $this->getLayout()
|
76 |
->createBlock('cms/block')
|
77 |
->setBlockId($infoBlockId);
|
78 |
|
79 |
return $infoBlock->toHtml();
|
80 |
}
|
81 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Core_Order_Returns_Info extends Mage_Sales_Block_Order_Info
|
72 |
/**
|
73 |
* @var Mage_Cms_Block_Block $infoBlock
|
74 |
*/
|
75 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
76 |
$infoBlock = $this->getLayout()
|
77 |
->createBlock('cms/block')
|
78 |
->setBlockId($infoBlockId);
|
79 |
|
80 |
return $infoBlock->toHtml();
|
81 |
}
|
82 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlShipmentCollection()
|
@@ -53,6 +53,7 @@ class TIG_PostNL_Block_Core_Order_Returns_Shipment_Items extends Mage_Sales_Bloc
|
|
53 |
}
|
54 |
|
55 |
$order = Mage::registry('current_order');
|
|
|
56 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
|
57 |
$postnlShipmentCollection->addFieldToFilter('order_id', array('eq' => $order->getid()));
|
58 |
|
@@ -69,7 +70,9 @@ class TIG_PostNL_Block_Core_Order_Returns_Shipment_Items extends Mage_Sales_Bloc
|
|
69 |
*/
|
70 |
public function getPrintLabelUrl($shipmentId)
|
71 |
{
|
72 |
-
|
|
|
|
|
73 |
$url = $this->getUrl('postnl/order/printReturnLabel', array('shipment_id' => $shipmentId));
|
74 |
} else {
|
75 |
$url = $this->getUrl('postnl/guest/printReturnLabel', array('shipment_id' => $shipmentId));
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlShipmentCollection()
|
53 |
}
|
54 |
|
55 |
$order = Mage::registry('current_order');
|
56 |
+
/** @var TIG_PostNL_Model_Core_Resource_Shipment_Collection $postnlShipmentCollection */
|
57 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
|
58 |
$postnlShipmentCollection->addFieldToFilter('order_id', array('eq' => $order->getid()));
|
59 |
|
70 |
*/
|
71 |
public function getPrintLabelUrl($shipmentId)
|
72 |
{
|
73 |
+
/** @var Mage_Customer_Model_Session $session */
|
74 |
+
$session = Mage::getSingleton('customer/session');
|
75 |
+
if ($session->isLoggedIn()) {
|
76 |
$url = $this->getUrl('postnl/order/printReturnLabel', array('shipment_id' => $shipmentId));
|
77 |
} else {
|
78 |
$url = $this->getUrl('postnl/guest/printReturnLabel', array('shipment_id' => $shipmentId));
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlShipment()
|
@@ -65,6 +65,7 @@ class TIG_PostNL_Block_Core_ShippingStatus extends TIG_PostNL_Block_Core_Templat
|
|
65 |
}
|
66 |
|
67 |
$shipment = $this->getShipment();
|
|
|
68 |
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
69 |
|
70 |
$this->setPostnlShipment($postnlShipment);
|
@@ -105,7 +106,9 @@ class TIG_PostNL_Block_Core_ShippingStatus extends TIG_PostNL_Block_Core_Templat
|
|
105 |
return false;
|
106 |
}
|
107 |
|
108 |
-
|
|
|
|
|
109 |
|
110 |
return $confirmedAt;
|
111 |
}
|
@@ -161,7 +164,9 @@ class TIG_PostNL_Block_Core_ShippingStatus extends TIG_PostNL_Block_Core_Templat
|
|
161 |
*/
|
162 |
protected function _toHtml()
|
163 |
{
|
164 |
-
|
|
|
|
|
165 |
return '';
|
166 |
}
|
167 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlShipment()
|
65 |
}
|
66 |
|
67 |
$shipment = $this->getShipment();
|
68 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
69 |
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
70 |
|
71 |
$this->setPostnlShipment($postnlShipment);
|
106 |
return false;
|
107 |
}
|
108 |
|
109 |
+
/** @var Mage_Core_Helper_Data $helper */
|
110 |
+
$helper = Mage::helper('core');
|
111 |
+
$confirmedAt = $helper->formatDate($postnlShipment->getConfirmedAt(), 'medium', false);
|
112 |
|
113 |
return $confirmedAt;
|
114 |
}
|
164 |
*/
|
165 |
protected function _toHtml()
|
166 |
{
|
167 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
168 |
+
$helper = Mage::helper('postnl');
|
169 |
+
if (!$helper->isEnabled()) {
|
170 |
return '';
|
171 |
}
|
172 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Block_Core_Template extends Mage_Core_Block_Template
|
@@ -57,4 +57,4 @@ abstract class TIG_PostNL_Block_Core_Template extends Mage_Core_Block_Template
|
|
57 |
Mage::dispatchEvent($this->_eventPrefix . '_to_html_after');
|
58 |
return $html;
|
59 |
}
|
60 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Block_Core_Template extends Mage_Core_Block_Template
|
57 |
Mage::dispatchEvent($this->_eventPrefix . '_to_html_after');
|
58 |
return $html;
|
59 |
}
|
60 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPhoneNumber()
|
@@ -93,6 +93,7 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber extends TIG_PostN
|
|
93 |
|
94 |
$quote = $this->getQuote();
|
95 |
if (!$quote) {
|
|
|
96 |
$shippingAddress = Mage::getModel('sales/quote_address');
|
97 |
|
98 |
$this->setShippingAddress($shippingAddress);
|
@@ -116,9 +117,11 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber extends TIG_PostN
|
|
116 |
return $this->_getData('quote');
|
117 |
}
|
118 |
|
119 |
-
|
|
|
|
|
120 |
|
121 |
$this->setQuote($quote);
|
122 |
return $quote;
|
123 |
}
|
124 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPhoneNumber()
|
93 |
|
94 |
$quote = $this->getQuote();
|
95 |
if (!$quote) {
|
96 |
+
/** @var Mage_Sales_Model_Quote_Address $shippingAddress */
|
97 |
$shippingAddress = Mage::getModel('sales/quote_address');
|
98 |
|
99 |
$this->setShippingAddress($shippingAddress);
|
117 |
return $this->_getData('quote');
|
118 |
}
|
119 |
|
120 |
+
/** @var Mage_Checkout_Model_Session $session */
|
121 |
+
$session = Mage::getSingleton('checkout/session');
|
122 |
+
$quote = $session->getQuote();
|
123 |
|
124 |
$this->setQuote($quote);
|
125 |
return $quote;
|
126 |
}
|
127 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions setStreetnameField(int $value)
|
@@ -188,7 +188,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
188 |
return $this->_getData('quote');
|
189 |
}
|
190 |
|
191 |
-
|
|
|
|
|
192 |
|
193 |
$this->setData('quote', $quote);
|
194 |
return $quote;
|
@@ -234,6 +236,7 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
234 |
return $shippingAddress;
|
235 |
}
|
236 |
|
|
|
237 |
$customerHelper = Mage::helper('customer');
|
238 |
|
239 |
/**
|
@@ -266,7 +269,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
266 |
&& $customerHelper->isLoggedIn()
|
267 |
&& $customerHelper->customerHasAddresses()
|
268 |
) {
|
269 |
-
|
|
|
|
|
270 |
}
|
271 |
|
272 |
return $shippingAddress;
|
@@ -293,21 +298,13 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
293 |
*/
|
294 |
public function getCountry()
|
295 |
{
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
*/
|
302 |
-
return 'NL';
|
303 |
|
304 |
-
|
305 |
-
//
|
306 |
-
// if (!$country) {
|
307 |
-
// $country = self::DEFAULT_SHIPPING_COUNTRY;
|
308 |
-
// }
|
309 |
-
//
|
310 |
-
// return $country;
|
311 |
}
|
312 |
|
313 |
/**
|
@@ -331,10 +328,12 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
331 |
try {
|
332 |
$deliveryDate = $this->_getDeliveryDate($postcode, $country, $quote);
|
333 |
} catch (Exception $e) {
|
334 |
-
|
|
|
|
|
335 |
|
336 |
-
$deliveryDate =
|
337 |
-
|
338 |
}
|
339 |
|
340 |
$this->setDeliveryDate($deliveryDate);
|
@@ -385,7 +384,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
385 |
*/
|
386 |
public function getOptionFee($option, $formatted = false, $includingTax = true, $convert = true)
|
387 |
{
|
388 |
-
|
|
|
|
|
389 |
}
|
390 |
|
391 |
/**
|
@@ -404,6 +405,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
404 |
case 'sunday':
|
405 |
$fee = $this->getSundayFee(false, $includingTax);
|
406 |
break;
|
|
|
|
|
|
|
407 |
case 'express':
|
408 |
$fee = $this->getExpressFee(false, $includingTax);
|
409 |
break;
|
@@ -434,6 +438,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
434 |
case 'sunday':
|
435 |
$feeText = $this->getSundayFee(true, $includingTax);
|
436 |
break;
|
|
|
|
|
|
|
437 |
case 'express':
|
438 |
$feeText = $this->getExpressFee(true, $includingTax);
|
439 |
break;
|
@@ -457,7 +464,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
457 |
*/
|
458 |
public function getEveningFee($formatted = false, $includingTax = true)
|
459 |
{
|
460 |
-
|
|
|
|
|
461 |
}
|
462 |
|
463 |
/**
|
@@ -470,9 +479,27 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
470 |
*/
|
471 |
public function getSundayFee($formatted = false, $includingTax = true)
|
472 |
{
|
473 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
}
|
475 |
|
|
|
476 |
/**
|
477 |
* Get the fee charged for PakjeGemak Express.
|
478 |
*
|
@@ -483,7 +510,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
483 |
*/
|
484 |
public function getExpressFee($formatted = false, $includingTax = true)
|
485 |
{
|
486 |
-
|
|
|
|
|
487 |
}
|
488 |
|
489 |
/**
|
@@ -499,10 +528,6 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
499 |
*/
|
500 |
public function getPakjeGemakFee($formatted = false, $includingTax = true)
|
501 |
{
|
502 |
-
if (!$this->getIsBuspakje()) {
|
503 |
-
return 0;
|
504 |
-
}
|
505 |
-
|
506 |
if (!$this->canUsePakjeGemak()
|
507 |
&& !$this->canUsePakjeGemakExpress()
|
508 |
&& !$this->canUsePakketAutomaat()
|
@@ -517,7 +542,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
517 |
|
518 |
$currentRate = $this->getMethodRate();
|
519 |
|
520 |
-
|
|
|
|
|
521 |
}
|
522 |
|
523 |
/**
|
@@ -531,7 +558,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
531 |
return $this->_getData('streetname_field');
|
532 |
}
|
533 |
|
534 |
-
|
|
|
|
|
535 |
|
536 |
$this->setStreetnameField($streetnameField);
|
537 |
return $streetnameField;
|
@@ -548,7 +577,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
548 |
return $this->_getData('housenumber_field');
|
549 |
}
|
550 |
|
551 |
-
|
|
|
|
|
552 |
|
553 |
$this->setHousenumberField($housenumberField);
|
554 |
return $housenumberField;
|
@@ -564,10 +595,12 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
564 |
$storeId = Mage::app()->getStore()->getId();
|
565 |
$address = $this->getShippingAddress();
|
566 |
|
|
|
|
|
567 |
try {
|
568 |
-
$streetData =
|
569 |
} catch (Exception $e) {
|
570 |
-
|
571 |
|
572 |
$streetData = array(
|
573 |
'streetname' => '',
|
@@ -590,7 +623,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
590 |
return $this->_getData('tax_display_type');
|
591 |
}
|
592 |
|
593 |
-
|
|
|
|
|
594 |
|
595 |
$this->setTaxDisplayType($taxDisplayType);
|
596 |
return $taxDisplayType;
|
@@ -603,7 +638,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
603 |
*/
|
604 |
public function canUsePakjeGemak()
|
605 |
{
|
606 |
-
|
|
|
|
|
607 |
return $canUsePakjeGemak;
|
608 |
}
|
609 |
|
@@ -614,7 +651,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
614 |
*/
|
615 |
public function canUsePakjeGemakExpress()
|
616 |
{
|
617 |
-
|
|
|
|
|
618 |
return $canUsePakjeGemakExpress;
|
619 |
}
|
620 |
|
@@ -625,7 +664,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
625 |
*/
|
626 |
public function canUsePakketAutomaat()
|
627 |
{
|
628 |
-
|
|
|
|
|
629 |
return $canUsePakketAutomaat;
|
630 |
}
|
631 |
|
@@ -636,7 +677,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
636 |
*/
|
637 |
public function canUseDeliveryDays()
|
638 |
{
|
639 |
-
|
|
|
|
|
640 |
return $canUseDeliveryDays;
|
641 |
}
|
642 |
|
@@ -647,7 +690,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
647 |
*/
|
648 |
public function canUseTimeframes()
|
649 |
{
|
650 |
-
|
|
|
|
|
651 |
return $canUseTimeframes;
|
652 |
}
|
653 |
|
@@ -658,10 +703,25 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
658 |
*/
|
659 |
public function canUseEveningTimeframes()
|
660 |
{
|
661 |
-
|
|
|
|
|
662 |
return $canUseEveningTimeframes;
|
663 |
}
|
664 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
665 |
/**
|
666 |
* Checks whether google streetview is allowed.
|
667 |
*
|
@@ -682,7 +742,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
682 |
*/
|
683 |
public function canUseResponsive()
|
684 |
{
|
685 |
-
|
|
|
|
|
686 |
return $canUseResponsive;
|
687 |
}
|
688 |
|
@@ -704,6 +766,7 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
704 |
/**
|
705 |
* @var Varien_Simplexml_Element $files
|
706 |
*/
|
|
|
707 |
$useCufon = (string) $theme->use_cufon;
|
708 |
if (!$useCufon) {
|
709 |
return false;
|
@@ -723,7 +786,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
723 |
*/
|
724 |
public function canShowOnlyStatedAddressOption()
|
725 |
{
|
726 |
-
|
|
|
|
|
727 |
return $canShowOnlyStatedAddressOptions;
|
728 |
}
|
729 |
|
@@ -734,7 +799,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
734 |
*/
|
735 |
public function isOnlyStatedAddressOptionChecked()
|
736 |
{
|
737 |
-
|
|
|
|
|
738 |
return $isOnlyStatedAddressOptionChecked;
|
739 |
}
|
740 |
|
@@ -745,15 +812,11 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
745 |
*/
|
746 |
public function canShowSeparateRates()
|
747 |
{
|
748 |
-
if (!$this->getIsBuspakje()) {
|
749 |
-
return false;
|
750 |
-
}
|
751 |
-
|
752 |
if (!$this->canUsePakjeGemak()) {
|
753 |
return false;
|
754 |
}
|
755 |
|
756 |
-
if ($this->getPakjeGemakFee() < 0.01) {
|
757 |
return false;
|
758 |
}
|
759 |
|
@@ -767,7 +830,9 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
767 |
*/
|
768 |
public function canUseSundaySorting()
|
769 |
{
|
770 |
-
|
|
|
|
|
771 |
return $canUseSundaySorting;
|
772 |
}
|
773 |
|
@@ -778,6 +843,7 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
778 |
*/
|
779 |
public function getIsBuspakje()
|
780 |
{
|
|
|
781 |
$helper = Mage::helper('postnl');
|
782 |
|
783 |
/**
|
@@ -790,7 +856,7 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
790 |
/**
|
791 |
* Check if the current quote fits as a letter box parcel.
|
792 |
*/
|
793 |
-
$quote =
|
794 |
if (!$helper->quoteIsBuspakje($quote)) {
|
795 |
return false;
|
796 |
}
|
@@ -805,6 +871,7 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
805 |
*/
|
806 |
public function isDebugEnabled()
|
807 |
{
|
|
|
808 |
$helper = Mage::helper('postnl');
|
809 |
$debugMode = $helper->getDebugMode();
|
810 |
|
@@ -822,6 +889,7 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
822 |
*/
|
823 |
public function canUseDeliveryOptions()
|
824 |
{
|
|
|
825 |
$helper = Mage::helper('postnl/deliveryOptions');
|
826 |
|
827 |
$quote = $this->getQuote();
|
@@ -882,6 +950,7 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
882 |
);
|
883 |
}
|
884 |
|
|
|
885 |
$cif = Mage::getModel('postnl_deliveryoptions/cif');
|
886 |
$response = $cif->setStoreId(Mage::app()->getStore()->getId())
|
887 |
->getDeliveryDate($postcode, $country, $quote);
|
@@ -895,4 +964,21 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_Post
|
|
895 |
|
896 |
return $dateObject->format('d-m-Y');
|
897 |
}
|
898 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions setStreetnameField(int $value)
|
188 |
return $this->_getData('quote');
|
189 |
}
|
190 |
|
191 |
+
/** @var Mage_Checkout_Model_Session $session */
|
192 |
+
$session = Mage::getSingleton('checkout/session');
|
193 |
+
$quote = $session->getQuote();
|
194 |
|
195 |
$this->setData('quote', $quote);
|
196 |
return $quote;
|
236 |
return $shippingAddress;
|
237 |
}
|
238 |
|
239 |
+
/** @var Mage_Customer_Helper_Data $customerHelper */
|
240 |
$customerHelper = Mage::helper('customer');
|
241 |
|
242 |
/**
|
269 |
&& $customerHelper->isLoggedIn()
|
270 |
&& $customerHelper->customerHasAddresses()
|
271 |
) {
|
272 |
+
/** @var Mage_Customer_Model_Session $session */
|
273 |
+
$session = Mage::getSingleton('customer/session');
|
274 |
+
$shippingAddress = $session->getCustomer()->getDefaultShippingAddress();
|
275 |
}
|
276 |
|
277 |
return $shippingAddress;
|
298 |
*/
|
299 |
public function getCountry()
|
300 |
{
|
301 |
+
$country = $this->getShippingAddress()->getCountryId();
|
302 |
+
|
303 |
+
if (!$country) {
|
304 |
+
$country = self::DEFAULT_SHIPPING_COUNTRY;
|
305 |
+
}
|
|
|
|
|
306 |
|
307 |
+
return $country;
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
}
|
309 |
|
310 |
/**
|
328 |
try {
|
329 |
$deliveryDate = $this->_getDeliveryDate($postcode, $country, $quote);
|
330 |
} catch (Exception $e) {
|
331 |
+
/** @var TIG_PostNL_Helper_Date $helper */
|
332 |
+
$helper = Mage::helper('postnl/date');
|
333 |
+
$helper->logException($e);
|
334 |
|
335 |
+
$deliveryDate = $helper->getDeliveryDate('now' ,$storeId)
|
336 |
+
->format('d-m-Y');
|
337 |
}
|
338 |
|
339 |
$this->setDeliveryDate($deliveryDate);
|
384 |
*/
|
385 |
public function getOptionFee($option, $formatted = false, $includingTax = true, $convert = true)
|
386 |
{
|
387 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
388 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
389 |
+
return $helper->getOptionFee($option, $formatted, $includingTax, $convert);
|
390 |
}
|
391 |
|
392 |
/**
|
405 |
case 'sunday':
|
406 |
$fee = $this->getSundayFee(false, $includingTax);
|
407 |
break;
|
408 |
+
case 'sameday':
|
409 |
+
$fee = $this->getSameDayFee(false, $includingTax);
|
410 |
+
break;
|
411 |
case 'express':
|
412 |
$fee = $this->getExpressFee(false, $includingTax);
|
413 |
break;
|
438 |
case 'sunday':
|
439 |
$feeText = $this->getSundayFee(true, $includingTax);
|
440 |
break;
|
441 |
+
case 'sameday':
|
442 |
+
$feeText = $this->getSameDayFee(true, $includingTax);
|
443 |
+
break;
|
444 |
case 'express':
|
445 |
$feeText = $this->getExpressFee(true, $includingTax);
|
446 |
break;
|
464 |
*/
|
465 |
public function getEveningFee($formatted = false, $includingTax = true)
|
466 |
{
|
467 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
468 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
469 |
+
return $helper->getEveningFee($formatted, $includingTax);
|
470 |
}
|
471 |
|
472 |
/**
|
479 |
*/
|
480 |
public function getSundayFee($formatted = false, $includingTax = true)
|
481 |
{
|
482 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
483 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
484 |
+
return $helper->getSundayFee($formatted, $includingTax);
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Get the fee charged for same day delivery.
|
489 |
+
*
|
490 |
+
* @param boolean $formatted
|
491 |
+
* @param boolean $includingTax
|
492 |
+
*
|
493 |
+
* @return float
|
494 |
+
*/
|
495 |
+
public function getSameDayFee($formatted = false, $includingTax = true)
|
496 |
+
{
|
497 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
498 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
499 |
+
return $helper->getSameDayFee($formatted, $includingTax);
|
500 |
}
|
501 |
|
502 |
+
|
503 |
/**
|
504 |
* Get the fee charged for PakjeGemak Express.
|
505 |
*
|
510 |
*/
|
511 |
public function getExpressFee($formatted = false, $includingTax = true)
|
512 |
{
|
513 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
514 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
515 |
+
return $helper->getExpressFee($formatted, $includingTax);
|
516 |
}
|
517 |
|
518 |
/**
|
528 |
*/
|
529 |
public function getPakjeGemakFee($formatted = false, $includingTax = true)
|
530 |
{
|
|
|
|
|
|
|
|
|
531 |
if (!$this->canUsePakjeGemak()
|
532 |
&& !$this->canUsePakjeGemakExpress()
|
533 |
&& !$this->canUsePakketAutomaat()
|
542 |
|
543 |
$currentRate = $this->getMethodRate();
|
544 |
|
545 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
546 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
547 |
+
return $helper->getPakjeGemakFee($currentRate, $formatted, $includingTax);
|
548 |
}
|
549 |
|
550 |
/**
|
558 |
return $this->_getData('streetname_field');
|
559 |
}
|
560 |
|
561 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
562 |
+
$helper = Mage::helper('postnl/addressValidation');
|
563 |
+
$streetnameField = $helper->getStreetnameField();
|
564 |
|
565 |
$this->setStreetnameField($streetnameField);
|
566 |
return $streetnameField;
|
577 |
return $this->_getData('housenumber_field');
|
578 |
}
|
579 |
|
580 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
581 |
+
$helper = Mage::helper('postnl/addressValidation');
|
582 |
+
$housenumberField = $helper->getHousenumberField();
|
583 |
|
584 |
$this->setHousenumberField($housenumberField);
|
585 |
return $housenumberField;
|
595 |
$storeId = Mage::app()->getStore()->getId();
|
596 |
$address = $this->getShippingAddress();
|
597 |
|
598 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
599 |
+
$helper = Mage::helper('postnl/cif');
|
600 |
try {
|
601 |
+
$streetData = $helper->getStreetData($storeId, $address, false);
|
602 |
} catch (Exception $e) {
|
603 |
+
$helper->logException($e);
|
604 |
|
605 |
$streetData = array(
|
606 |
'streetname' => '',
|
623 |
return $this->_getData('tax_display_type');
|
624 |
}
|
625 |
|
626 |
+
/** @var Mage_Tax_Model_Config $config */
|
627 |
+
$config = Mage::getSingleton('tax/config');
|
628 |
+
$taxDisplayType = $config->getShippingPriceDisplayType();
|
629 |
|
630 |
$this->setTaxDisplayType($taxDisplayType);
|
631 |
return $taxDisplayType;
|
638 |
*/
|
639 |
public function canUsePakjeGemak()
|
640 |
{
|
641 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
642 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
643 |
+
$canUsePakjeGemak = $helper->canUsePakjeGemak();
|
644 |
return $canUsePakjeGemak;
|
645 |
}
|
646 |
|
651 |
*/
|
652 |
public function canUsePakjeGemakExpress()
|
653 |
{
|
654 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
655 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
656 |
+
$canUsePakjeGemakExpress = $helper->canUsePakjeGemakExpress();
|
657 |
return $canUsePakjeGemakExpress;
|
658 |
}
|
659 |
|
664 |
*/
|
665 |
public function canUsePakketAutomaat()
|
666 |
{
|
667 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
668 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
669 |
+
$canUsePakketAutomaat = $helper->canUsePakketAutomaat();
|
670 |
return $canUsePakketAutomaat;
|
671 |
}
|
672 |
|
677 |
*/
|
678 |
public function canUseDeliveryDays()
|
679 |
{
|
680 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
681 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
682 |
+
$canUseDeliveryDays = $helper->canUseDeliveryDays();
|
683 |
return $canUseDeliveryDays;
|
684 |
}
|
685 |
|
690 |
*/
|
691 |
public function canUseTimeframes()
|
692 |
{
|
693 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
694 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
695 |
+
$canUseTimeframes = $helper->canUseTimeframes();
|
696 |
return $canUseTimeframes;
|
697 |
}
|
698 |
|
703 |
*/
|
704 |
public function canUseEveningTimeframes()
|
705 |
{
|
706 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
707 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
708 |
+
$canUseEveningTimeframes = $helper->canUseEveningTimeframes();
|
709 |
return $canUseEveningTimeframes;
|
710 |
}
|
711 |
|
712 |
+
/**
|
713 |
+
* Checks whether the fallback timeframe should be shown or not.
|
714 |
+
*
|
715 |
+
* @return boolean
|
716 |
+
*/
|
717 |
+
public function canUseFallBackTimeframe()
|
718 |
+
{
|
719 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
720 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
721 |
+
$canUseFallBackTimeframe = $helper->canUseFallBackTimeframe();
|
722 |
+
return $canUseFallBackTimeframe;
|
723 |
+
}
|
724 |
+
|
725 |
/**
|
726 |
* Checks whether google streetview is allowed.
|
727 |
*
|
742 |
*/
|
743 |
public function canUseResponsive()
|
744 |
{
|
745 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
746 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
747 |
+
$canUseResponsive = $helper->canUseResponsive();
|
748 |
return $canUseResponsive;
|
749 |
}
|
750 |
|
766 |
/**
|
767 |
* @var Varien_Simplexml_Element $files
|
768 |
*/
|
769 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
770 |
$useCufon = (string) $theme->use_cufon;
|
771 |
if (!$useCufon) {
|
772 |
return false;
|
786 |
*/
|
787 |
public function canShowOnlyStatedAddressOption()
|
788 |
{
|
789 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
790 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
791 |
+
$canShowOnlyStatedAddressOptions = $helper->canShowOnlyStatedAddressOption();
|
792 |
return $canShowOnlyStatedAddressOptions;
|
793 |
}
|
794 |
|
799 |
*/
|
800 |
public function isOnlyStatedAddressOptionChecked()
|
801 |
{
|
802 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
803 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
804 |
+
$isOnlyStatedAddressOptionChecked = $helper->isOnlyStatedAddressOptionChecked();
|
805 |
return $isOnlyStatedAddressOptionChecked;
|
806 |
}
|
807 |
|
812 |
*/
|
813 |
public function canShowSeparateRates()
|
814 |
{
|
|
|
|
|
|
|
|
|
815 |
if (!$this->canUsePakjeGemak()) {
|
816 |
return false;
|
817 |
}
|
818 |
|
819 |
+
if (abs($this->getPakjeGemakFee()) < 0.01) {
|
820 |
return false;
|
821 |
}
|
822 |
|
830 |
*/
|
831 |
public function canUseSundaySorting()
|
832 |
{
|
833 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
834 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
835 |
+
$canUseSundaySorting = $helper->canUseSundaySorting();
|
836 |
return $canUseSundaySorting;
|
837 |
}
|
838 |
|
843 |
*/
|
844 |
public function getIsBuspakje()
|
845 |
{
|
846 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
847 |
$helper = Mage::helper('postnl');
|
848 |
|
849 |
/**
|
856 |
/**
|
857 |
* Check if the current quote fits as a letter box parcel.
|
858 |
*/
|
859 |
+
$quote = $this->getQuote();
|
860 |
if (!$helper->quoteIsBuspakje($quote)) {
|
861 |
return false;
|
862 |
}
|
871 |
*/
|
872 |
public function isDebugEnabled()
|
873 |
{
|
874 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
875 |
$helper = Mage::helper('postnl');
|
876 |
$debugMode = $helper->getDebugMode();
|
877 |
|
889 |
*/
|
890 |
public function canUseDeliveryOptions()
|
891 |
{
|
892 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
893 |
$helper = Mage::helper('postnl/deliveryOptions');
|
894 |
|
895 |
$quote = $this->getQuote();
|
950 |
);
|
951 |
}
|
952 |
|
953 |
+
/** @var TIG_PostNL_Model_DeliveryOptions_Cif $cif */
|
954 |
$cif = Mage::getModel('postnl_deliveryoptions/cif');
|
955 |
$response = $cif->setStoreId(Mage::app()->getStore()->getId())
|
956 |
->getDeliveryDate($postcode, $country, $quote);
|
964 |
|
965 |
return $dateObject->format('d-m-Y');
|
966 |
}
|
967 |
+
|
968 |
+
/**
|
969 |
+
* We added addslashes here to escape ' characters.
|
970 |
+
*
|
971 |
+
* @param mixed $data
|
972 |
+
* @param null $allowedTags
|
973 |
+
*
|
974 |
+
* @return string
|
975 |
+
*/
|
976 |
+
public function escapeJavascriptHtml($data, $allowedTags = null)
|
977 |
+
{
|
978 |
+
if (is_string($data)) {
|
979 |
+
return addslashes(parent::escapeHtml($data, $allowedTags));
|
980 |
+
} else {
|
981 |
+
return parent::escapeHtml($data, $allowedTags);
|
982 |
+
}
|
983 |
+
}
|
984 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_DeliveryOptions_Checkout_GoMage_LightCheckout_DeliveryOptions
|
@@ -63,4 +63,4 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_GoMage_LightCheckout_DeliveryOpt
|
|
63 |
$this->_isPostcodeAjaxEnabled = Mage::getStoreConfigFlag(self::XPATH_POSTCODE_AJAX_ENABLED);
|
64 |
return $this->_isPostcodeAjaxEnabled;
|
65 |
}
|
66 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_DeliveryOptions_Checkout_GoMage_LightCheckout_DeliveryOptions
|
63 |
$this->_isPostcodeAjaxEnabled = Mage::getStoreConfigFlag(self::XPATH_POSTCODE_AJAX_ENABLED);
|
64 |
return $this->_isPostcodeAjaxEnabled;
|
65 |
}
|
66 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_DeliveryOptions_Checkout_Progress extends TIG_PostNL_Block_DeliveryOptions_Template
|
@@ -83,4 +83,4 @@ class TIG_PostNL_Block_DeliveryOptions_Checkout_Progress extends TIG_PostNL_Bloc
|
|
83 |
|
84 |
return $pakjeGemakAddress->format('html');
|
85 |
}
|
86 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_DeliveryOptions_Checkout_Progress extends TIG_PostNL_Block_DeliveryOptions_Template
|
83 |
|
84 |
return $pakjeGemakAddress->format('html');
|
85 |
}
|
86 |
+
}
|
@@ -33,11 +33,11 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasApiKey()
|
40 |
-
* @method TIG_PostNL_Block_DeliveryOptions_Js setApiKey()
|
41 |
*/
|
42 |
class TIG_PostNL_Block_DeliveryOptions_Js extends TIG_PostNL_Block_DeliveryOptions_Template
|
43 |
{
|
@@ -86,4 +86,4 @@ class TIG_PostNL_Block_DeliveryOptions_Js extends TIG_PostNL_Block_DeliveryOptio
|
|
86 |
|
87 |
return parent::_toHtml();
|
88 |
}
|
89 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasApiKey()
|
40 |
+
* @method TIG_PostNL_Block_DeliveryOptions_Js setApiKey($apiKey)
|
41 |
*/
|
42 |
class TIG_PostNL_Block_DeliveryOptions_Js extends TIG_PostNL_Block_DeliveryOptions_Template
|
43 |
{
|
86 |
|
87 |
return parent::_toHtml();
|
88 |
}
|
89 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasApiKey()
|
@@ -53,10 +53,12 @@ class TIG_PostNL_Block_DeliveryOptions_PickupNotification extends TIG_PostNL_Blo
|
|
53 |
*/
|
54 |
protected function _toHtml()
|
55 |
{
|
56 |
-
|
|
|
|
|
57 |
return '';
|
58 |
}
|
59 |
|
60 |
return parent::_toHtml();
|
61 |
}
|
62 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasApiKey()
|
53 |
*/
|
54 |
protected function _toHtml()
|
55 |
{
|
56 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
57 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
58 |
+
if (!$helper->isDeliveryOptionsEnabled()) {
|
59 |
return '';
|
60 |
}
|
61 |
|
62 |
return parent::_toHtml();
|
63 |
}
|
64 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Block_DeliveryOptions_Template extends TIG_PostNL_Block_Core_Template
|
@@ -98,8 +98,11 @@ abstract class TIG_PostNL_Block_DeliveryOptions_Template extends TIG_PostNL_Bloc
|
|
98 |
return $this->_canUseDeliveryOptions;
|
99 |
}
|
100 |
|
101 |
-
|
|
|
|
|
102 |
|
|
|
103 |
$helper = Mage::helper('postnl/deliveryOptions');
|
104 |
$canUseDeliveryOptions = $helper->canUseDeliveryOptions($quote);
|
105 |
|
@@ -120,4 +123,4 @@ abstract class TIG_PostNL_Block_DeliveryOptions_Template extends TIG_PostNL_Bloc
|
|
120 |
|
121 |
return parent::_toHtml();
|
122 |
}
|
123 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Block_DeliveryOptions_Template extends TIG_PostNL_Block_Core_Template
|
98 |
return $this->_canUseDeliveryOptions;
|
99 |
}
|
100 |
|
101 |
+
/** @var Mage_Checkout_Model_Session $session */
|
102 |
+
$session = Mage::getSingleton('checkout/session');
|
103 |
+
$quote = $session->getQuote();
|
104 |
|
105 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
106 |
$helper = Mage::helper('postnl/deliveryOptions');
|
107 |
$canUseDeliveryOptions = $helper->canUseDeliveryOptions($quote);
|
108 |
|
123 |
|
124 |
return parent::_toHtml();
|
125 |
}
|
126 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsOsc()
|
@@ -97,6 +97,7 @@ class TIG_PostNL_Block_DeliveryOptions_Theme extends TIG_PostNL_Block_DeliveryOp
|
|
97 |
/**
|
98 |
* @var Varien_Simplexml_Element $files
|
99 |
*/
|
|
|
100 |
$files = $theme->files;
|
101 |
if (!$files) {
|
102 |
return '';
|
@@ -142,6 +143,7 @@ class TIG_PostNL_Block_DeliveryOptions_Theme extends TIG_PostNL_Block_DeliveryOp
|
|
142 |
/**
|
143 |
* @var Varien_Simplexml_Element $files
|
144 |
*/
|
|
|
145 |
$files = $theme->files;
|
146 |
if (!$files) {
|
147 |
return $cssFiles;
|
@@ -183,7 +185,9 @@ class TIG_PostNL_Block_DeliveryOptions_Theme extends TIG_PostNL_Block_DeliveryOp
|
|
183 |
*/
|
184 |
public function canUseResponsive()
|
185 |
{
|
186 |
-
|
|
|
|
|
187 |
}
|
188 |
|
189 |
/**
|
@@ -193,8 +197,11 @@ class TIG_PostNL_Block_DeliveryOptions_Theme extends TIG_PostNL_Block_DeliveryOp
|
|
193 |
*/
|
194 |
protected function _toHtml()
|
195 |
{
|
196 |
-
|
|
|
|
|
197 |
|
|
|
198 |
$helper = Mage::helper('postnl/deliveryOptions');
|
199 |
|
200 |
if (!$helper->canUseDeliveryOptions($quote)) {
|
@@ -203,4 +210,4 @@ class TIG_PostNL_Block_DeliveryOptions_Theme extends TIG_PostNL_Block_DeliveryOp
|
|
203 |
|
204 |
return parent::_toHtml();
|
205 |
}
|
206 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsOsc()
|
97 |
/**
|
98 |
* @var Varien_Simplexml_Element $files
|
99 |
*/
|
100 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
101 |
$files = $theme->files;
|
102 |
if (!$files) {
|
103 |
return '';
|
143 |
/**
|
144 |
* @var Varien_Simplexml_Element $files
|
145 |
*/
|
146 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
147 |
$files = $theme->files;
|
148 |
if (!$files) {
|
149 |
return $cssFiles;
|
185 |
*/
|
186 |
public function canUseResponsive()
|
187 |
{
|
188 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
189 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
190 |
+
return $helper->canUseResponsive();
|
191 |
}
|
192 |
|
193 |
/**
|
197 |
*/
|
198 |
protected function _toHtml()
|
199 |
{
|
200 |
+
/** @var Mage_Checkout_Model_Session $session */
|
201 |
+
$session = Mage::getSingleton('checkout/session');
|
202 |
+
$quote = $session->getQuote();
|
203 |
|
204 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
205 |
$helper = Mage::helper('postnl/deliveryOptions');
|
206 |
|
207 |
if (!$helper->canUseDeliveryOptions($quote)) {
|
210 |
|
211 |
return parent::_toHtml();
|
212 |
}
|
213 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasCanShowNotification()
|
@@ -92,7 +92,9 @@ class TIG_PostNL_Block_Mijnpakket_AccountNotification extends TIG_PostNL_Block_C
|
|
92 |
return $this->_getData('can_show_notification');
|
93 |
}
|
94 |
|
95 |
-
|
|
|
|
|
96 |
|
97 |
$this->setCanShowNotification($canShowNotification);
|
98 |
return $canShowNotification;
|
@@ -162,7 +164,10 @@ class TIG_PostNL_Block_Mijnpakket_AccountNotification extends TIG_PostNL_Block_C
|
|
162 |
return $this->_getData('order');
|
163 |
}
|
164 |
|
165 |
-
|
|
|
|
|
|
|
166 |
if (!$orderId) {
|
167 |
return false;
|
168 |
}
|
@@ -264,6 +269,7 @@ class TIG_PostNL_Block_Mijnpakket_AccountNotification extends TIG_PostNL_Block_C
|
|
264 |
return array('webshopPublicId' => $publicWebshopId);
|
265 |
}
|
266 |
|
|
|
267 |
$helper = Mage::helper('postnl/mijnpakket');
|
268 |
|
269 |
/**
|
@@ -284,6 +290,7 @@ class TIG_PostNL_Block_Mijnpakket_AccountNotification extends TIG_PostNL_Block_C
|
|
284 |
/**
|
285 |
* If this address has a VAT ID, it's probably a B2B client.
|
286 |
*/
|
|
|
287 |
$vat = $shippingAddress->getVatId();
|
288 |
if ($vat) {
|
289 |
$params['business'] = 'Z';
|
@@ -292,6 +299,7 @@ class TIG_PostNL_Block_Mijnpakket_AccountNotification extends TIG_PostNL_Block_C
|
|
292 |
/**
|
293 |
* Optionally add the dob.
|
294 |
*/
|
|
|
295 |
$dob = $shippingAddress->getDob();
|
296 |
if ($dob) {
|
297 |
$dob = new DateTime($dob);
|
@@ -313,9 +321,11 @@ class TIG_PostNL_Block_Mijnpakket_AccountNotification extends TIG_PostNL_Block_C
|
|
313 |
*/
|
314 |
$streetData = false;
|
315 |
try {
|
316 |
-
|
|
|
|
|
317 |
} catch (Exception $e) {
|
318 |
-
|
319 |
}
|
320 |
|
321 |
/**
|
@@ -345,4 +355,4 @@ class TIG_PostNL_Block_Mijnpakket_AccountNotification extends TIG_PostNL_Block_C
|
|
345 |
|
346 |
return parent::_toHtml();
|
347 |
}
|
348 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasCanShowNotification()
|
92 |
return $this->_getData('can_show_notification');
|
93 |
}
|
94 |
|
95 |
+
/** @var TIG_PostNL_Helper_Mijnpakket $helper */
|
96 |
+
$helper = Mage::helper('postnl/mijnpakket');
|
97 |
+
$canShowNotification = $helper->canShowMijnpakketNotification();
|
98 |
|
99 |
$this->setCanShowNotification($canShowNotification);
|
100 |
return $canShowNotification;
|
164 |
return $this->_getData('order');
|
165 |
}
|
166 |
|
167 |
+
/** @var Mage_Checkout_Model_Session $session */
|
168 |
+
$session = Mage::getSingleton('checkout/session');
|
169 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
170 |
+
$orderId = $session->getLastOrderId();
|
171 |
if (!$orderId) {
|
172 |
return false;
|
173 |
}
|
269 |
return array('webshopPublicId' => $publicWebshopId);
|
270 |
}
|
271 |
|
272 |
+
/** @var TIG_PostNL_Helper_Mijnpakket $helper */
|
273 |
$helper = Mage::helper('postnl/mijnpakket');
|
274 |
|
275 |
/**
|
290 |
/**
|
291 |
* If this address has a VAT ID, it's probably a B2B client.
|
292 |
*/
|
293 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
294 |
$vat = $shippingAddress->getVatId();
|
295 |
if ($vat) {
|
296 |
$params['business'] = 'Z';
|
299 |
/**
|
300 |
* Optionally add the dob.
|
301 |
*/
|
302 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
303 |
$dob = $shippingAddress->getDob();
|
304 |
if ($dob) {
|
305 |
$dob = new DateTime($dob);
|
321 |
*/
|
322 |
$streetData = false;
|
323 |
try {
|
324 |
+
/** @var TIG_PostNL_Helper_Cif $cifHelper */
|
325 |
+
$cifHelper = Mage::helper('postnl/cif');
|
326 |
+
$streetData = $cifHelper->getStreetData($order->getStoreId(), $shippingAddress, false);
|
327 |
} catch (Exception $e) {
|
328 |
+
$helper->logException($e);
|
329 |
}
|
330 |
|
331 |
/**
|
355 |
|
356 |
return parent::_toHtml();
|
357 |
}
|
358 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsTestMode()
|
@@ -70,7 +70,9 @@ class TIG_PostNL_Block_Mijnpakket_Js extends TIG_PostNL_Block_Core_Template
|
|
70 |
return $this->_getData('is_test_mode');
|
71 |
}
|
72 |
|
73 |
-
|
|
|
|
|
74 |
|
75 |
$this->setIsTestMode($isTestMode);
|
76 |
return $isTestMode;
|
@@ -133,6 +135,7 @@ class TIG_PostNL_Block_Mijnpakket_Js extends TIG_PostNL_Block_Core_Template
|
|
133 |
*/
|
134 |
protected function _tohtml()
|
135 |
{
|
|
|
136 |
$helper = Mage::helper('postnl/mijnpakket');
|
137 |
if (!$helper->canLoginWithMijnpakket()) {
|
138 |
return '';
|
@@ -140,4 +143,4 @@ class TIG_PostNL_Block_Mijnpakket_Js extends TIG_PostNL_Block_Core_Template
|
|
140 |
|
141 |
return parent::_toHtml();
|
142 |
}
|
143 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsTestMode()
|
70 |
return $this->_getData('is_test_mode');
|
71 |
}
|
72 |
|
73 |
+
/** @var TIG_PostNL_Helper_Mijnpakket $helper */
|
74 |
+
$helper = Mage::helper('postnl/mijnpakket');
|
75 |
+
$isTestMode = $helper->isTestMode();
|
76 |
|
77 |
$this->setIsTestMode($isTestMode);
|
78 |
return $isTestMode;
|
135 |
*/
|
136 |
protected function _tohtml()
|
137 |
{
|
138 |
+
/** @var TIG_PostNL_Helper_Mijnpakket $helper */
|
139 |
$helper = Mage::helper('postnl/mijnpakket');
|
140 |
if (!$helper->canLoginWithMijnpakket()) {
|
141 |
return '';
|
143 |
|
144 |
return parent::_toHtml();
|
145 |
}
|
146 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsTestMode()
|
@@ -82,7 +82,9 @@ class TIG_PostNL_Block_Mijnpakket_LoginButton extends TIG_PostNL_Block_Core_Temp
|
|
82 |
return $this->_getData('is_test_mode');
|
83 |
}
|
84 |
|
85 |
-
|
|
|
|
|
86 |
|
87 |
$this->setIsTestMode($isTestMode);
|
88 |
return $isTestMode;
|
@@ -140,7 +142,10 @@ class TIG_PostNL_Block_Mijnpakket_LoginButton extends TIG_PostNL_Block_Core_Temp
|
|
140 |
return $this->_getData('saved_mijnpakket_data');
|
141 |
}
|
142 |
|
143 |
-
|
|
|
|
|
|
|
144 |
|
145 |
$this->setSavedMijnpakketData($data);
|
146 |
return $data;
|
@@ -191,6 +196,7 @@ class TIG_PostNL_Block_Mijnpakket_LoginButton extends TIG_PostNL_Block_Core_Temp
|
|
191 |
*/
|
192 |
public function isDebugEnabled()
|
193 |
{
|
|
|
194 |
$helper = Mage::helper('postnl');
|
195 |
$debugMode = $helper->getDebugMode();
|
196 |
|
@@ -208,6 +214,7 @@ class TIG_PostNL_Block_Mijnpakket_LoginButton extends TIG_PostNL_Block_Core_Temp
|
|
208 |
*/
|
209 |
protected function _tohtml()
|
210 |
{
|
|
|
211 |
$helper = Mage::helper('postnl/mijnpakket');
|
212 |
if (!$helper->canLoginWithMijnpakket()) {
|
213 |
return '';
|
@@ -215,4 +222,4 @@ class TIG_PostNL_Block_Mijnpakket_LoginButton extends TIG_PostNL_Block_Core_Temp
|
|
215 |
|
216 |
return parent::_toHtml();
|
217 |
}
|
218 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsTestMode()
|
82 |
return $this->_getData('is_test_mode');
|
83 |
}
|
84 |
|
85 |
+
/** @var TIG_PostNL_Helper_Mijnpakket $helper */
|
86 |
+
$helper = Mage::helper('postnl/mijnpakket');
|
87 |
+
$isTestMode = $helper->isTestMode();
|
88 |
|
89 |
$this->setIsTestMode($isTestMode);
|
90 |
return $isTestMode;
|
142 |
return $this->_getData('saved_mijnpakket_data');
|
143 |
}
|
144 |
|
145 |
+
/** @var Mage_Checkout_Model_Session $session */
|
146 |
+
$session = Mage::getSingleton('checkout/session');
|
147 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
148 |
+
$data = $session->getPostnlMijnpakketData();
|
149 |
|
150 |
$this->setSavedMijnpakketData($data);
|
151 |
return $data;
|
196 |
*/
|
197 |
public function isDebugEnabled()
|
198 |
{
|
199 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
200 |
$helper = Mage::helper('postnl');
|
201 |
$debugMode = $helper->getDebugMode();
|
202 |
|
214 |
*/
|
215 |
protected function _tohtml()
|
216 |
{
|
217 |
+
/** @var TIG_PostNL_Helper_Mijnpakket $helper */
|
218 |
$helper = Mage::helper('postnl/mijnpakket');
|
219 |
if (!$helper->canLoginWithMijnpakket()) {
|
220 |
return '';
|
222 |
|
223 |
return parent::_toHtml();
|
224 |
}
|
225 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsTestMode()
|
@@ -60,6 +60,7 @@ class TIG_PostNL_Block_Mijnpakket_OrderSuccessJs extends TIG_PostNL_Block_Checko
|
|
60 |
*/
|
61 |
protected function _tohtml()
|
62 |
{
|
|
|
63 |
$helper = Mage::helper('postnl/mijnpakket');
|
64 |
if (!$helper->canShowMijnpakketNotification()) {
|
65 |
return '';
|
@@ -67,4 +68,4 @@ class TIG_PostNL_Block_Mijnpakket_OrderSuccessJs extends TIG_PostNL_Block_Checko
|
|
67 |
|
68 |
return TIG_PostNL_Block_Core_Template::_toHtml();
|
69 |
}
|
70 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsTestMode()
|
60 |
*/
|
61 |
protected function _tohtml()
|
62 |
{
|
63 |
+
/** @var TIG_PostNL_Helper_Mijnpakket $helper */
|
64 |
$helper = Mage::helper('postnl/mijnpakket');
|
65 |
if (!$helper->canShowMijnpakketNotification()) {
|
66 |
return '';
|
68 |
|
69 |
return TIG_PostNL_Block_Core_Template::_toHtml();
|
70 |
}
|
71 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Varien_Object getTotal()
|
@@ -78,7 +78,9 @@ class TIG_PostNL_Block_Payment_Checkout_Total_CodFee extends Mage_Checkout_Block
|
|
78 |
*/
|
79 |
public function getTaxLabel($inclTax = false)
|
80 |
{
|
81 |
-
|
|
|
|
|
82 |
|
83 |
return $taxLabel;
|
84 |
}
|
@@ -92,14 +94,17 @@ class TIG_PostNL_Block_Payment_Checkout_Total_CodFee extends Mage_Checkout_Block
|
|
92 |
*/
|
93 |
public function getValue($inclTax = false)
|
94 |
{
|
|
|
95 |
$address = $this->getTotal()->getAddress();
|
96 |
|
|
|
97 |
$exclTax = $address->getPostnlCodFee();
|
98 |
if (!$inclTax) {
|
99 |
return $exclTax;
|
100 |
}
|
101 |
|
|
|
102 |
$inclTax = $exclTax + $address->getPostnlCodFeeTax();
|
103 |
return $inclTax;
|
104 |
}
|
105 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Varien_Object getTotal()
|
78 |
*/
|
79 |
public function getTaxLabel($inclTax = false)
|
80 |
{
|
81 |
+
/** @var Mage_Tax_Helper_Data $helper */
|
82 |
+
$helper = Mage::helper('tax');
|
83 |
+
$taxLabel = $helper->getIncExcTaxLabel($inclTax);
|
84 |
|
85 |
return $taxLabel;
|
86 |
}
|
94 |
*/
|
95 |
public function getValue($inclTax = false)
|
96 |
{
|
97 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
98 |
$address = $this->getTotal()->getAddress();
|
99 |
|
100 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
101 |
$exclTax = $address->getPostnlCodFee();
|
102 |
if (!$inclTax) {
|
103 |
return $exclTax;
|
104 |
}
|
105 |
|
106 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
107 |
$inclTax = $exclTax + $address->getPostnlCodFeeTax();
|
108 |
return $inclTax;
|
109 |
}
|
110 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Form_Cod extends Mage_Payment_Block_Form
|
@@ -66,6 +66,7 @@ class TIG_PostNL_Block_Payment_Form_Cod extends Mage_Payment_Block_Form
|
|
66 |
public function getInstructions()
|
67 |
{
|
68 |
if (is_null($this->_instructions)) {
|
|
|
69 |
$this->_instructions = $this->getMethod()->getInstructions();
|
70 |
}
|
71 |
return $this->_instructions;
|
@@ -89,6 +90,7 @@ class TIG_PostNL_Block_Payment_Form_Cod extends Mage_Payment_Block_Form
|
|
89 |
/**
|
90 |
* Check if the buspakje calculation mode is set to automatic.
|
91 |
*/
|
|
|
92 |
$helper = Mage::helper('postnl');
|
93 |
$calculationMode = $helper->getBuspakjeCalculationMode();
|
94 |
if ($calculationMode != 'automatic') {
|
@@ -98,7 +100,9 @@ class TIG_PostNL_Block_Payment_Form_Cod extends Mage_Payment_Block_Form
|
|
98 |
/**
|
99 |
* Check if the current quote fits as a letter box parcel.
|
100 |
*/
|
101 |
-
|
|
|
|
|
102 |
if (!$helper->fitsAsBuspakje($quote->getAllItems())) {
|
103 |
return true;
|
104 |
}
|
@@ -120,4 +124,4 @@ class TIG_PostNL_Block_Payment_Form_Cod extends Mage_Payment_Block_Form
|
|
120 |
Mage::dispatchEvent($this->_eventPrefix . '_to_html_after');
|
121 |
return $html;
|
122 |
}
|
123 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Form_Cod extends Mage_Payment_Block_Form
|
66 |
public function getInstructions()
|
67 |
{
|
68 |
if (is_null($this->_instructions)) {
|
69 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
70 |
$this->_instructions = $this->getMethod()->getInstructions();
|
71 |
}
|
72 |
return $this->_instructions;
|
90 |
/**
|
91 |
* Check if the buspakje calculation mode is set to automatic.
|
92 |
*/
|
93 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
94 |
$helper = Mage::helper('postnl');
|
95 |
$calculationMode = $helper->getBuspakjeCalculationMode();
|
96 |
if ($calculationMode != 'automatic') {
|
100 |
/**
|
101 |
* Check if the current quote fits as a letter box parcel.
|
102 |
*/
|
103 |
+
/** @var Mage_Checkout_Model_Session $session */
|
104 |
+
$session = Mage::getSingleton('checkout/session');
|
105 |
+
$quote = $session->getQuote();
|
106 |
if (!$helper->fitsAsBuspakje($quote->getAllItems())) {
|
107 |
return true;
|
108 |
}
|
124 |
Mage::dispatchEvent($this->_eventPrefix . '_to_html_after');
|
125 |
return $html;
|
126 |
}
|
127 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Info extends Mage_Payment_Block_Info
|
@@ -58,4 +58,4 @@ class TIG_PostNL_Block_Payment_Info extends Mage_Payment_Block_Info
|
|
58 |
return $html;
|
59 |
}
|
60 |
|
61 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Info extends Mage_Payment_Block_Info
|
58 |
return $html;
|
59 |
}
|
60 |
|
61 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Sales_Order_Creditmemo_Totals_CodFee extends Mage_Sales_Block_Order_Creditmemo_Totals
|
@@ -62,9 +62,12 @@ class TIG_PostNL_Block_Payment_Sales_Order_Creditmemo_Totals_CodFee extends Mage
|
|
62 |
* @var Mage_Sales_Model_Order_Creditmemo $creditmemo
|
63 |
*/
|
64 |
$parent = $this->getParentBlock();
|
|
|
65 |
$creditmemo = $parent->getCreditmemo();
|
66 |
|
|
|
67 |
$fee = $creditmemo->getPostnlCodFee();
|
|
|
68 |
$baseFee = $creditmemo->getBasePostnlCodFee();
|
69 |
|
70 |
if ($fee < 0.01 || $baseFee < 0.01) {
|
@@ -72,7 +75,9 @@ class TIG_PostNL_Block_Payment_Sales_Order_Creditmemo_Totals_CodFee extends Mage
|
|
72 |
}
|
73 |
|
74 |
$displayMode = $this->getDisplayMode();
|
75 |
-
|
|
|
|
|
76 |
|
77 |
if ($displayMode === self::DISPLAY_MODE_EXCL
|
78 |
|| $displayMode === self::DISPLAY_MODE_BOTH
|
@@ -84,6 +89,7 @@ class TIG_PostNL_Block_Payment_Sales_Order_Creditmemo_Totals_CodFee extends Mage
|
|
84 |
}
|
85 |
|
86 |
$total = new Varien_Object();
|
|
|
87 |
$total->setLabel($label)
|
88 |
->setValue($fee)
|
89 |
->setBaseValue($baseFee)
|
@@ -102,6 +108,7 @@ class TIG_PostNL_Block_Payment_Sales_Order_Creditmemo_Totals_CodFee extends Mage
|
|
102 |
}
|
103 |
|
104 |
$totalInclTax = new Varien_Object();
|
|
|
105 |
$totalInclTax->setLabel($label)
|
106 |
->setValue($fee + $creditmemo->getPostnlCodFeeTax())
|
107 |
->setBaseValue($baseFee + $creditmemo->getBasePostnlCodFeeTax())
|
@@ -120,7 +127,7 @@ class TIG_PostNL_Block_Payment_Sales_Order_Creditmemo_Totals_CodFee extends Mage
|
|
120 |
*/
|
121 |
public function getDisplayMode()
|
122 |
{
|
123 |
-
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE
|
124 |
|
125 |
return $displayMode;
|
126 |
}
|
@@ -134,8 +141,10 @@ class TIG_PostNL_Block_Payment_Sales_Order_Creditmemo_Totals_CodFee extends Mage
|
|
134 |
*/
|
135 |
public function getTaxLabel($inclTax = false)
|
136 |
{
|
137 |
-
|
|
|
|
|
138 |
|
139 |
return $taxLabel;
|
140 |
}
|
141 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Sales_Order_Creditmemo_Totals_CodFee extends Mage_Sales_Block_Order_Creditmemo_Totals
|
62 |
* @var Mage_Sales_Model_Order_Creditmemo $creditmemo
|
63 |
*/
|
64 |
$parent = $this->getParentBlock();
|
65 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
66 |
$creditmemo = $parent->getCreditmemo();
|
67 |
|
68 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
69 |
$fee = $creditmemo->getPostnlCodFee();
|
70 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
71 |
$baseFee = $creditmemo->getBasePostnlCodFee();
|
72 |
|
73 |
if ($fee < 0.01 || $baseFee < 0.01) {
|
75 |
}
|
76 |
|
77 |
$displayMode = $this->getDisplayMode();
|
78 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
79 |
+
$helper = Mage::helper('postnl/payment');
|
80 |
+
$baseLabel = $helper->getPostnlCodFeeLabel($creditmemo->getStoreId());
|
81 |
|
82 |
if ($displayMode === self::DISPLAY_MODE_EXCL
|
83 |
|| $displayMode === self::DISPLAY_MODE_BOTH
|
89 |
}
|
90 |
|
91 |
$total = new Varien_Object();
|
92 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
93 |
$total->setLabel($label)
|
94 |
->setValue($fee)
|
95 |
->setBaseValue($baseFee)
|
108 |
}
|
109 |
|
110 |
$totalInclTax = new Varien_Object();
|
111 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
112 |
$totalInclTax->setLabel($label)
|
113 |
->setValue($fee + $creditmemo->getPostnlCodFeeTax())
|
114 |
->setBaseValue($baseFee + $creditmemo->getBasePostnlCodFeeTax())
|
127 |
*/
|
128 |
public function getDisplayMode()
|
129 |
{
|
130 |
+
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE);
|
131 |
|
132 |
return $displayMode;
|
133 |
}
|
141 |
*/
|
142 |
public function getTaxLabel($inclTax = false)
|
143 |
{
|
144 |
+
/** @var Mage_Tax_Helper_Data $helper */
|
145 |
+
$helper = Mage::helper('tax');
|
146 |
+
$taxLabel = $helper->getIncExcText($inclTax);
|
147 |
|
148 |
return $taxLabel;
|
149 |
}
|
150 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Sales_Order_Invoice_Totals_CodFee extends Mage_Sales_Block_Order_Invoice_Totals
|
@@ -71,7 +71,9 @@ class TIG_PostNL_Block_Payment_Sales_Order_Invoice_Totals_CodFee extends Mage_Sa
|
|
71 |
}
|
72 |
|
73 |
$displayMode = $this->getDisplayMode();
|
74 |
-
|
|
|
|
|
75 |
|
76 |
if ($displayMode === self::DISPLAY_MODE_EXCL || $displayMode === self::DISPLAY_MODE_BOTH) {
|
77 |
$label = $baseLabel;
|
@@ -80,6 +82,7 @@ class TIG_PostNL_Block_Payment_Sales_Order_Invoice_Totals_CodFee extends Mage_Sa
|
|
80 |
}
|
81 |
|
82 |
$total = new Varien_Object();
|
|
|
83 |
$total->setLabel($label)
|
84 |
->setValue($fee)
|
85 |
->setBaseValue($baseFee)
|
@@ -95,6 +98,7 @@ class TIG_PostNL_Block_Payment_Sales_Order_Invoice_Totals_CodFee extends Mage_Sa
|
|
95 |
}
|
96 |
|
97 |
$totalInclTax = new Varien_Object();
|
|
|
98 |
$totalInclTax->setLabel($label)
|
99 |
->setValue($fee + $invoice->getPostnlCodFeeTax())
|
100 |
->setBaseValue($baseFee + $invoice->getBasePostnlCodFeeTax())
|
@@ -113,7 +117,7 @@ class TIG_PostNL_Block_Payment_Sales_Order_Invoice_Totals_CodFee extends Mage_Sa
|
|
113 |
*/
|
114 |
public function getDisplayMode()
|
115 |
{
|
116 |
-
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE
|
117 |
|
118 |
return $displayMode;
|
119 |
}
|
@@ -127,8 +131,10 @@ class TIG_PostNL_Block_Payment_Sales_Order_Invoice_Totals_CodFee extends Mage_Sa
|
|
127 |
*/
|
128 |
public function getTaxLabel($inclTax = false)
|
129 |
{
|
130 |
-
|
|
|
|
|
131 |
|
132 |
return $taxLabel;
|
133 |
}
|
134 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Sales_Order_Invoice_Totals_CodFee extends Mage_Sales_Block_Order_Invoice_Totals
|
71 |
}
|
72 |
|
73 |
$displayMode = $this->getDisplayMode();
|
74 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
75 |
+
$helper = Mage::helper('postnl/payment');
|
76 |
+
$baseLabel = $helper->getPostnlCodFeeLabel($invoice->getStoreId());
|
77 |
|
78 |
if ($displayMode === self::DISPLAY_MODE_EXCL || $displayMode === self::DISPLAY_MODE_BOTH) {
|
79 |
$label = $baseLabel;
|
82 |
}
|
83 |
|
84 |
$total = new Varien_Object();
|
85 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
86 |
$total->setLabel($label)
|
87 |
->setValue($fee)
|
88 |
->setBaseValue($baseFee)
|
98 |
}
|
99 |
|
100 |
$totalInclTax = new Varien_Object();
|
101 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
102 |
$totalInclTax->setLabel($label)
|
103 |
->setValue($fee + $invoice->getPostnlCodFeeTax())
|
104 |
->setBaseValue($baseFee + $invoice->getBasePostnlCodFeeTax())
|
117 |
*/
|
118 |
public function getDisplayMode()
|
119 |
{
|
120 |
+
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE);
|
121 |
|
122 |
return $displayMode;
|
123 |
}
|
131 |
*/
|
132 |
public function getTaxLabel($inclTax = false)
|
133 |
{
|
134 |
+
/** @var Mage_Tax_Helper_Data $helper */
|
135 |
+
$helper = Mage::helper('tax');
|
136 |
+
$taxLabel = $helper->getIncExcText($inclTax);
|
137 |
|
138 |
return $taxLabel;
|
139 |
}
|
140 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Sales_Order_Totals_CodFee extends Mage_Sales_Block_Order_Totals
|
@@ -60,7 +60,9 @@ class TIG_PostNL_Block_Payment_Sales_Order_Totals_CodFee extends Mage_Sales_Bloc
|
|
60 |
$parent = $this->getParentBlock();
|
61 |
$order = $this->getOrder();
|
62 |
|
|
|
63 |
$fee = $order->getPostnlCodFee();
|
|
|
64 |
$baseFee = $order->getBasePostnlCodFee();
|
65 |
|
66 |
if ($fee < 0.01 || $baseFee < 0.01) {
|
@@ -68,7 +70,10 @@ class TIG_PostNL_Block_Payment_Sales_Order_Totals_CodFee extends Mage_Sales_Bloc
|
|
68 |
}
|
69 |
|
70 |
$displayMode = $this->getDisplayMode();
|
71 |
-
|
|
|
|
|
|
|
72 |
|
73 |
if ($displayMode === self::DISPLAY_MODE_EXCL || $displayMode === self::DISPLAY_MODE_BOTH) {
|
74 |
$label = $baseLabel;
|
@@ -77,11 +82,13 @@ class TIG_PostNL_Block_Payment_Sales_Order_Totals_CodFee extends Mage_Sales_Bloc
|
|
77 |
}
|
78 |
|
79 |
$total = new Varien_Object();
|
|
|
80 |
$total->setLabel($label)
|
81 |
->setValue($fee)
|
82 |
->setBaseValue($baseFee)
|
83 |
->setCode('postnl_cod_fee');
|
84 |
|
|
|
85 |
$parent->addTotalBefore($total, 'shipping');
|
86 |
}
|
87 |
|
@@ -92,11 +99,13 @@ class TIG_PostNL_Block_Payment_Sales_Order_Totals_CodFee extends Mage_Sales_Bloc
|
|
92 |
}
|
93 |
|
94 |
$totalInclTax = new Varien_Object();
|
|
|
95 |
$totalInclTax->setLabel($label)
|
96 |
->setValue($fee + $order->getPostnlCodFeeTax())
|
97 |
->setBaseValue($baseFee + $order->getBasePostnlCodFeeTax())
|
98 |
->setCode('postnl_cod_fee_incl_tax');
|
99 |
|
|
|
100 |
$parent->addTotalBefore($totalInclTax, 'shipping');
|
101 |
}
|
102 |
|
@@ -110,7 +119,7 @@ class TIG_PostNL_Block_Payment_Sales_Order_Totals_CodFee extends Mage_Sales_Bloc
|
|
110 |
*/
|
111 |
public function getDisplayMode()
|
112 |
{
|
113 |
-
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE
|
114 |
|
115 |
return $displayMode;
|
116 |
}
|
@@ -124,8 +133,10 @@ class TIG_PostNL_Block_Payment_Sales_Order_Totals_CodFee extends Mage_Sales_Bloc
|
|
124 |
*/
|
125 |
public function getTaxLabel($inclTax = false)
|
126 |
{
|
127 |
-
|
|
|
|
|
128 |
|
129 |
return $taxLabel;
|
130 |
}
|
131 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Block_Payment_Sales_Order_Totals_CodFee extends Mage_Sales_Block_Order_Totals
|
60 |
$parent = $this->getParentBlock();
|
61 |
$order = $this->getOrder();
|
62 |
|
63 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
64 |
$fee = $order->getPostnlCodFee();
|
65 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
66 |
$baseFee = $order->getBasePostnlCodFee();
|
67 |
|
68 |
if ($fee < 0.01 || $baseFee < 0.01) {
|
70 |
}
|
71 |
|
72 |
$displayMode = $this->getDisplayMode();
|
73 |
+
|
74 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
75 |
+
$helper = Mage::helper('postnl/payment');
|
76 |
+
$baseLabel = $helper->getPostnlCodFeeLabel($order->getStoreId());
|
77 |
|
78 |
if ($displayMode === self::DISPLAY_MODE_EXCL || $displayMode === self::DISPLAY_MODE_BOTH) {
|
79 |
$label = $baseLabel;
|
82 |
}
|
83 |
|
84 |
$total = new Varien_Object();
|
85 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
86 |
$total->setLabel($label)
|
87 |
->setValue($fee)
|
88 |
->setBaseValue($baseFee)
|
89 |
->setCode('postnl_cod_fee');
|
90 |
|
91 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
92 |
$parent->addTotalBefore($total, 'shipping');
|
93 |
}
|
94 |
|
99 |
}
|
100 |
|
101 |
$totalInclTax = new Varien_Object();
|
102 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
103 |
$totalInclTax->setLabel($label)
|
104 |
->setValue($fee + $order->getPostnlCodFeeTax())
|
105 |
->setBaseValue($baseFee + $order->getBasePostnlCodFeeTax())
|
106 |
->setCode('postnl_cod_fee_incl_tax');
|
107 |
|
108 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
109 |
$parent->addTotalBefore($totalInclTax, 'shipping');
|
110 |
}
|
111 |
|
119 |
*/
|
120 |
public function getDisplayMode()
|
121 |
{
|
122 |
+
$displayMode = (int) Mage::getStoreConfig(self::XPATH_DISPLAY_MODE_COD_FEE);
|
123 |
|
124 |
return $displayMode;
|
125 |
}
|
133 |
*/
|
134 |
public function getTaxLabel($inclTax = false)
|
135 |
{
|
136 |
+
/** @var Mage_Tax_Helper_Data $helper */
|
137 |
+
$helper = Mage::helper('tax');
|
138 |
+
$taxLabel = $helper->getIncExcText($inclTax);
|
139 |
|
140 |
return $taxLabel;
|
141 |
}
|
142 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Controller_Adminhtml_Abstract extends Mage_Adminhtml_Controller_Action
|
@@ -67,9 +67,10 @@ abstract class TIG_PostNL_Controller_Adminhtml_Abstract extends Mage_Adminhtml_C
|
|
67 |
*/
|
68 |
protected function _checkIsAllowed($actions = array())
|
69 |
{
|
|
|
70 |
$helper = Mage::helper('postnl');
|
71 |
$isAllowed = $helper->checkIsPostnlActionAllowed($actions, false);
|
72 |
|
73 |
return $isAllowed;
|
74 |
}
|
75 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Controller_Adminhtml_Abstract extends Mage_Adminhtml_Controller_Action
|
67 |
*/
|
68 |
protected function _checkIsAllowed($actions = array())
|
69 |
{
|
70 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
71 |
$helper = Mage::helper('postnl');
|
72 |
$isAllowed = $helper->checkIsPostnlActionAllowed($actions, false);
|
73 |
|
74 |
return $isAllowed;
|
75 |
}
|
76 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Controller_Adminhtml_Config extends TIG_PostNL_Controller_Adminhtml_Abstract
|
@@ -56,11 +56,12 @@ class TIG_PostNL_Controller_Adminhtml_Config extends TIG_PostNL_Controller_Admin
|
|
56 |
{
|
57 |
$step = $this->_validateStep($step);
|
58 |
|
59 |
-
/**
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
$
|
|
|
64 |
|
65 |
$extra['postnl']['current_wizard_step'] = $step;
|
66 |
|
@@ -94,4 +95,4 @@ class TIG_PostNL_Controller_Adminhtml_Config extends TIG_PostNL_Controller_Admin
|
|
94 |
|
95 |
return $step;
|
96 |
}
|
97 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Controller_Adminhtml_Config extends TIG_PostNL_Controller_Adminhtml_Abstract
|
56 |
{
|
57 |
$step = $this->_validateStep($step);
|
58 |
|
59 |
+
/** @var Mage_Admin_Model_Session $adminSession */
|
60 |
+
$adminSession = Mage::getSingleton('admin/session');
|
61 |
+
/** @var Mage_Admin_Model_User $adminUser */
|
62 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
63 |
+
$adminUser = $adminSession->getUser();
|
64 |
+
$extra = $adminUser->getExtra();
|
65 |
|
66 |
$extra['postnl']['current_wizard_step'] = $step;
|
67 |
|
95 |
|
96 |
return $step;
|
97 |
}
|
98 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Controller_Adminhtml_Shipment extends TIG_PostNL_Controller_Adminhtml_Abstract
|
@@ -50,6 +50,7 @@ class TIG_PostNL_Controller_Adminhtml_Shipment extends TIG_PostNL_Controller_Adm
|
|
50 |
{
|
51 |
$serviceModel = $this->_serviceModel;
|
52 |
if (!$serviceModel) {
|
|
|
53 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
54 |
$this->setServiceModel($serviceModel);
|
55 |
}
|
@@ -308,6 +309,7 @@ class TIG_PostNL_Controller_Adminhtml_Shipment extends TIG_PostNL_Controller_Adm
|
|
308 |
*/
|
309 |
protected function _addWarningMessages($warnings, $headerText = '')
|
310 |
{
|
|
|
311 |
$helper = Mage::helper('postnl');
|
312 |
|
313 |
/**
|
@@ -383,10 +385,10 @@ class TIG_PostNL_Controller_Adminhtml_Shipment extends TIG_PostNL_Controller_Adm
|
|
383 |
/**
|
384 |
* Add the warnings to the session.
|
385 |
*/
|
386 |
-
|
387 |
$warningMessage
|
388 |
);
|
389 |
|
390 |
return $this;
|
391 |
}
|
392 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Controller_Adminhtml_Shipment extends TIG_PostNL_Controller_Adminhtml_Abstract
|
50 |
{
|
51 |
$serviceModel = $this->_serviceModel;
|
52 |
if (!$serviceModel) {
|
53 |
+
/** @var TIG_PostNL_Model_Core_Service_Shipment $serviceModel */
|
54 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
55 |
$this->setServiceModel($serviceModel);
|
56 |
}
|
309 |
*/
|
310 |
protected function _addWarningMessages($warnings, $headerText = '')
|
311 |
{
|
312 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
313 |
$helper = Mage::helper('postnl');
|
314 |
|
315 |
/**
|
385 |
/**
|
386 |
* Add the warnings to the session.
|
387 |
*/
|
388 |
+
$helper->addSessionMessage('adminhtml/session', null, 'notice',
|
389 |
$warningMessage
|
390 |
);
|
391 |
|
392 |
return $this;
|
393 |
}
|
394 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
@@ -63,7 +63,9 @@ class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
|
63 |
}
|
64 |
|
65 |
$order = Mage::registry('current_order');
|
66 |
-
|
|
|
|
|
67 |
$this->_redirect($this->getErrorRedirect());
|
68 |
return;
|
69 |
}
|
@@ -95,10 +97,9 @@ class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
|
95 |
return $this;
|
96 |
}
|
97 |
|
98 |
-
/**
|
99 |
-
* @var TIG_postNL_Model_Core_Shipment $postnlShipment
|
100 |
-
*/
|
101 |
$helper = Mage::helper('postnl');
|
|
|
102 |
$postnlShipment = Mage::registry('current_postnl_shipment');
|
103 |
|
104 |
try {
|
@@ -118,6 +119,7 @@ class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
|
118 |
/**
|
119 |
* Merge the labels and print them.
|
120 |
*/
|
|
|
121 |
$labelModel = Mage::getModel('postnl_core/label');
|
122 |
$output = $labelModel->setLabelSize('A6')->createPdf($labels);
|
123 |
|
@@ -186,6 +188,7 @@ class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
|
186 |
return false;
|
187 |
}
|
188 |
|
|
|
189 |
$order = Mage::getModel('sales/order')->load($orderId);
|
190 |
|
191 |
if ($this->_canViewOrder($order)) {
|
@@ -217,6 +220,7 @@ class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
|
217 |
|
218 |
$shipmentId = Mage::getResourceModel('postnl/order_shipment')->getShipmentId($shipmentIncrementId);
|
219 |
|
|
|
220 |
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipmentId, 'shipment_id');
|
221 |
|
222 |
if ($this->_canViewPostnlShipment($postnlShipment)) {
|
@@ -236,8 +240,13 @@ class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
|
236 |
*/
|
237 |
protected function _canViewOrder($order)
|
238 |
{
|
239 |
-
|
240 |
-
$
|
|
|
|
|
|
|
|
|
|
|
241 |
if ($order->getId() && $order->getCustomerId() && ($order->getCustomerId() == $customerId)
|
242 |
&& in_array($order->getState(), $availableStates, $strict = true)
|
243 |
) {
|
@@ -255,8 +264,13 @@ class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
|
255 |
*/
|
256 |
protected function _canViewPostnlShipment(TIG_PostNL_Model_Core_Shipment $postnlShipment)
|
257 |
{
|
258 |
-
|
259 |
-
$
|
|
|
|
|
|
|
|
|
|
|
260 |
$order = $postnlShipment->getOrder();
|
261 |
|
262 |
if ($postnlShipment->getId()
|
@@ -317,7 +331,9 @@ class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
|
317 |
$postnlShipment->generateBarcodes();
|
318 |
}
|
319 |
|
320 |
-
|
|
|
|
|
321 |
if ($printReturnLabel && $postnlShipment->canGenerateReturnBarcode()) {
|
322 |
$postnlShipment->generateReturnBarcode();
|
323 |
}
|
@@ -330,4 +346,4 @@ class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
|
330 |
|
331 |
return $postnlShipment;
|
332 |
}
|
333 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Controller_Sales extends Mage_Core_Controller_Front_Action
|
63 |
}
|
64 |
|
65 |
$order = Mage::registry('current_order');
|
66 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
67 |
+
$helper = Mage::helper('postnl');
|
68 |
+
if (!$helper->canPrintReturnLabelForOrder($order)) {
|
69 |
$this->_redirect($this->getErrorRedirect());
|
70 |
return;
|
71 |
}
|
97 |
return $this;
|
98 |
}
|
99 |
|
100 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
|
|
|
|
101 |
$helper = Mage::helper('postnl');
|
102 |
+
/** @var TIG_postNL_Model_Core_Shipment $postnlShipment */
|
103 |
$postnlShipment = Mage::registry('current_postnl_shipment');
|
104 |
|
105 |
try {
|
119 |
/**
|
120 |
* Merge the labels and print them.
|
121 |
*/
|
122 |
+
/** @var TIG_PostNL_Model_Core_Label $labelModel */
|
123 |
$labelModel = Mage::getModel('postnl_core/label');
|
124 |
$output = $labelModel->setLabelSize('A6')->createPdf($labels);
|
125 |
|
188 |
return false;
|
189 |
}
|
190 |
|
191 |
+
/** @var Mage_Sales_Model_Order $order */
|
192 |
$order = Mage::getModel('sales/order')->load($orderId);
|
193 |
|
194 |
if ($this->_canViewOrder($order)) {
|
220 |
|
221 |
$shipmentId = Mage::getResourceModel('postnl/order_shipment')->getShipmentId($shipmentIncrementId);
|
222 |
|
223 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
224 |
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipmentId, 'shipment_id');
|
225 |
|
226 |
if ($this->_canViewPostnlShipment($postnlShipment)) {
|
240 |
*/
|
241 |
protected function _canViewOrder($order)
|
242 |
{
|
243 |
+
/** @var Mage_Customer_Model_Session $session */
|
244 |
+
$session = Mage::getSingleton('customer/session');
|
245 |
+
$customerId = $session->getCustomerId();
|
246 |
+
|
247 |
+
/** @var Mage_Sales_Model_Order_Config $config */
|
248 |
+
$config = Mage::getSingleton('sales/order_config');
|
249 |
+
$availableStates = $config->getVisibleOnFrontStates();
|
250 |
if ($order->getId() && $order->getCustomerId() && ($order->getCustomerId() == $customerId)
|
251 |
&& in_array($order->getState(), $availableStates, $strict = true)
|
252 |
) {
|
264 |
*/
|
265 |
protected function _canViewPostnlShipment(TIG_PostNL_Model_Core_Shipment $postnlShipment)
|
266 |
{
|
267 |
+
/** @var Mage_Customer_Model_Session $session */
|
268 |
+
$session = Mage::getSingleton('customer/session');
|
269 |
+
$customerId = $session->getCustomerId();
|
270 |
+
|
271 |
+
/** @var Mage_Sales_Model_Order_Config $config */
|
272 |
+
$config = Mage::getSingleton('sales/order_config');
|
273 |
+
$availableStates = $config->getVisibleOnFrontStates();
|
274 |
$order = $postnlShipment->getOrder();
|
275 |
|
276 |
if ($postnlShipment->getId()
|
331 |
$postnlShipment->generateBarcodes();
|
332 |
}
|
333 |
|
334 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
335 |
+
$helper = Mage::helper('postnl/cif');
|
336 |
+
$printReturnLabel = $helper->isReturnsEnabled($postnlShipment->getStoreId());
|
337 |
if ($printReturnLabel && $postnlShipment->canGenerateReturnBarcode()) {
|
338 |
$postnlShipment->generateReturnBarcode();
|
339 |
}
|
346 |
|
347 |
return $postnlShipment;
|
348 |
}
|
349 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* General exception class for TIG_PostNL extension
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* General exception class for TIG_PostNL extension
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
@@ -102,6 +102,28 @@ class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
|
102 |
*/
|
103 |
const XPATH_POSTCODE_NL_EXTENSION_ACTIVE = 'postcodenl_api/config/enabled';
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
/**
|
106 |
* @var null|string|int
|
107 |
*/
|
@@ -166,7 +188,7 @@ class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
|
166 |
return true;
|
167 |
}
|
168 |
|
169 |
-
$addressLines =
|
170 |
if ($addressLines < 2) {
|
171 |
$this->_useSplitStreet[$storeId] = false;
|
172 |
return false;
|
@@ -344,6 +366,7 @@ class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
|
344 |
*/
|
345 |
public function getAttributeValidationClass($attribute)
|
346 |
{
|
|
|
347 |
$addressHelper = Mage::helper('customer/address');
|
348 |
if (is_callable(array($addressHelper, 'getAttributeValidationClass'))) {
|
349 |
return $addressHelper->getAttributeValidationClass($attribute);
|
@@ -449,6 +472,81 @@ class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
|
449 |
return false;
|
450 |
}
|
451 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
/**
|
453 |
* Get the configured line count for the current, or specified, config scope.
|
454 |
*
|
@@ -496,8 +594,9 @@ class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
|
496 |
if ($request->getParam('store')) {
|
497 |
$lineCount = Mage::getStoreConfig(self::XPATH_COMMUNITY_STREET_LINES, $request->getParam('store'));
|
498 |
} elseif ($request->getParam('website')) {
|
|
|
499 |
$website = Mage::getModel('core/website')->load($request->getParam('website'), 'code');
|
500 |
-
$lineCount = $website->getConfig(self::XPATH_COMMUNITY_STREET_LINES
|
501 |
} else {
|
502 |
$lineCount = Mage::getStoreConfig(
|
503 |
self::XPATH_COMMUNITY_STREET_LINES,
|
@@ -526,6 +625,7 @@ class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
|
526 |
if ($request->getParam('store')) {
|
527 |
$storeId = $request->getParam('store');
|
528 |
} elseif ($request->getParam('website')) {
|
|
|
529 |
$website = Mage::getModel('core/website')->load($request->getParam('website'), 'code');
|
530 |
$storeId = $website->getDefaultStore()->getId();
|
531 |
} else {
|
@@ -533,14 +633,16 @@ class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
|
533 |
}
|
534 |
}
|
535 |
|
536 |
-
|
|
|
|
|
537 |
return $lineCount;
|
538 |
}
|
539 |
|
540 |
/**
|
541 |
* Logs a cendris request and response for debug purposes.
|
542 |
*
|
543 |
-
* @param
|
544 |
*
|
545 |
* @return TIG_PostNL_Helper_Webservices
|
546 |
*
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
102 |
*/
|
103 |
const XPATH_POSTCODE_NL_EXTENSION_ACTIVE = 'postcodenl_api/config/enabled';
|
104 |
|
105 |
+
/**
|
106 |
+
* Extension code of the OneStepCheckout extension.
|
107 |
+
*
|
108 |
+
* @todo move all OSC specific code to a separate OSC-helper class.
|
109 |
+
*/
|
110 |
+
const ONESTEPCHECKOUT_EXTENSION_CODE = 'Idev_OneStepCheckout';
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Xpath to the OneStepCheckout extension's enabled field.
|
114 |
+
*/
|
115 |
+
const XPATH_ONESTEPCHECKOUT_EXTENSION_ACTIVE = 'onestepcheckout/general/rewrite_checkout_links';
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Xpath to the OneStepCheckout extension's Google Places enabled field.
|
119 |
+
*/
|
120 |
+
const XPATH_ONESTEPCHECKOUT_GOOGLE_PLACES_ENABLED = 'onestepcheckout/googleplaces/enabled';
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Xpath to the OneStepCheckout extension's Delivery Date enabled field.
|
124 |
+
*/
|
125 |
+
const XPATH_ONESTEPCHECKOUT_DELIVERY_DATE_ENABLED = 'onestepcheckout/delivery/enabled_date';
|
126 |
+
|
127 |
/**
|
128 |
* @var null|string|int
|
129 |
*/
|
188 |
return true;
|
189 |
}
|
190 |
|
191 |
+
$addressLines = $this->getAddressLineCount($storeId);
|
192 |
if ($addressLines < 2) {
|
193 |
$this->_useSplitStreet[$storeId] = false;
|
194 |
return false;
|
366 |
*/
|
367 |
public function getAttributeValidationClass($attribute)
|
368 |
{
|
369 |
+
/** @var Mage_Customer_Helper_Address $addressHelper */
|
370 |
$addressHelper = Mage::helper('customer/address');
|
371 |
if (is_callable(array($addressHelper, 'getAttributeValidationClass'))) {
|
372 |
return $addressHelper->getAttributeValidationClass($attribute);
|
472 |
return false;
|
473 |
}
|
474 |
|
475 |
+
/**
|
476 |
+
* Checks if the OneStepCheckout extension is installed and active.
|
477 |
+
*
|
478 |
+
* @param null $storeId
|
479 |
+
*
|
480 |
+
* @return bool
|
481 |
+
*/
|
482 |
+
public function checkOneStepCheckoutActive($storeId = null)
|
483 |
+
{
|
484 |
+
if (!Mage::helper('core')->isModuleEnabled(self::ONESTEPCHECKOUT_EXTENSION_CODE)) {
|
485 |
+
return false;
|
486 |
+
}
|
487 |
+
|
488 |
+
if ($storeId == null) {
|
489 |
+
$storeId = Mage::app()->getStore()->getId();
|
490 |
+
}
|
491 |
+
|
492 |
+
$oneStepCheckoutEnabled = Mage::getStoreConfigFlag(self::XPATH_ONESTEPCHECKOUT_EXTENSION_ACTIVE, $storeId);
|
493 |
+
if (!$oneStepCheckoutEnabled) {
|
494 |
+
return false;
|
495 |
+
}
|
496 |
+
|
497 |
+
return true;
|
498 |
+
}
|
499 |
+
|
500 |
+
/**
|
501 |
+
* Check if OneStepCheckout's Google Places functionality is active.
|
502 |
+
*
|
503 |
+
* @param null $storeId
|
504 |
+
*
|
505 |
+
* @return bool
|
506 |
+
*/
|
507 |
+
public function checkGooglePlacesActive($storeId = null)
|
508 |
+
{
|
509 |
+
if ($storeId == null) {
|
510 |
+
$storeId = Mage::app()->getStore()->getId();
|
511 |
+
}
|
512 |
+
|
513 |
+
if (!$this->checkOneStepCheckoutActive($storeId)) {
|
514 |
+
return false;
|
515 |
+
}
|
516 |
+
|
517 |
+
$googlePlacesEnabled = Mage::getStoreConfigFlag(self::XPATH_ONESTEPCHECKOUT_GOOGLE_PLACES_ENABLED, $storeId);
|
518 |
+
if (!$googlePlacesEnabled) {
|
519 |
+
return false;
|
520 |
+
}
|
521 |
+
|
522 |
+
return true;
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* Check if the OSC delivery date functionality is active.
|
527 |
+
*
|
528 |
+
* @param null $storeId
|
529 |
+
*
|
530 |
+
* @return bool
|
531 |
+
*/
|
532 |
+
public function checkOscDeliveryDateActive($storeId = null)
|
533 |
+
{
|
534 |
+
if ($storeId == null) {
|
535 |
+
$storeId = Mage::app()->getStore()->getId();
|
536 |
+
}
|
537 |
+
|
538 |
+
if (!$this->checkOneStepCheckoutActive($storeId)) {
|
539 |
+
return false;
|
540 |
+
}
|
541 |
+
|
542 |
+
$oscDeliveryDateEnabled = Mage::getStoreConfigFlag(self::XPATH_ONESTEPCHECKOUT_DELIVERY_DATE_ENABLED, $storeId);
|
543 |
+
if (!$oscDeliveryDateEnabled) {
|
544 |
+
return false;
|
545 |
+
}
|
546 |
+
|
547 |
+
return true;
|
548 |
+
}
|
549 |
+
|
550 |
/**
|
551 |
* Get the configured line count for the current, or specified, config scope.
|
552 |
*
|
594 |
if ($request->getParam('store')) {
|
595 |
$lineCount = Mage::getStoreConfig(self::XPATH_COMMUNITY_STREET_LINES, $request->getParam('store'));
|
596 |
} elseif ($request->getParam('website')) {
|
597 |
+
/** @var Mage_Core_Model_Website $website */
|
598 |
$website = Mage::getModel('core/website')->load($request->getParam('website'), 'code');
|
599 |
+
$lineCount = $website->getConfig(self::XPATH_COMMUNITY_STREET_LINES);
|
600 |
} else {
|
601 |
$lineCount = Mage::getStoreConfig(
|
602 |
self::XPATH_COMMUNITY_STREET_LINES,
|
625 |
if ($request->getParam('store')) {
|
626 |
$storeId = $request->getParam('store');
|
627 |
} elseif ($request->getParam('website')) {
|
628 |
+
/** @var Mage_Core_Model_Website $website */
|
629 |
$website = Mage::getModel('core/website')->load($request->getParam('website'), 'code');
|
630 |
$storeId = $website->getDefaultStore()->getId();
|
631 |
} else {
|
633 |
}
|
634 |
}
|
635 |
|
636 |
+
/** @var Mage_Customer_Helper_Address $addressHelper */
|
637 |
+
$addressHelper = Mage::helper('customer/address');
|
638 |
+
$lineCount = $addressHelper->getStreetLines($storeId);
|
639 |
return $lineCount;
|
640 |
}
|
641 |
|
642 |
/**
|
643 |
* Logs a cendris request and response for debug purposes.
|
644 |
*
|
645 |
+
* @param SoapClient $client
|
646 |
*
|
647 |
* @return TIG_PostNL_Helper_Webservices
|
648 |
*
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Adminhtml extends TIG_PostNL_Helper_Data
|
@@ -49,8 +49,11 @@ class TIG_PostNL_Helper_Adminhtml extends TIG_PostNL_Helper_Data
|
|
49 |
return array();
|
50 |
}
|
51 |
|
|
|
|
|
52 |
/** @var Mage_Admin_Model_User $adminUser */
|
53 |
-
|
|
|
54 |
if (!$adminUser) {
|
55 |
return array();
|
56 |
}
|
@@ -62,4 +65,26 @@ class TIG_PostNL_Helper_Adminhtml extends TIG_PostNL_Helper_Data
|
|
62 |
|
63 |
return $extra['postnl']['hidden_notification'];
|
64 |
}
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Adminhtml extends TIG_PostNL_Helper_Data
|
49 |
return array();
|
50 |
}
|
51 |
|
52 |
+
/** @var Mage_Admin_Model_Session $adminSession */
|
53 |
+
$adminSession = Mage::getSingleton('admin/session');
|
54 |
/** @var Mage_Admin_Model_User $adminUser */
|
55 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
56 |
+
$adminUser = $adminSession->getUser();
|
57 |
if (!$adminUser) {
|
58 |
return array();
|
59 |
}
|
65 |
|
66 |
return $extra['postnl']['hidden_notification'];
|
67 |
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Returns either the store id of the current scope, or returns 0 for global level scope.
|
71 |
+
*
|
72 |
+
* @return int|mixed
|
73 |
+
* @throws Mage_Core_Exception
|
74 |
+
*/
|
75 |
+
public function getCurrentScope()
|
76 |
+
{
|
77 |
+
$storeId = 0;
|
78 |
+
|
79 |
+
/** @var Mage_Adminhtml_Model_Config_Data $configData */
|
80 |
+
$configData = Mage::getSingleton('adminhtml/config_data');
|
81 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
82 |
+
$code = $configData->getStore();
|
83 |
+
if (strlen($code)) {
|
84 |
+
$storeId = Mage::getModel('core/store')->load($code)->getId();
|
85 |
+
}
|
86 |
+
|
87 |
+
return $storeId;
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
@@ -191,7 +191,7 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
191 |
*/
|
192 |
public function getPostnlShippingMethod()
|
193 |
{
|
194 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
195 |
return $this->getCurrentPostnlShippingMethod();
|
196 |
}
|
197 |
|
@@ -281,9 +281,11 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
281 |
/**
|
282 |
* Need for shipping methods that use insurance based on price of physical products.
|
283 |
*/
|
|
|
284 |
$packagePhysicalValue = $shippingAddress->getBaseVirtualAmount();
|
285 |
$request->setPackagePhysicalValue($packagePhysicalValue);
|
286 |
|
|
|
287 |
$request->setFreeMethodWeight($shippingAddress->getFreeMethodWeight());
|
288 |
|
289 |
$request->setStoreId($store->getId());
|
@@ -294,12 +296,16 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
294 |
*/
|
295 |
$request->setBaseCurrency($store->getBaseCurrency());
|
296 |
$request->setPackageCurrency($store->getCurrentCurrency());
|
|
|
297 |
$request->setLimitCarrier($shippingAddress->getLimitCarrier());
|
298 |
|
|
|
299 |
$request->setBaseSubtotalInclTax(
|
300 |
$shippingAddress->getBaseSubtotalInclTax() + $shippingAddress->getBaseExtraTaxAmount()
|
301 |
);
|
302 |
-
|
|
|
|
|
303 |
|
304 |
$rawResult = Mage::getResourceModel('postnl_carrier/matrixrate')->getRate($request);
|
305 |
if (!$rawResult) {
|
@@ -310,17 +316,25 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
310 |
/**
|
311 |
* Convert the raw result from the database to a shipping rate result object.
|
312 |
*/
|
|
|
313 |
$carrier = Mage::getModel('postnl_carrier/postnl');
|
|
|
314 |
$result = Mage::getModel('shipping/rate_result');
|
|
|
315 |
$method = Mage::getModel('shipping/rate_result_method');
|
316 |
|
|
|
317 |
$method->setCarrier('postnl');
|
|
|
318 |
$method->setCarrierTitle($carrier->getConfigData('title'));
|
319 |
|
|
|
320 |
$method->setMethod('flatrate');
|
|
|
321 |
$method->setMethodTitle($carrier->getConfigData('name'));
|
322 |
|
323 |
$method->setPrice($rawResult['price']);
|
|
|
324 |
$method->setCost(0);
|
325 |
|
326 |
$result->append($method);
|
@@ -418,10 +432,13 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
418 |
$countryCode = $destination['countryCode'];
|
419 |
$postcode = $destination['postcode'];
|
420 |
} elseif (is_object($destination) && $destination instanceof Varien_Object) {
|
|
|
421 |
if (!$destination->getCountry()) {
|
422 |
throw new InvalidArgumentException('Destination must contain a country code.');
|
423 |
}
|
|
|
424 |
$countryCode = $destination->getCountry();
|
|
|
425 |
$postcode = str_replace(' ', '', $destination->getPostcode());
|
426 |
} else {
|
427 |
throw new InvalidArgumentException('Destination must be an array or an instance of Varien_Object.');
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
191 |
*/
|
192 |
public function getPostnlShippingMethod()
|
193 |
{
|
194 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
195 |
return $this->getCurrentPostnlShippingMethod();
|
196 |
}
|
197 |
|
281 |
/**
|
282 |
* Need for shipping methods that use insurance based on price of physical products.
|
283 |
*/
|
284 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
285 |
$packagePhysicalValue = $shippingAddress->getBaseVirtualAmount();
|
286 |
$request->setPackagePhysicalValue($packagePhysicalValue);
|
287 |
|
288 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
289 |
$request->setFreeMethodWeight($shippingAddress->getFreeMethodWeight());
|
290 |
|
291 |
$request->setStoreId($store->getId());
|
296 |
*/
|
297 |
$request->setBaseCurrency($store->getBaseCurrency());
|
298 |
$request->setPackageCurrency($store->getCurrentCurrency());
|
299 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
300 |
$request->setLimitCarrier($shippingAddress->getLimitCarrier());
|
301 |
|
302 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
303 |
$request->setBaseSubtotalInclTax(
|
304 |
$shippingAddress->getBaseSubtotalInclTax() + $shippingAddress->getBaseExtraTaxAmount()
|
305 |
);
|
306 |
+
|
307 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
308 |
+
$request->setParcelType('pakje_gemak');
|
309 |
|
310 |
$rawResult = Mage::getResourceModel('postnl_carrier/matrixrate')->getRate($request);
|
311 |
if (!$rawResult) {
|
316 |
/**
|
317 |
* Convert the raw result from the database to a shipping rate result object.
|
318 |
*/
|
319 |
+
/** @var TIG_PostNL_Model_Carrier_Postnl $carrier */
|
320 |
$carrier = Mage::getModel('postnl_carrier/postnl');
|
321 |
+
/** @var Mage_Shipping_Model_Rate_Result $result */
|
322 |
$result = Mage::getModel('shipping/rate_result');
|
323 |
+
/** @var Mage_Shipping_Model_Rate_Result_Method $method */
|
324 |
$method = Mage::getModel('shipping/rate_result_method');
|
325 |
|
326 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
327 |
$method->setCarrier('postnl');
|
328 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
329 |
$method->setCarrierTitle($carrier->getConfigData('title'));
|
330 |
|
331 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
332 |
$method->setMethod('flatrate');
|
333 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
334 |
$method->setMethodTitle($carrier->getConfigData('name'));
|
335 |
|
336 |
$method->setPrice($rawResult['price']);
|
337 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
338 |
$method->setCost(0);
|
339 |
|
340 |
$result->append($method);
|
432 |
$countryCode = $destination['countryCode'];
|
433 |
$postcode = $destination['postcode'];
|
434 |
} elseif (is_object($destination) && $destination instanceof Varien_Object) {
|
435 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
436 |
if (!$destination->getCountry()) {
|
437 |
throw new InvalidArgumentException('Destination must contain a country code.');
|
438 |
}
|
439 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
440 |
$countryCode = $destination->getCountry();
|
441 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
442 |
$postcode = str_replace(' ', '', $destination->getPostcode());
|
443 |
} else {
|
444 |
throw new InvalidArgumentException('Destination must be an array or an instance of Varien_Object.');
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
@@ -171,6 +171,7 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
171 |
)
|
172 |
);
|
173 |
|
|
|
174 |
return $conversionObject->getConversionArray();
|
175 |
}
|
176 |
|
@@ -301,6 +302,7 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
301 |
* Send a ping request to see if the PostNL Checkout service is available
|
302 |
*/
|
303 |
try {
|
|
|
304 |
$cif = Mage::getModel('postnl_checkout/cif');
|
305 |
$result = $cif->ping();
|
306 |
} catch (Exception $e) {
|
@@ -331,7 +333,7 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
331 |
*/
|
332 |
public function quoteIsLetter($quoteItems, $storeId = null)
|
333 |
{
|
334 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
335 |
if ($quoteItems instanceof Mage_Sales_Model_Quote) {
|
336 |
$quoteItems = $quoteItems->getAllItems();
|
337 |
}
|
@@ -498,7 +500,7 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
498 |
*
|
499 |
* @param int $storeId
|
500 |
*
|
501 |
-
* @return
|
502 |
*/
|
503 |
protected function _isCheckoutConfigured($storeId)
|
504 |
{
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
171 |
)
|
172 |
);
|
173 |
|
174 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
175 |
return $conversionObject->getConversionArray();
|
176 |
}
|
177 |
|
302 |
* Send a ping request to see if the PostNL Checkout service is available
|
303 |
*/
|
304 |
try {
|
305 |
+
/** @var TIG_PostNL_Model_Checkout_Cif $cif */
|
306 |
$cif = Mage::getModel('postnl_checkout/cif');
|
307 |
$result = $cif->ping();
|
308 |
} catch (Exception $e) {
|
333 |
*/
|
334 |
public function quoteIsLetter($quoteItems, $storeId = null)
|
335 |
{
|
336 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
337 |
if ($quoteItems instanceof Mage_Sales_Model_Quote) {
|
338 |
$quoteItems = $quoteItems->getAllItems();
|
339 |
}
|
500 |
*
|
501 |
* @param int $storeId
|
502 |
*
|
503 |
+
* @return boolean
|
504 |
*/
|
505 |
protected function _isCheckoutConfigured($storeId)
|
506 |
{
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
@@ -77,6 +77,11 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
77 |
const XPATH_DEFAULT_GLOBAL_PRODUCT_OPTION = 'postnl/cif_product_options/default_global_product_option';
|
78 |
const XPATH_DEFAULT_PAKKETAUTOMAAT_PRODUCT_OPTION = 'postnl/cif_product_options/default_pakketautomaat_product_option';
|
79 |
|
|
|
|
|
|
|
|
|
|
|
80 |
/**
|
81 |
* Regular expression used to split street name from house number. This regex works well for dutch addresses, but
|
82 |
* may fail for international addresses. We strongly recommend using split address lines instead.
|
@@ -90,6 +95,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
90 |
|
91 |
/**
|
92 |
* Array of countries to which PostNL ships using EPS. Other EU countries are shipped to using GlobalPack
|
|
|
93 |
*
|
94 |
* @var array
|
95 |
*/
|
@@ -102,6 +108,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
102 |
'FI',
|
103 |
'FR',
|
104 |
'GB',
|
|
|
105 |
'HU',
|
106 |
'IE',
|
107 |
'IT',
|
@@ -117,11 +124,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
117 |
'ES',
|
118 |
'CZ',
|
119 |
'SE',
|
120 |
-
'GR',
|
121 |
-
'MT',
|
122 |
'NL',
|
123 |
-
'CY',
|
124 |
-
'ML',
|
125 |
);
|
126 |
|
127 |
/**
|
@@ -266,7 +269,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
266 |
* @var array
|
267 |
*/
|
268 |
protected $_returnLabelTypes = array(
|
269 |
-
|
270 |
);
|
271 |
|
272 |
/**
|
@@ -284,6 +287,19 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
284 |
return $this->_euCountries;
|
285 |
}
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
/**
|
288 |
* Gets an array of country-restricted product codes
|
289 |
*
|
@@ -298,12 +314,13 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
298 |
* Get an array of standard product codes.
|
299 |
*
|
300 |
* @param boolean $flat
|
301 |
-
* @param string|
|
302 |
*
|
303 |
* @return array
|
304 |
*/
|
305 |
public function getStandardProductCodes($flat = true, $destination = false)
|
306 |
{
|
|
|
307 |
$standardProductCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
308 |
|
309 |
$productCodes = $standardProductCodes->getAvailableOptions($flat, $destination);
|
@@ -314,13 +331,14 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
314 |
/**
|
315 |
* Get an array of standard COD product codes.
|
316 |
*
|
317 |
-
* @param boolean
|
318 |
-
* @param string|
|
319 |
*
|
320 |
* @return array
|
321 |
*/
|
322 |
public function getStandardCodProductCodes($flat = true, $destination = false)
|
323 |
{
|
|
|
324 |
$standardProductCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
325 |
|
326 |
$productCodes = $standardProductCodes->getAvailableCodOptions($flat, $destination);
|
@@ -337,8 +355,9 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
337 |
*/
|
338 |
public function getAvondProductCodes($flat = true)
|
339 |
{
|
340 |
-
$
|
341 |
-
|
|
|
342 |
}
|
343 |
|
344 |
/**
|
@@ -350,20 +369,28 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
350 |
*/
|
351 |
public function getAvondCodProductCodes($flat = true)
|
352 |
{
|
353 |
-
$
|
354 |
-
|
|
|
355 |
}
|
356 |
|
357 |
/**
|
358 |
* Get an array of PakjeGemak product codes.
|
359 |
*
|
360 |
-
* @param boolean
|
|
|
361 |
*
|
362 |
* @return array
|
363 |
*/
|
364 |
-
public function getPakjeGemakProductCodes($flat = true)
|
365 |
{
|
|
|
366 |
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
|
|
|
|
|
|
|
|
|
|
367 |
return $pakjeGemakProductCodes->getAvailableOptions($flat);
|
368 |
}
|
369 |
|
@@ -376,6 +403,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
376 |
*/
|
377 |
public function getPakjeGemakCodProductCodes($flat = true)
|
378 |
{
|
|
|
379 |
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
380 |
return $pakjeGemakProductCodes->getAvailableCodOptions($flat);
|
381 |
}
|
@@ -389,6 +417,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
389 |
*/
|
390 |
public function getPgeProductCodes($flat = true)
|
391 |
{
|
|
|
392 |
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
393 |
return $pakjeGemakProductCodes->getAvailablePgeOptions($flat);
|
394 |
}
|
@@ -402,6 +431,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
402 |
*/
|
403 |
public function getPgeCodProductCodes($flat = true)
|
404 |
{
|
|
|
405 |
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
406 |
return $pakjeGemakProductCodes->getAvailablePgeCodOptions($flat);
|
407 |
}
|
@@ -415,6 +445,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
415 |
*/
|
416 |
public function getPakketautomaatProductCodes($flat = true)
|
417 |
{
|
|
|
418 |
$pakketautomaatProductCodes = Mage::getSingleton(
|
419 |
'postnl_core/system_config_source_pakketautomaatProductOptions'
|
420 |
);
|
@@ -430,6 +461,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
430 |
*/
|
431 |
public function getEuProductCodes($flat = true)
|
432 |
{
|
|
|
433 |
$euProductCodes = Mage::getSingleton('postnl_core/system_config_source_euProductOptions');
|
434 |
return $euProductCodes->getAvailableOptions($flat);
|
435 |
}
|
@@ -443,6 +475,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
443 |
*/
|
444 |
public function getGlobalProductCodes($flat = true)
|
445 |
{
|
|
|
446 |
$globalProductCodes = Mage::getSingleton('postnl_core/system_config_source_globalProductOptions');
|
447 |
return $globalProductCodes->getAvailableOptions($flat);
|
448 |
}
|
@@ -456,6 +489,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
456 |
*/
|
457 |
public function getBuspakjeProductCodes($flat = true)
|
458 |
{
|
|
|
459 |
$buspakjeProductCodes = Mage::getSingleton('postnl_core/system_config_source_buspakjeProductOptions');
|
460 |
return $buspakjeProductCodes->getAvailableOptions($flat);
|
461 |
}
|
@@ -469,10 +503,49 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
469 |
*/
|
470 |
public function getSundayProductCodes($flat = true)
|
471 |
{
|
|
|
472 |
$sundayProductCodes = Mage::getSingleton('postnl_core/system_config_source_sundayProductOptions');
|
473 |
return $sundayProductCodes->getAvailableOptions($flat);
|
474 |
}
|
475 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
/**
|
477 |
* Get an array of possible shipment types
|
478 |
*
|
@@ -605,6 +678,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
605 |
public function getProductOptionsForShipment($shipment)
|
606 |
{
|
607 |
if ($shipment instanceof Mage_Sales_Model_Order_Shipment) {
|
|
|
608 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
609 |
$tempPostnlShipment->setShipment($shipment);
|
610 |
} else {
|
@@ -625,6 +699,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
625 |
*/
|
626 |
public function isPakjeGemakShipment($shipment)
|
627 |
{
|
|
|
628 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
629 |
if ($shipment instanceof $postnlShipmentClass) {
|
630 |
/**
|
@@ -633,6 +708,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
633 |
return $shipment->isPakjeGemakShipment();
|
634 |
}
|
635 |
|
|
|
636 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
637 |
$tempPostnlShipment->setShipment($shipment);
|
638 |
|
@@ -650,6 +726,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
650 |
*/
|
651 |
public function isPakketautomaatShipment($shipment)
|
652 |
{
|
|
|
653 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
654 |
if ($shipment instanceof $postnlShipmentClass) {
|
655 |
/**
|
@@ -658,6 +735,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
658 |
return $shipment->isPakketautomaatShipment();
|
659 |
}
|
660 |
|
|
|
661 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
662 |
$tempPostnlShipment->setShipment($shipment);
|
663 |
|
@@ -675,6 +753,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
675 |
*/
|
676 |
public function isAvondShipment($shipment)
|
677 |
{
|
|
|
678 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
679 |
if ($shipment instanceof $postnlShipmentClass) {
|
680 |
/**
|
@@ -683,6 +762,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
683 |
return $shipment->isAvondShipment();
|
684 |
}
|
685 |
|
|
|
686 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
687 |
$tempPostnlShipment->setShipment($shipment);
|
688 |
|
@@ -700,6 +780,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
700 |
*/
|
701 |
public function isDomesticShipment($shipment)
|
702 |
{
|
|
|
703 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
704 |
if ($shipment instanceof $postnlShipmentClass) {
|
705 |
/**
|
@@ -708,6 +789,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
708 |
return $shipment->isDomesticShipment();
|
709 |
}
|
710 |
|
|
|
711 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
712 |
$tempPostnlShipment->setShipment($shipment);
|
713 |
|
@@ -725,6 +807,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
725 |
*/
|
726 |
public function isEuShipment($shipment)
|
727 |
{
|
|
|
728 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
729 |
if ($shipment instanceof $postnlShipmentClass) {
|
730 |
/**
|
@@ -733,6 +816,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
733 |
return $shipment->isEuShipment();
|
734 |
}
|
735 |
|
|
|
736 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
737 |
$tempPostnlShipment->setShipment($shipment);
|
738 |
|
@@ -750,6 +834,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
750 |
*/
|
751 |
public function isGlobalShipment($shipment)
|
752 |
{
|
|
|
753 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
754 |
if ($shipment instanceof $postnlShipmentClass) {
|
755 |
/**
|
@@ -758,6 +843,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
758 |
return $shipment->isGlobalShipment();
|
759 |
}
|
760 |
|
|
|
761 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
762 |
$tempPostnlShipment->setShipment($shipment);
|
763 |
|
@@ -775,6 +861,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
775 |
*/
|
776 |
public function isCodShipment($shipment)
|
777 |
{
|
|
|
778 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
779 |
if ($shipment instanceof $postnlShipmentClass) {
|
780 |
/**
|
@@ -783,6 +870,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
783 |
return $shipment->isCod();
|
784 |
}
|
785 |
|
|
|
786 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
787 |
$tempPostnlShipment->setShipment($shipment);
|
788 |
|
@@ -798,6 +886,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
798 |
*/
|
799 |
public function isSundayShipment($shipment)
|
800 |
{
|
|
|
801 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
802 |
if ($shipment instanceof $postnlShipmentClass) {
|
803 |
/**
|
@@ -806,6 +895,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
806 |
return $shipment->isSunday();
|
807 |
}
|
808 |
|
|
|
809 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
810 |
$tempPostnlShipment->setShipment($shipment);
|
811 |
|
@@ -821,6 +911,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
821 |
*/
|
822 |
public function isMondayShipment($shipment)
|
823 |
{
|
|
|
824 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
825 |
if ($shipment instanceof $postnlShipmentClass) {
|
826 |
/**
|
@@ -829,6 +920,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
829 |
return $shipment->isMonday();
|
830 |
}
|
831 |
|
|
|
832 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
833 |
$tempPostnlShipment->setShipment($shipment);
|
834 |
|
@@ -845,6 +937,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
845 |
*/
|
846 |
public function getDefaultProductOptionForShipment($shipment)
|
847 |
{
|
|
|
848 |
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
849 |
$postnlShipment->setShipment($shipment);
|
850 |
|
@@ -866,7 +959,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
866 |
*/
|
867 |
public function getDefaultProductOptions()
|
868 |
{
|
869 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
870 |
$storeId = Mage::app()->getStore()->getId();
|
871 |
|
872 |
$defaultDutchOption = Mage::getStoreConfig(self::XPATH_DEFAULT_STANDARD_PRODUCT_OPTION, $storeId);
|
@@ -896,13 +989,14 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
896 |
*/
|
897 |
public function getParcelCount($shipment)
|
898 |
{
|
|
|
899 |
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
900 |
$postnlShipment->setShipment($shipment);
|
901 |
|
902 |
/**
|
903 |
* Only NL shipments support multi-colli shipments.
|
904 |
*/
|
905 |
-
if (
|
906 |
return 1;
|
907 |
}
|
908 |
|
@@ -975,6 +1069,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
975 |
*/
|
976 |
public function postnlShipmentExists($shipmentId)
|
977 |
{
|
|
|
978 |
$coreResource = Mage::getSingleton('core/resource');
|
979 |
$readAdapter = $coreResource->getConnection('core_read');
|
980 |
|
@@ -1008,6 +1103,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
1008 |
*/
|
1009 |
public function barcodeExists($barcode)
|
1010 |
{
|
|
|
1011 |
$coreResource = Mage::getSingleton('core/resource');
|
1012 |
$readAdapter = $coreResource->getConnection('core_read');
|
1013 |
|
@@ -1071,7 +1167,9 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
1071 |
$storeId = Mage::app()->getStore()->getId();
|
1072 |
}
|
1073 |
|
1074 |
-
|
|
|
|
|
1075 |
|
1076 |
/**
|
1077 |
* Website uses multi-line address mode
|
@@ -1095,7 +1193,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
1095 |
$fullStreet = $address->getStreetFull();
|
1096 |
|
1097 |
/**
|
1098 |
-
* Select countries don't have to split their street values into
|
1099 |
*/
|
1100 |
if ($allowFullStreet === true
|
1101 |
&& in_array($address->getCountry(), $allowedFullStreetCountries)
|
@@ -1130,6 +1228,7 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
1130 |
*/
|
1131 |
protected function _getMultiLineStreetData($storeId, $address)
|
1132 |
{
|
|
|
1133 |
$addressHelper = Mage::helper('postnl/addressValidation');
|
1134 |
|
1135 |
$streetnameField = $addressHelper->getStreetnameField($storeId);
|
@@ -1138,11 +1237,12 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
1138 |
$streetname = $address->getStreet($streetnameField);
|
1139 |
$housenumber = $address->getStreet($housenumberField);
|
1140 |
$housenumber = trim($housenumber);
|
|
|
1141 |
|
1142 |
/**
|
1143 |
-
* If street
|
1144 |
*/
|
1145 |
-
if (empty($streetname)
|
1146 |
return false;
|
1147 |
}
|
1148 |
|
@@ -1157,12 +1257,12 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
1157 |
/**
|
1158 |
* Make sure the house number is actually split.
|
1159 |
*/
|
1160 |
-
if (!$housenumberExtension && !is_numeric($housenumber)) {
|
1161 |
$housenumberParts = $this->_splitHousenumber($housenumber);
|
1162 |
$housenumber = $housenumberParts['number'];
|
1163 |
$housenumberExtension = $housenumberParts['extension'];
|
1164 |
}
|
1165 |
-
}
|
1166 |
$housenumberParts = $this->_splitHousenumber($housenumber);
|
1167 |
$housenumber = $housenumberParts['number'];
|
1168 |
$housenumberExtension = $housenumberParts['extension'];
|
@@ -1195,14 +1295,19 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
1195 |
{
|
1196 |
$result = preg_match(self::SPLIT_STREET_REGEX, $fullStreet, $matches);
|
1197 |
if (!$result || !is_array($matches)) {
|
1198 |
-
|
1199 |
-
|
1200 |
-
'
|
|
|
|
|
1201 |
);
|
|
|
|
|
1202 |
}
|
1203 |
|
1204 |
$streetname = '';
|
1205 |
$housenumber = '';
|
|
|
1206 |
if (isset($matches[1])) {
|
1207 |
$streetname = $matches[1];
|
1208 |
}
|
@@ -1211,9 +1316,11 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
1211 |
$housenumber = $matches[2];
|
1212 |
}
|
1213 |
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
|
|
|
|
1217 |
|
1218 |
$streetData = array(
|
1219 |
'streetname' => $streetname,
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
77 |
const XPATH_DEFAULT_GLOBAL_PRODUCT_OPTION = 'postnl/cif_product_options/default_global_product_option';
|
78 |
const XPATH_DEFAULT_PAKKETAUTOMAAT_PRODUCT_OPTION = 'postnl/cif_product_options/default_pakketautomaat_product_option';
|
79 |
|
80 |
+
/**
|
81 |
+
* Xpath to the 'house_number_required_countries' setting.
|
82 |
+
*/
|
83 |
+
const XPATH_HOUSE_NUMBER_REQUIRED_COUNTRIES_XPATH = 'postnl/cif/house_number_required_countries';
|
84 |
+
|
85 |
/**
|
86 |
* Regular expression used to split street name from house number. This regex works well for dutch addresses, but
|
87 |
* may fail for international addresses. We strongly recommend using split address lines instead.
|
95 |
|
96 |
/**
|
97 |
* Array of countries to which PostNL ships using EPS. Other EU countries are shipped to using GlobalPack
|
98 |
+
* http://www.postnl.nl/zakelijke-oplossingen/pakket-versturen/pakket-buitenland/binnen-de-eu/
|
99 |
*
|
100 |
* @var array
|
101 |
*/
|
108 |
'FI',
|
109 |
'FR',
|
110 |
'GB',
|
111 |
+
'UK', //alias for GB
|
112 |
'HU',
|
113 |
'IE',
|
114 |
'IT',
|
124 |
'ES',
|
125 |
'CZ',
|
126 |
'SE',
|
|
|
|
|
127 |
'NL',
|
|
|
|
|
128 |
);
|
129 |
|
130 |
/**
|
269 |
* @var array
|
270 |
*/
|
271 |
protected $_returnLabelTypes = array(
|
272 |
+
TIG_PostNL_Model_Core_Shipment_Label::LABEL_TYPE_RETURN_LABEL
|
273 |
);
|
274 |
|
275 |
/**
|
287 |
return $this->_euCountries;
|
288 |
}
|
289 |
|
290 |
+
/**
|
291 |
+
* @param int|Mage_Core_Model_Store|null $storeId
|
292 |
+
*
|
293 |
+
* @return array|mixed
|
294 |
+
*/
|
295 |
+
public function getHouseNumberRequiredCountries($storeId = null)
|
296 |
+
{
|
297 |
+
$requiredCountries = Mage::getStoreConfig(self::XPATH_HOUSE_NUMBER_REQUIRED_COUNTRIES_XPATH, $storeId);
|
298 |
+
$requiredCountries = explode(',', $requiredCountries);
|
299 |
+
|
300 |
+
return $requiredCountries;
|
301 |
+
}
|
302 |
+
|
303 |
/**
|
304 |
* Gets an array of country-restricted product codes
|
305 |
*
|
314 |
* Get an array of standard product codes.
|
315 |
*
|
316 |
* @param boolean $flat
|
317 |
+
* @param string|bool $destination
|
318 |
*
|
319 |
* @return array
|
320 |
*/
|
321 |
public function getStandardProductCodes($flat = true, $destination = false)
|
322 |
{
|
323 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions $standardProductCodes */
|
324 |
$standardProductCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
325 |
|
326 |
$productCodes = $standardProductCodes->getAvailableOptions($flat, $destination);
|
331 |
/**
|
332 |
* Get an array of standard COD product codes.
|
333 |
*
|
334 |
+
* @param boolean $flat
|
335 |
+
* @param string|bool $destination
|
336 |
*
|
337 |
* @return array
|
338 |
*/
|
339 |
public function getStandardCodProductCodes($flat = true, $destination = false)
|
340 |
{
|
341 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions $standardProductCodes */
|
342 |
$standardProductCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
343 |
|
344 |
$productCodes = $standardProductCodes->getAvailableCodOptions($flat, $destination);
|
355 |
*/
|
356 |
public function getAvondProductCodes($flat = true)
|
357 |
{
|
358 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions $productCodes */
|
359 |
+
$productCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
360 |
+
return $productCodes->getAvailableAvondOptions($flat);
|
361 |
}
|
362 |
|
363 |
/**
|
369 |
*/
|
370 |
public function getAvondCodProductCodes($flat = true)
|
371 |
{
|
372 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions $productCodes */
|
373 |
+
$productCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
374 |
+
return $productCodes->getAvailableAvondCodOptions($flat);
|
375 |
}
|
376 |
|
377 |
/**
|
378 |
* Get an array of PakjeGemak product codes.
|
379 |
*
|
380 |
+
* @param boolean $flat
|
381 |
+
* @param string|bool $destination
|
382 |
*
|
383 |
* @return array
|
384 |
*/
|
385 |
+
public function getPakjeGemakProductCodes($flat = true, $destination = false)
|
386 |
{
|
387 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions $pakjeGemakProductCodes */
|
388 |
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
389 |
+
|
390 |
+
if ($destination == 'BE') {
|
391 |
+
return $pakjeGemakProductCodes->getAvailableBeOptions($flat);
|
392 |
+
}
|
393 |
+
|
394 |
return $pakjeGemakProductCodes->getAvailableOptions($flat);
|
395 |
}
|
396 |
|
403 |
*/
|
404 |
public function getPakjeGemakCodProductCodes($flat = true)
|
405 |
{
|
406 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions $pakjeGemakProductCodes */
|
407 |
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
408 |
return $pakjeGemakProductCodes->getAvailableCodOptions($flat);
|
409 |
}
|
417 |
*/
|
418 |
public function getPgeProductCodes($flat = true)
|
419 |
{
|
420 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions $pakjeGemakProductCodes */
|
421 |
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
422 |
return $pakjeGemakProductCodes->getAvailablePgeOptions($flat);
|
423 |
}
|
431 |
*/
|
432 |
public function getPgeCodProductCodes($flat = true)
|
433 |
{
|
434 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions $pakjeGemakProductCodes */
|
435 |
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
436 |
return $pakjeGemakProductCodes->getAvailablePgeCodOptions($flat);
|
437 |
}
|
445 |
*/
|
446 |
public function getPakketautomaatProductCodes($flat = true)
|
447 |
{
|
448 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_PakketautomaatProductOptions $pakketautomaatProductCodes */
|
449 |
$pakketautomaatProductCodes = Mage::getSingleton(
|
450 |
'postnl_core/system_config_source_pakketautomaatProductOptions'
|
451 |
);
|
461 |
*/
|
462 |
public function getEuProductCodes($flat = true)
|
463 |
{
|
464 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions $euProductCodes */
|
465 |
$euProductCodes = Mage::getSingleton('postnl_core/system_config_source_euProductOptions');
|
466 |
return $euProductCodes->getAvailableOptions($flat);
|
467 |
}
|
475 |
*/
|
476 |
public function getGlobalProductCodes($flat = true)
|
477 |
{
|
478 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_GlobalpackShipmentType $globalProductCodes */
|
479 |
$globalProductCodes = Mage::getSingleton('postnl_core/system_config_source_globalProductOptions');
|
480 |
return $globalProductCodes->getAvailableOptions($flat);
|
481 |
}
|
489 |
*/
|
490 |
public function getBuspakjeProductCodes($flat = true)
|
491 |
{
|
492 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_BuspakjeProductOptions $buspakjeProductCodes */
|
493 |
$buspakjeProductCodes = Mage::getSingleton('postnl_core/system_config_source_buspakjeProductOptions');
|
494 |
return $buspakjeProductCodes->getAvailableOptions($flat);
|
495 |
}
|
503 |
*/
|
504 |
public function getSundayProductCodes($flat = true)
|
505 |
{
|
506 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_SundayProductOptions $sundayProductCodes */
|
507 |
$sundayProductCodes = Mage::getSingleton('postnl_core/system_config_source_sundayProductOptions');
|
508 |
return $sundayProductCodes->getAvailableOptions($flat);
|
509 |
}
|
510 |
|
511 |
+
/**
|
512 |
+
* Get an array of same day delivery product codes.
|
513 |
+
*
|
514 |
+
* @param boolean $flat
|
515 |
+
*
|
516 |
+
* @return array
|
517 |
+
*/
|
518 |
+
public function getSameDayProductCodes($flat = true)
|
519 |
+
{
|
520 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions $productCodes */
|
521 |
+
$productCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
522 |
+
return $productCodes->getAvailableSameDayOptions($flat);
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* @param bool $flat
|
527 |
+
*
|
528 |
+
* @return mixed
|
529 |
+
*/
|
530 |
+
public function getFoodProductCodes($flat = true)
|
531 |
+
{
|
532 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_FoodProductOptions $foodProductCodes */
|
533 |
+
$foodProductCodes = Mage::getSingleton('postnl_core/system_config_source_foodProductOptions');
|
534 |
+
return $foodProductCodes->getAvailableSameDayOptions($flat);
|
535 |
+
}
|
536 |
+
|
537 |
+
/**
|
538 |
+
* @param bool $flat
|
539 |
+
*
|
540 |
+
* @return mixed
|
541 |
+
*/
|
542 |
+
public function getCooledProductCodes($flat = true)
|
543 |
+
{
|
544 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_CooledProductOptions $cooledProductCodes */
|
545 |
+
$cooledProductCodes = Mage::getSingleton('postnl_core/system_config_source_cooledProductOptions');
|
546 |
+
return $cooledProductCodes->getAvailableSameDayOptions($flat);
|
547 |
+
}
|
548 |
+
|
549 |
/**
|
550 |
* Get an array of possible shipment types
|
551 |
*
|
678 |
public function getProductOptionsForShipment($shipment)
|
679 |
{
|
680 |
if ($shipment instanceof Mage_Sales_Model_Order_Shipment) {
|
681 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
682 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
683 |
$tempPostnlShipment->setShipment($shipment);
|
684 |
} else {
|
699 |
*/
|
700 |
public function isPakjeGemakShipment($shipment)
|
701 |
{
|
702 |
+
/** @noinspection PhpParamsInspection */
|
703 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
704 |
if ($shipment instanceof $postnlShipmentClass) {
|
705 |
/**
|
708 |
return $shipment->isPakjeGemakShipment();
|
709 |
}
|
710 |
|
711 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
712 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
713 |
$tempPostnlShipment->setShipment($shipment);
|
714 |
|
726 |
*/
|
727 |
public function isPakketautomaatShipment($shipment)
|
728 |
{
|
729 |
+
/** @noinspection PhpParamsInspection */
|
730 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
731 |
if ($shipment instanceof $postnlShipmentClass) {
|
732 |
/**
|
735 |
return $shipment->isPakketautomaatShipment();
|
736 |
}
|
737 |
|
738 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
739 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
740 |
$tempPostnlShipment->setShipment($shipment);
|
741 |
|
753 |
*/
|
754 |
public function isAvondShipment($shipment)
|
755 |
{
|
756 |
+
/** @noinspection PhpParamsInspection */
|
757 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
758 |
if ($shipment instanceof $postnlShipmentClass) {
|
759 |
/**
|
762 |
return $shipment->isAvondShipment();
|
763 |
}
|
764 |
|
765 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
766 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
767 |
$tempPostnlShipment->setShipment($shipment);
|
768 |
|
780 |
*/
|
781 |
public function isDomesticShipment($shipment)
|
782 |
{
|
783 |
+
/** @noinspection PhpParamsInspection */
|
784 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
785 |
if ($shipment instanceof $postnlShipmentClass) {
|
786 |
/**
|
789 |
return $shipment->isDomesticShipment();
|
790 |
}
|
791 |
|
792 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
793 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
794 |
$tempPostnlShipment->setShipment($shipment);
|
795 |
|
807 |
*/
|
808 |
public function isEuShipment($shipment)
|
809 |
{
|
810 |
+
/** @noinspection PhpParamsInspection */
|
811 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
812 |
if ($shipment instanceof $postnlShipmentClass) {
|
813 |
/**
|
816 |
return $shipment->isEuShipment();
|
817 |
}
|
818 |
|
819 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
820 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
821 |
$tempPostnlShipment->setShipment($shipment);
|
822 |
|
834 |
*/
|
835 |
public function isGlobalShipment($shipment)
|
836 |
{
|
837 |
+
/** @noinspection PhpParamsInspection */
|
838 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
839 |
if ($shipment instanceof $postnlShipmentClass) {
|
840 |
/**
|
843 |
return $shipment->isGlobalShipment();
|
844 |
}
|
845 |
|
846 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
847 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
848 |
$tempPostnlShipment->setShipment($shipment);
|
849 |
|
861 |
*/
|
862 |
public function isCodShipment($shipment)
|
863 |
{
|
864 |
+
/** @noinspection PhpParamsInspection */
|
865 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
866 |
if ($shipment instanceof $postnlShipmentClass) {
|
867 |
/**
|
870 |
return $shipment->isCod();
|
871 |
}
|
872 |
|
873 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
874 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
875 |
$tempPostnlShipment->setShipment($shipment);
|
876 |
|
886 |
*/
|
887 |
public function isSundayShipment($shipment)
|
888 |
{
|
889 |
+
/** @noinspection PhpParamsInspection */
|
890 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
891 |
if ($shipment instanceof $postnlShipmentClass) {
|
892 |
/**
|
895 |
return $shipment->isSunday();
|
896 |
}
|
897 |
|
898 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
899 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
900 |
$tempPostnlShipment->setShipment($shipment);
|
901 |
|
911 |
*/
|
912 |
public function isMondayShipment($shipment)
|
913 |
{
|
914 |
+
/** @noinspection PhpParamsInspection */
|
915 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
916 |
if ($shipment instanceof $postnlShipmentClass) {
|
917 |
/**
|
920 |
return $shipment->isMonday();
|
921 |
}
|
922 |
|
923 |
+
/** @var TIG_PostNL_Model_Core_Shipment $tempPostnlShipment */
|
924 |
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
925 |
$tempPostnlShipment->setShipment($shipment);
|
926 |
|
937 |
*/
|
938 |
public function getDefaultProductOptionForShipment($shipment)
|
939 |
{
|
940 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
941 |
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
942 |
$postnlShipment->setShipment($shipment);
|
943 |
|
959 |
*/
|
960 |
public function getDefaultProductOptions()
|
961 |
{
|
962 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
963 |
$storeId = Mage::app()->getStore()->getId();
|
964 |
|
965 |
$defaultDutchOption = Mage::getStoreConfig(self::XPATH_DEFAULT_STANDARD_PRODUCT_OPTION, $storeId);
|
989 |
*/
|
990 |
public function getParcelCount($shipment)
|
991 |
{
|
992 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
993 |
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
994 |
$postnlShipment->setShipment($shipment);
|
995 |
|
996 |
/**
|
997 |
* Only NL shipments support multi-colli shipments.
|
998 |
*/
|
999 |
+
if ($postnlShipment->getShippingAddress()->getCountryId() != 'NL') {
|
1000 |
return 1;
|
1001 |
}
|
1002 |
|
1069 |
*/
|
1070 |
public function postnlShipmentExists($shipmentId)
|
1071 |
{
|
1072 |
+
/** @var Mage_Core_Model_Resource $coreResource */
|
1073 |
$coreResource = Mage::getSingleton('core/resource');
|
1074 |
$readAdapter = $coreResource->getConnection('core_read');
|
1075 |
|
1103 |
*/
|
1104 |
public function barcodeExists($barcode)
|
1105 |
{
|
1106 |
+
/** @var Mage_Core_Model_Resource $coreResource */
|
1107 |
$coreResource = Mage::getSingleton('core/resource');
|
1108 |
$readAdapter = $coreResource->getConnection('core_read');
|
1109 |
|
1167 |
$storeId = Mage::app()->getStore()->getId();
|
1168 |
}
|
1169 |
|
1170 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
1171 |
+
$helper = Mage::helper('postnl/addressValidation');
|
1172 |
+
$splitStreet = $helper->useSplitStreet($storeId);
|
1173 |
|
1174 |
/**
|
1175 |
* Website uses multi-line address mode
|
1193 |
$fullStreet = $address->getStreetFull();
|
1194 |
|
1195 |
/**
|
1196 |
+
* Select countries don't have to split their street values into separate part
|
1197 |
*/
|
1198 |
if ($allowFullStreet === true
|
1199 |
&& in_array($address->getCountry(), $allowedFullStreetCountries)
|
1228 |
*/
|
1229 |
protected function _getMultiLineStreetData($storeId, $address)
|
1230 |
{
|
1231 |
+
/** @var TIG_PostNL_Helper_AddressValidation $addressHelper */
|
1232 |
$addressHelper = Mage::helper('postnl/addressValidation');
|
1233 |
|
1234 |
$streetnameField = $addressHelper->getStreetnameField($storeId);
|
1237 |
$streetname = $address->getStreet($streetnameField);
|
1238 |
$housenumber = $address->getStreet($housenumberField);
|
1239 |
$housenumber = trim($housenumber);
|
1240 |
+
$housenumberExtension = '';
|
1241 |
|
1242 |
/**
|
1243 |
+
* If street field is empty, use alternative options to obtain the address data
|
1244 |
*/
|
1245 |
+
if (empty($streetname)) {
|
1246 |
return false;
|
1247 |
}
|
1248 |
|
1257 |
/**
|
1258 |
* Make sure the house number is actually split.
|
1259 |
*/
|
1260 |
+
if (!empty($housenumber) && !$housenumberExtension && !is_numeric($housenumber)) {
|
1261 |
$housenumberParts = $this->_splitHousenumber($housenumber);
|
1262 |
$housenumber = $housenumberParts['number'];
|
1263 |
$housenumberExtension = $housenumberParts['extension'];
|
1264 |
}
|
1265 |
+
} elseif (!empty($housenumber)) {
|
1266 |
$housenumberParts = $this->_splitHousenumber($housenumber);
|
1267 |
$housenumber = $housenumberParts['number'];
|
1268 |
$housenumberExtension = $housenumberParts['extension'];
|
1295 |
{
|
1296 |
$result = preg_match(self::SPLIT_STREET_REGEX, $fullStreet, $matches);
|
1297 |
if (!$result || !is_array($matches)) {
|
1298 |
+
$streetData = array(
|
1299 |
+
'streetname' => $fullStreet,
|
1300 |
+
'housenumber' => '',
|
1301 |
+
'housenumberExtension' => '',
|
1302 |
+
'fullStreet' => '',
|
1303 |
);
|
1304 |
+
|
1305 |
+
return $streetData;
|
1306 |
}
|
1307 |
|
1308 |
$streetname = '';
|
1309 |
$housenumber = '';
|
1310 |
+
$housenumberExtension = '';
|
1311 |
if (isset($matches[1])) {
|
1312 |
$streetname = $matches[1];
|
1313 |
}
|
1316 |
$housenumber = $matches[2];
|
1317 |
}
|
1318 |
|
1319 |
+
if (!empty($housenumber)) {
|
1320 |
+
$housenumberParts = $this->_splitHousenumber($housenumber);
|
1321 |
+
$housenumber = $housenumberParts['number'];
|
1322 |
+
$housenumberExtension = $housenumberParts['extension'];
|
1323 |
+
}
|
1324 |
|
1325 |
$streetData = array(
|
1326 |
'streetname' => $streetname,
|
@@ -271,40 +271,6 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
271 |
*/
|
272 |
protected $_domesticCountry;
|
273 |
|
274 |
-
/**
|
275 |
-
* TIG_PostNL_Helper_Data constructor.
|
276 |
-
*/
|
277 |
-
public function __construct()
|
278 |
-
{
|
279 |
-
if (!function_exists('postnlErrorHandler')) {
|
280 |
-
/**
|
281 |
-
* @param $errno
|
282 |
-
* @param $errstr
|
283 |
-
* @param $errfile
|
284 |
-
* @param $errline
|
285 |
-
*
|
286 |
-
* @return bool
|
287 |
-
* @throws Exception
|
288 |
-
*
|
289 |
-
* Register E_USER_DEPRECATED errors and pass them on to the Magento core error_handler as regular
|
290 |
-
* DEPRECATED errors.
|
291 |
-
*
|
292 |
-
* Magento's core error handler unfortunately doesn't recognize E_USER_DEPRECATED errors. Most likely
|
293 |
-
* because the developers simply forgot.
|
294 |
-
*/
|
295 |
-
function postnlErrorHandler($errno, $errstr, $errfile, $errline)
|
296 |
-
{
|
297 |
-
if ($errno == E_USER_DEPRECATED) {
|
298 |
-
$errno = E_DEPRECATED;
|
299 |
-
}
|
300 |
-
|
301 |
-
return mageCoreErrorHandler($errno, $errstr, $errfile, $errline);
|
302 |
-
}
|
303 |
-
|
304 |
-
set_error_handler('postnlErrorHandler');
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
/**
|
309 |
* Get required fields array.
|
310 |
*
|
@@ -385,6 +351,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
385 |
return $this->_cache;
|
386 |
}
|
387 |
|
|
|
388 |
$cache = Mage::getSingleton('postnl_core/cache');
|
389 |
if (!$cache->canUseCache()) {
|
390 |
$cache = false;
|
@@ -403,7 +370,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
403 |
return $this->_quote;
|
404 |
}
|
405 |
|
406 |
-
|
|
|
|
|
407 |
|
408 |
$this->_quote = $quote;
|
409 |
return $quote;
|
@@ -513,7 +482,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
513 |
}
|
514 |
|
515 |
/**
|
516 |
-
* Try to
|
517 |
*/
|
518 |
$cache = $this->getCache();
|
519 |
if ($cache && $cache->hasDomesticCountry()) {
|
@@ -634,11 +603,25 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
634 |
*/
|
635 |
public function getModuleVersion()
|
636 |
{
|
|
|
637 |
$version = (string) Mage::getConfig()->getModuleConfig('TIG_PostNL')->version;
|
638 |
|
639 |
return $version;
|
640 |
}
|
641 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
642 |
/**
|
643 |
* Gets a shipment's PakjeGemak address if available.
|
644 |
*
|
@@ -671,7 +654,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
671 |
* If this shipment's order was not placed with PostNL, we need to ignore any PakjeGemak addresses that may have
|
672 |
* been saved.
|
673 |
*/
|
674 |
-
|
|
|
|
|
675 |
return false;
|
676 |
}
|
677 |
|
@@ -701,8 +686,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
701 |
return $cache->getPostnlCoreCanUseStandard();
|
702 |
}
|
703 |
|
704 |
-
$
|
705 |
-
|
|
|
706 |
if (empty($standardProductOptions)) {
|
707 |
if ($cache) {
|
708 |
$cache->setPostnlCoreCanUseStandard(false)
|
@@ -733,8 +719,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
733 |
return $cache->getPostnlCoreCanUsePakjeGemak();
|
734 |
}
|
735 |
|
736 |
-
$
|
737 |
-
|
|
|
738 |
|
739 |
if (empty($pakjeGemakProductoptions)) {
|
740 |
if ($cache) {
|
@@ -765,8 +752,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
765 |
return $cache->getPostnlCoreCanUseEps();
|
766 |
}
|
767 |
|
768 |
-
$
|
769 |
-
|
|
|
770 |
|
771 |
if (empty($euProductOptions)) {
|
772 |
if ($cache) {
|
@@ -804,8 +792,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
804 |
return false;
|
805 |
}
|
806 |
|
807 |
-
$
|
808 |
-
|
|
|
809 |
|
810 |
if (empty($globalProductOptions)) {
|
811 |
if ($cache) {
|
@@ -835,6 +824,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
835 |
return $cache->getPostnlCoreCanUseBuspakje();
|
836 |
}
|
837 |
|
|
|
838 |
$storeId = Mage::app()->getStore()->getStoreId();
|
839 |
|
840 |
$isBuspakjeActive = Mage::getStoreConfigFlag(self::XPATH_USE_BUSPAKJE, $storeId);
|
@@ -848,8 +838,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
848 |
return false;
|
849 |
}
|
850 |
|
851 |
-
$
|
852 |
-
|
|
|
853 |
|
854 |
if (empty($buspakjeProductOptions)) {
|
855 |
if ($cache) {
|
@@ -908,10 +899,11 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
908 |
*/
|
909 |
public function saveConfigState($configState = array())
|
910 |
{
|
911 |
-
/**
|
912 |
-
|
913 |
-
|
914 |
-
|
|
|
915 |
if (!$adminUser) {
|
916 |
return false;
|
917 |
}
|
@@ -979,6 +971,20 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
979 |
return Mage::registry($registryKey);
|
980 |
}
|
981 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
982 |
/**
|
983 |
* If the buspakje calculation mode is set to 'manual', no further checks are required as the regular delivery
|
984 |
* option rules will apply.
|
@@ -999,6 +1005,81 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
999 |
return $fits;
|
1000 |
}
|
1001 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1002 |
/**
|
1003 |
* Gets the currently configured buspakje calculation mode.
|
1004 |
*
|
@@ -1060,6 +1141,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1060 |
$qty = $item->getQty();
|
1061 |
} elseif($item instanceof Mage_Sales_Model_Quote_Item) {
|
1062 |
if ($item->getParentItemId()) {
|
|
|
1063 |
$qty = $item->getParentItem()->getQty();
|
1064 |
} else {
|
1065 |
$qty = $item->getQty();
|
@@ -1328,7 +1410,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1328 |
return false;
|
1329 |
}
|
1330 |
|
1331 |
-
|
|
|
|
|
1332 |
return $isAllowed;
|
1333 |
}
|
1334 |
|
@@ -1383,7 +1467,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1383 |
*/
|
1384 |
public function isTestModeAllowed()
|
1385 |
{
|
1386 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
1387 |
return true;
|
1388 |
}
|
1389 |
|
@@ -1507,7 +1591,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1507 |
* active shipping methods in Magento.
|
1508 |
*/
|
1509 |
$postnlShippingMethodEnabled = false;
|
1510 |
-
$
|
|
|
|
|
1511 |
$activeMethods = Mage::getModel('postnl_core/system_config_source_shippingMethods')
|
1512 |
->toArray(true);
|
1513 |
|
@@ -1523,7 +1609,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1523 |
$linkEnd = '';
|
1524 |
|
1525 |
if ($this->isSystemConfig() || $this->isLoggingEnabled()) {
|
1526 |
-
$
|
|
|
|
|
1527 |
'adminhtml/system_config/edit',
|
1528 |
array(
|
1529 |
'_secure' => true,
|
@@ -1560,7 +1648,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1560 |
/**
|
1561 |
* The PostNL module only works with EUR as the shop's base currency
|
1562 |
*/
|
1563 |
-
|
|
|
|
|
1564 |
if ($baseCurrencyCode != 'EUR') {
|
1565 |
$errors = array(
|
1566 |
array(
|
@@ -1798,10 +1888,12 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1798 |
/**
|
1799 |
* Load the adminhtml config model and get the PostNL section.
|
1800 |
*
|
|
|
1801 |
* @var Varien_Simplexml_Element $section
|
1802 |
*/
|
1803 |
$configFields = Mage::getSingleton('adminhtml/config');
|
1804 |
-
|
|
|
1805 |
}
|
1806 |
|
1807 |
/**
|
@@ -1889,9 +1981,12 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1889 |
/**
|
1890 |
* @var Varien_Simplexml_Element $sectionGroup
|
1891 |
*/
|
|
|
1892 |
$sectionGroup = $section->groups->$group;
|
1893 |
|
|
|
1894 |
$label = (string) $sectionGroup->fields->$field->label;
|
|
|
1895 |
$groupLabel = (string) $sectionGroup->label;
|
1896 |
$groupName = $sectionGroup->getName();
|
1897 |
|
@@ -2032,7 +2127,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
2032 |
* Return labels are only available for orders that are shipped with PostNL.
|
2033 |
*/
|
2034 |
$shippingMethod = $order->getShippingMethod();
|
2035 |
-
|
|
|
|
|
2036 |
return false;
|
2037 |
}
|
2038 |
|
@@ -2056,9 +2153,14 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
2056 |
return false;
|
2057 |
}
|
2058 |
|
|
|
|
|
|
|
|
|
2059 |
/**
|
2060 |
* Loop through all confirmed shipments. If at least one of them is able to print return labels, return true.
|
2061 |
*/
|
|
|
2062 |
foreach ($postnlShipmentsCollection as $postnlShipment) {
|
2063 |
if ($postnlShipment->canPrintReturnLabels()) {
|
2064 |
return true;
|
@@ -2068,6 +2170,55 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
2068 |
return false;
|
2069 |
}
|
2070 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2071 |
/**
|
2072 |
* Check if debug logging is enabled
|
2073 |
*
|
@@ -2126,6 +2277,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
2126 |
* @var Varien_Simplexml_Element $moduleConfig
|
2127 |
*/
|
2128 |
$moduleConfig = $config->getModuleConfig($moduleName);
|
|
|
2129 |
$codePool = (string) $moduleConfig->codePool;
|
2130 |
$path = $config->getOptions()->getCodeDir()
|
2131 |
. DS
|
@@ -2285,6 +2437,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
2285 |
/**
|
2286 |
* Check if the Enterprise_Enterprise extension is installed.
|
2287 |
*/
|
|
|
2288 |
if (Mage::getConfig()->getNode('modules')->Enterprise_Enterprise) {
|
2289 |
return true;
|
2290 |
}
|
@@ -2360,7 +2513,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
2360 |
public function getErrorUrl($errorCode)
|
2361 |
{
|
2362 |
$error = Mage::getConfig()->getNode('tig/errors/' . $errorCode);
|
|
|
2363 |
if ($error !== false && $error->url) {
|
|
|
2364 |
return (string) $error->url;
|
2365 |
}
|
2366 |
|
@@ -2554,6 +2709,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
2554 |
*/
|
2555 |
$error = Mage::getConfig()->getNode('tig/errors/' . $code);
|
2556 |
if ($error !== false) {
|
|
|
2557 |
$link = (string) $error->url;
|
2558 |
}
|
2559 |
}
|
@@ -2567,6 +2723,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
2567 |
* If the specified error was found and no message was supplied, get the error's default message.
|
2568 |
*/
|
2569 |
if ($error && !$message) {
|
|
|
2570 |
$message = (string) $error->message;
|
2571 |
}
|
2572 |
|
@@ -2584,6 +2741,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
2584 |
* If the specified error was found and no message type was supplied, get the error's default type.
|
2585 |
*/
|
2586 |
if ($error && !$messageType) {
|
|
|
2587 |
$messageType = (string) $error->type;
|
2588 |
}
|
2589 |
|
271 |
*/
|
272 |
protected $_domesticCountry;
|
273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
/**
|
275 |
* Get required fields array.
|
276 |
*
|
351 |
return $this->_cache;
|
352 |
}
|
353 |
|
354 |
+
/** @var TIG_PostNL_Model_Core_Cache $cache */
|
355 |
$cache = Mage::getSingleton('postnl_core/cache');
|
356 |
if (!$cache->canUseCache()) {
|
357 |
$cache = false;
|
370 |
return $this->_quote;
|
371 |
}
|
372 |
|
373 |
+
/** @var Mage_Checkout_Model_Session $session */
|
374 |
+
$session = Mage::getSingleton('checkout/session');
|
375 |
+
$quote = $session->getQuote();
|
376 |
|
377 |
$this->_quote = $quote;
|
378 |
return $quote;
|
482 |
}
|
483 |
|
484 |
/**
|
485 |
+
* Try to get the domestic country array from the cache.
|
486 |
*/
|
487 |
$cache = $this->getCache();
|
488 |
if ($cache && $cache->hasDomesticCountry()) {
|
603 |
*/
|
604 |
public function getModuleVersion()
|
605 |
{
|
606 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
607 |
$version = (string) Mage::getConfig()->getModuleConfig('TIG_PostNL')->version;
|
608 |
|
609 |
return $version;
|
610 |
}
|
611 |
|
612 |
+
/**
|
613 |
+
* Get the current stability of the PostNL extension's code base.
|
614 |
+
*
|
615 |
+
* @return string
|
616 |
+
*/
|
617 |
+
public function getModuleStability()
|
618 |
+
{
|
619 |
+
$stability = Mage::getConfig()->getXpath('tig/stability/postnl');
|
620 |
+
$stability = (string) $stability[0];
|
621 |
+
|
622 |
+
return $stability;
|
623 |
+
}
|
624 |
+
|
625 |
/**
|
626 |
* Gets a shipment's PakjeGemak address if available.
|
627 |
*
|
654 |
* If this shipment's order was not placed with PostNL, we need to ignore any PakjeGemak addresses that may have
|
655 |
* been saved.
|
656 |
*/
|
657 |
+
/** @var TIG_PostNL_Helper_Carrier $carrierHelper */
|
658 |
+
$carrierHelper = Mage::helper('postnl/carrier');
|
659 |
+
if (!$carrierHelper->isPostnlShippingMethod($shippingMethod)) {
|
660 |
return false;
|
661 |
}
|
662 |
|
686 |
return $cache->getPostnlCoreCanUseStandard();
|
687 |
}
|
688 |
|
689 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions $standardProductOptionsModel */
|
690 |
+
$standardProductOptionsModel = Mage::getModel('postnl_core/system_config_source_standardProductOptions');
|
691 |
+
$standardProductOptions = $standardProductOptionsModel->getAvailableOptions();
|
692 |
if (empty($standardProductOptions)) {
|
693 |
if ($cache) {
|
694 |
$cache->setPostnlCoreCanUseStandard(false)
|
719 |
return $cache->getPostnlCoreCanUsePakjeGemak();
|
720 |
}
|
721 |
|
722 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions $pakjeGemakProductoptionsModel */
|
723 |
+
$pakjeGemakProductoptionsModel = Mage::getModel('postnl_core/system_config_source_pakjeGemakProductOptions');
|
724 |
+
$pakjeGemakProductoptions = $pakjeGemakProductoptionsModel->getAvailableOptions();
|
725 |
|
726 |
if (empty($pakjeGemakProductoptions)) {
|
727 |
if ($cache) {
|
752 |
return $cache->getPostnlCoreCanUseEps();
|
753 |
}
|
754 |
|
755 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions $euProductOptionsModel */
|
756 |
+
$euProductOptionsModel = Mage::getModel('postnl_core/system_config_source_euProductOptions');
|
757 |
+
$euProductOptions = $euProductOptionsModel->getAvailableOptions();
|
758 |
|
759 |
if (empty($euProductOptions)) {
|
760 |
if ($cache) {
|
792 |
return false;
|
793 |
}
|
794 |
|
795 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_GlobalProductOptions $globalProductOptionsModel */
|
796 |
+
$globalProductOptionsModel = Mage::getModel('postnl_core/system_config_source_globalProductOptions');
|
797 |
+
$globalProductOptions = $globalProductOptionsModel->getAvailableOptions();
|
798 |
|
799 |
if (empty($globalProductOptions)) {
|
800 |
if ($cache) {
|
824 |
return $cache->getPostnlCoreCanUseBuspakje();
|
825 |
}
|
826 |
|
827 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
828 |
$storeId = Mage::app()->getStore()->getStoreId();
|
829 |
|
830 |
$isBuspakjeActive = Mage::getStoreConfigFlag(self::XPATH_USE_BUSPAKJE, $storeId);
|
838 |
return false;
|
839 |
}
|
840 |
|
841 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_BuspakjeProductOptions $buspakjeProductOptionsModel */
|
842 |
+
$buspakjeProductOptionsModel = Mage::getModel('postnl_core/system_config_source_buspakjeProductOptions');
|
843 |
+
$buspakjeProductOptions = $buspakjeProductOptionsModel->getAvailableOptions();
|
844 |
|
845 |
if (empty($buspakjeProductOptions)) {
|
846 |
if ($cache) {
|
899 |
*/
|
900 |
public function saveConfigState($configState = array())
|
901 |
{
|
902 |
+
/** @var Mage_Admin_Model_Session $adminSession */
|
903 |
+
$adminSession = Mage::getSingleton('admin/session');
|
904 |
+
/** @var Mage_Admin_Model_User $adminUser */
|
905 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
906 |
+
$adminUser = $adminSession->getUser();
|
907 |
if (!$adminUser) {
|
908 |
return false;
|
909 |
}
|
971 |
return Mage::registry($registryKey);
|
972 |
}
|
973 |
|
974 |
+
/**
|
975 |
+
* Orders to Belgium are never letter box parcels.
|
976 |
+
*/
|
977 |
+
if ($this->isBe($quote)) {
|
978 |
+
return false;
|
979 |
+
}
|
980 |
+
|
981 |
+
/**
|
982 |
+
* Food orders are never letter box parcels.
|
983 |
+
*/
|
984 |
+
if ($this->quoteIsFood($quote)) {
|
985 |
+
return false;
|
986 |
+
}
|
987 |
+
|
988 |
/**
|
989 |
* If the buspakje calculation mode is set to 'manual', no further checks are required as the regular delivery
|
990 |
* option rules will apply.
|
1005 |
return $fits;
|
1006 |
}
|
1007 |
|
1008 |
+
/**
|
1009 |
+
* Checks if the current quote is classified as a food quote, and saves the result in the cache.
|
1010 |
+
*
|
1011 |
+
* @param Mage_Sales_Model_Quote $quote
|
1012 |
+
*
|
1013 |
+
* @return boolean
|
1014 |
+
*/
|
1015 |
+
public function quoteIsFood(Mage_Sales_Model_Quote $quote = null)
|
1016 |
+
{
|
1017 |
+
if (is_null($quote)) {
|
1018 |
+
$quote = $this->getQuote();
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
/**
|
1022 |
+
* Form a unique registry key for the current quote (if available) so we can cache the result of this method in
|
1023 |
+
* the registry.
|
1024 |
+
*/
|
1025 |
+
$registryKey = 'postnl_quote_is_food' . $quote->getId();
|
1026 |
+
|
1027 |
+
/**
|
1028 |
+
* Check if the result of this method has been cached in the registry.
|
1029 |
+
*/
|
1030 |
+
if (Mage::registry($registryKey) !== null) {
|
1031 |
+
return Mage::registry($registryKey);
|
1032 |
+
}
|
1033 |
+
|
1034 |
+
$quoteFoodType = (bool) $this->getQuoteFoodType($quote);
|
1035 |
+
|
1036 |
+
Mage::register($registryKey, $quoteFoodType);
|
1037 |
+
return $quoteFoodType;
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
/**
|
1041 |
+
* Returns the food Type of the provided quote.
|
1042 |
+
*
|
1043 |
+
* Cool products are leading. So if we find a cooled products, the entire quote is marked as Cool Products.
|
1044 |
+
* If there is a Dry & Groceries product, but no Cooled Product, the quote is marked as Dry & Groceries.
|
1045 |
+
* If neither of above is found, the quote is marked as Non-Food.
|
1046 |
+
*
|
1047 |
+
* @param Mage_Sales_Model_Quote $quote
|
1048 |
+
*
|
1049 |
+
* @return int
|
1050 |
+
* 0 = Non-Food
|
1051 |
+
* 1 = Dry & Groceries
|
1052 |
+
* 2 = Cool Products
|
1053 |
+
*/
|
1054 |
+
public function getQuoteFoodType(Mage_Sales_Model_Quote $quote = null)
|
1055 |
+
{
|
1056 |
+
if (!$quote) {
|
1057 |
+
$quote = $this->getQuote();
|
1058 |
+
}
|
1059 |
+
|
1060 |
+
$quoteItems = $quote->getAllItems();
|
1061 |
+
|
1062 |
+
$foodType = 0;
|
1063 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $deliveryOptionsHelper */
|
1064 |
+
$deliveryOptionsHelper = Mage::app()->getConfig()->getHelperClassName('postnl/deliveryOptions');
|
1065 |
+
/** @var Mage_Sales_Model_Quote_Item $quoteItem */
|
1066 |
+
foreach ($quoteItems as $quoteItem) {
|
1067 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1068 |
+
$postnlProductType = $quoteItem->getProduct()->getPostnlProductType();
|
1069 |
+
|
1070 |
+
if ($postnlProductType == $deliveryOptionsHelper::FOOD_TYPE_COOL_PRODUCTS) {
|
1071 |
+
$foodType = $postnlProductType;
|
1072 |
+
break;
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
if ($postnlProductType == $deliveryOptionsHelper::FOOD_TYPE_DRY_GROCERIES) {
|
1076 |
+
$foodType = $postnlProductType;
|
1077 |
+
}
|
1078 |
+
}
|
1079 |
+
|
1080 |
+
return $foodType;
|
1081 |
+
}
|
1082 |
+
|
1083 |
/**
|
1084 |
* Gets the currently configured buspakje calculation mode.
|
1085 |
*
|
1141 |
$qty = $item->getQty();
|
1142 |
} elseif($item instanceof Mage_Sales_Model_Quote_Item) {
|
1143 |
if ($item->getParentItemId()) {
|
1144 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1145 |
$qty = $item->getParentItem()->getQty();
|
1146 |
} else {
|
1147 |
$qty = $item->getQty();
|
1410 |
return false;
|
1411 |
}
|
1412 |
|
1413 |
+
/** @var Mage_Admin_Model_Session $adminSession */
|
1414 |
+
$adminSession = Mage::getSingleton('admin/session');
|
1415 |
+
$isAllowed = $adminSession->isAllowed($aclPath);
|
1416 |
return $isAllowed;
|
1417 |
}
|
1418 |
|
1467 |
*/
|
1468 |
public function isTestModeAllowed()
|
1469 |
{
|
1470 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
1471 |
return true;
|
1472 |
}
|
1473 |
|
1591 |
* active shipping methods in Magento.
|
1592 |
*/
|
1593 |
$postnlShippingMethodEnabled = false;
|
1594 |
+
/** @var TIG_PostNL_Helper_Carrier $carrierHelper */
|
1595 |
+
$carrierHelper = Mage::helper('postnl/carrier');
|
1596 |
+
$postnlShippingMethods = $carrierHelper->getPostnlShippingMethods();
|
1597 |
$activeMethods = Mage::getModel('postnl_core/system_config_source_shippingMethods')
|
1598 |
->toArray(true);
|
1599 |
|
1609 |
$linkEnd = '';
|
1610 |
|
1611 |
if ($this->isSystemConfig() || $this->isLoggingEnabled()) {
|
1612 |
+
/** @var Mage_Adminhtml_Helper_Data $adminhtmlHelper */
|
1613 |
+
$adminhtmlHelper = Mage::helper("adminhtml");
|
1614 |
+
$shippingMethodSectionurl = $adminhtmlHelper->getUrl(
|
1615 |
'adminhtml/system_config/edit',
|
1616 |
array(
|
1617 |
'_secure' => true,
|
1648 |
/**
|
1649 |
* The PostNL module only works with EUR as the shop's base currency
|
1650 |
*/
|
1651 |
+
/** @var Mage_Core_Model_Store $store */
|
1652 |
+
$store = Mage::getModel('core/store')->load($storeId);
|
1653 |
+
$baseCurrencyCode = $store->getBaseCurrencyCode();
|
1654 |
if ($baseCurrencyCode != 'EUR') {
|
1655 |
$errors = array(
|
1656 |
array(
|
1888 |
/**
|
1889 |
* Load the adminhtml config model and get the PostNL section.
|
1890 |
*
|
1891 |
+
* @var Mage_Adminhtml_Model_Config $configFields
|
1892 |
* @var Varien_Simplexml_Element $section
|
1893 |
*/
|
1894 |
$configFields = Mage::getSingleton('adminhtml/config');
|
1895 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
1896 |
+
$section = $configFields->getSections('postnl')->postnl;
|
1897 |
}
|
1898 |
|
1899 |
/**
|
1981 |
/**
|
1982 |
* @var Varien_Simplexml_Element $sectionGroup
|
1983 |
*/
|
1984 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
1985 |
$sectionGroup = $section->groups->$group;
|
1986 |
|
1987 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
1988 |
$label = (string) $sectionGroup->fields->$field->label;
|
1989 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
1990 |
$groupLabel = (string) $sectionGroup->label;
|
1991 |
$groupName = $sectionGroup->getName();
|
1992 |
|
2127 |
* Return labels are only available for orders that are shipped with PostNL.
|
2128 |
*/
|
2129 |
$shippingMethod = $order->getShippingMethod();
|
2130 |
+
/** @var TIG_PostNL_Helper_Carrier $carrierHelper */
|
2131 |
+
$carrierHelper = Mage::helper('postnl/carrier');
|
2132 |
+
if (!$carrierHelper->isPostnlShippingMethod($shippingMethod)) {
|
2133 |
return false;
|
2134 |
}
|
2135 |
|
2153 |
return false;
|
2154 |
}
|
2155 |
|
2156 |
+
if ($this->isFoodOrder($order)) {
|
2157 |
+
return false;
|
2158 |
+
}
|
2159 |
+
|
2160 |
/**
|
2161 |
* Loop through all confirmed shipments. If at least one of them is able to print return labels, return true.
|
2162 |
*/
|
2163 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
2164 |
foreach ($postnlShipmentsCollection as $postnlShipment) {
|
2165 |
if ($postnlShipment->canPrintReturnLabels()) {
|
2166 |
return true;
|
2170 |
return false;
|
2171 |
}
|
2172 |
|
2173 |
+
/**
|
2174 |
+
* Determines if the order contains food products.
|
2175 |
+
*
|
2176 |
+
* @param Mage_Sales_Model_Order $order
|
2177 |
+
*
|
2178 |
+
* @return bool
|
2179 |
+
*/
|
2180 |
+
public function isFoodOrder($order)
|
2181 |
+
{
|
2182 |
+
$orderItems = $order->getAllItems();
|
2183 |
+
|
2184 |
+
/** @var Mage_Sales_Model_Order_Item $orderItem */
|
2185 |
+
foreach ($orderItems as $orderItem) {
|
2186 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
2187 |
+
$postnlProductType = $orderItem->getProduct()->getPostnlProductType();
|
2188 |
+
|
2189 |
+
if ($postnlProductType) {
|
2190 |
+
return true;
|
2191 |
+
}
|
2192 |
+
}
|
2193 |
+
|
2194 |
+
return false;
|
2195 |
+
}
|
2196 |
+
|
2197 |
+
/**
|
2198 |
+
* Check if the provided quote or order is being shipped to Belgium.
|
2199 |
+
*
|
2200 |
+
* @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $object
|
2201 |
+
*
|
2202 |
+
* @return bool
|
2203 |
+
*/
|
2204 |
+
public function isBe($object)
|
2205 |
+
{
|
2206 |
+
if (!($object instanceof Mage_Sales_Model_Order) && !($object instanceof Mage_Sales_Model_Quote)) {
|
2207 |
+
throw new InvalidArgumentException("The object parameter must be an instance of an order or a quote.");
|
2208 |
+
}
|
2209 |
+
|
2210 |
+
$shippingAddress = $object->getShippingAddress();
|
2211 |
+
if (!$shippingAddress) {
|
2212 |
+
return false;
|
2213 |
+
}
|
2214 |
+
|
2215 |
+
if ($shippingAddress->getCountryId() == 'BE') {
|
2216 |
+
return true;
|
2217 |
+
}
|
2218 |
+
|
2219 |
+
return false;
|
2220 |
+
}
|
2221 |
+
|
2222 |
/**
|
2223 |
* Check if debug logging is enabled
|
2224 |
*
|
2277 |
* @var Varien_Simplexml_Element $moduleConfig
|
2278 |
*/
|
2279 |
$moduleConfig = $config->getModuleConfig($moduleName);
|
2280 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
2281 |
$codePool = (string) $moduleConfig->codePool;
|
2282 |
$path = $config->getOptions()->getCodeDir()
|
2283 |
. DS
|
2437 |
/**
|
2438 |
* Check if the Enterprise_Enterprise extension is installed.
|
2439 |
*/
|
2440 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
2441 |
if (Mage::getConfig()->getNode('modules')->Enterprise_Enterprise) {
|
2442 |
return true;
|
2443 |
}
|
2513 |
public function getErrorUrl($errorCode)
|
2514 |
{
|
2515 |
$error = Mage::getConfig()->getNode('tig/errors/' . $errorCode);
|
2516 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
2517 |
if ($error !== false && $error->url) {
|
2518 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
2519 |
return (string) $error->url;
|
2520 |
}
|
2521 |
|
2709 |
*/
|
2710 |
$error = Mage::getConfig()->getNode('tig/errors/' . $code);
|
2711 |
if ($error !== false) {
|
2712 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
2713 |
$link = (string) $error->url;
|
2714 |
}
|
2715 |
}
|
2723 |
* If the specified error was found and no message was supplied, get the error's default message.
|
2724 |
*/
|
2725 |
if ($error && !$message) {
|
2726 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
2727 |
$message = (string) $error->message;
|
2728 |
}
|
2729 |
|
2741 |
* If the specified error was found and no message type was supplied, get the error's default type.
|
2742 |
*/
|
2743 |
if ($error && !$messageType) {
|
2744 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
2745 |
$messageType = (string) $error->type;
|
2746 |
}
|
2747 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
*/
|
@@ -79,6 +79,43 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
79 |
*/
|
80 |
protected $_postnlDeliveryDelay = 1;
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
/**
|
83 |
* Build an array of valid delivery dates. Used for calculating delivery and shipping dates.
|
84 |
*
|
@@ -106,6 +143,10 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
106 |
$shippingDays = Mage::getStoreConfig(self::XPATH_SHIPPING_DAYS, $storeId);
|
107 |
$shippingDays = explode(',', $shippingDays);
|
108 |
|
|
|
|
|
|
|
|
|
109 |
/**
|
110 |
* Sunday delivery and sunday sorting are not available for letter box parcels.
|
111 |
*/
|
@@ -117,7 +158,7 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
117 |
/**
|
118 |
* If a day is configured as shipping day, this day + the PostNL shipping delay is available as delivery day.
|
119 |
*/
|
120 |
-
foreach($shippingDays as $shippingDay) {
|
121 |
$dayToEnable = ($shippingDay + $this->_postnlDeliveryDelay) % 7;
|
122 |
$this->_validDeliveryDays[$dayToEnable] = 1;
|
123 |
}
|
@@ -189,12 +230,13 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
189 |
/**
|
190 |
* Calculates the date an order should be delivered, based on the order date
|
191 |
*
|
192 |
-
* @param mixed
|
193 |
-
* @param int
|
|
|
194 |
*
|
195 |
* @return DateTime
|
196 |
*/
|
197 |
-
public function getDeliveryDate($date, $storeId)
|
198 |
{
|
199 |
$orderDateObject = $this->getUtcDateTime($date, $storeId);
|
200 |
|
@@ -211,6 +253,13 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
211 |
$weekday = $orderDateObject->format('N');
|
212 |
$shippingDuration = $this->getQuoteShippingDuration();
|
213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
/**
|
215 |
* Get a possible addition of day(s), if the found deliveryDay is not a valid deliveryday.
|
216 |
*/
|
@@ -238,6 +287,10 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
238 |
$dateObject = $this->getDeliveryDate($date, $storeId);
|
239 |
$sundaySorting = Mage::getStoreConfig(self::XPATH_ALLOW_SUNDAY_SORTING, $storeId);
|
240 |
|
|
|
|
|
|
|
|
|
241 |
/**
|
242 |
* If the delivery day is monday, the shipment possibly needs to be sent on saturday, if sundaydelivery is not
|
243 |
* allowed, and sundaysorting is active.
|
@@ -270,9 +323,14 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
270 |
* Get required config values and date object.
|
271 |
*/
|
272 |
$sundaySorting = Mage::getStoreConfig(self::XPATH_ALLOW_SUNDAY_SORTING, $storeId);
|
|
|
|
|
|
|
|
|
|
|
273 |
$shippingDays = Mage::getStoreConfig(self::XPATH_SHIPPING_DAYS, $storeId);
|
274 |
$shippingDaysArray = explode(',', $shippingDays);
|
275 |
-
$dateObject = $this->getUtcDateTime($deliveryDate, $storeId);
|
276 |
|
277 |
/**
|
278 |
* If the delivery day is monday, the shipment possibly needs to be sent on saturday, if sundaydelivery is not
|
@@ -284,7 +342,18 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
284 |
}
|
285 |
}
|
286 |
|
|
|
|
|
|
|
287 |
$dateObject->sub(new DateInterval("P{$this->_postnlDeliveryDelay}D"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
return $dateObject;
|
289 |
}
|
290 |
|
@@ -292,11 +361,12 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
292 |
* Returns an UTC DateTime object built from the orderdate.
|
293 |
*
|
294 |
* @param mixed $date
|
295 |
-
* @param
|
|
|
296 |
*
|
297 |
* @return DateTime
|
298 |
*/
|
299 |
-
public function getUtcDateTime($date, $storeId)
|
300 |
{
|
301 |
/**
|
302 |
* If the orderDate is not an object. Make an object using the current store timezone
|
@@ -309,8 +379,10 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
309 |
/**
|
310 |
* If the orderDate object is not in UTC, change the timezone to UTC.
|
311 |
*/
|
312 |
-
if ($
|
313 |
-
$date->
|
|
|
|
|
314 |
}
|
315 |
|
316 |
return $date;
|
@@ -319,27 +391,34 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
319 |
/**
|
320 |
* Calculates if the orderDate is past the configured cutoff time.
|
321 |
*
|
322 |
-
* @param DateTime
|
323 |
-
* @param int
|
|
|
324 |
*
|
325 |
-
* @return
|
326 |
*/
|
327 |
-
public function isPastCutOff($orderDateObject, $storeId)
|
328 |
{
|
329 |
-
|
|
|
|
|
|
|
|
|
330 |
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
|
|
|
|
337 |
}
|
338 |
|
339 |
/**
|
340 |
* Check if the order time is before the cutoff time, disregarding dates.
|
341 |
*/
|
342 |
-
$cutoff = $this->getCutOff($storeId, $
|
343 |
$orderTime = $orderDateObject->format("H:i:s");
|
344 |
|
345 |
return ($cutoff < $orderTime);
|
@@ -349,28 +428,36 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
349 |
* Gets the cut off time for the given store. When $forSunday is set to true,
|
350 |
* will return sunday cut off time instead.
|
351 |
*
|
352 |
-
* @param int
|
353 |
-
* @param
|
354 |
*
|
355 |
* @return DateTime
|
356 |
*/
|
357 |
-
public function getCutOff($storeId = 0, $
|
358 |
{
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
}
|
|
|
366 |
$cutoff = Mage::getStoreConfig($xpathToUse, $storeId);
|
|
|
367 |
$cutoff = new DateTime($cutoff, new DateTimeZone("Europe/Amsterdam"));
|
368 |
$correctedCutOff = $this->getUtcDateTime($cutoff, $storeId)->format('H:i:s');
|
369 |
return $correctedCutOff;
|
370 |
}
|
371 |
|
372 |
/**
|
373 |
-
* Checks if the found delivery day is valid. If this is not the case, add a day to the
|
374 |
* point to the next found day, and repeat this.
|
375 |
*
|
376 |
* @param DateTime|int $checkValidDay
|
@@ -466,4 +553,4 @@ class TIG_PostNL_Helper_Date extends TIG_PostNL_Helper_DeliveryOptions
|
|
466 |
|
467 |
return $deliveryDate;
|
468 |
}
|
469 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
*/
|
79 |
*/
|
80 |
protected $_postnlDeliveryDelay = 1;
|
81 |
|
82 |
+
/**
|
83 |
+
* @var bool
|
84 |
+
*/
|
85 |
+
protected $_useFoodCutOffTime = false;
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @param int $postnlDeliveryDelay
|
89 |
+
*
|
90 |
+
* @return $this
|
91 |
+
*/
|
92 |
+
public function setPostnlDeliveryDelay($postnlDeliveryDelay)
|
93 |
+
{
|
94 |
+
$this->_postnlDeliveryDelay = (int) $postnlDeliveryDelay;
|
95 |
+
|
96 |
+
return $this;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @return boolean
|
101 |
+
*/
|
102 |
+
public function useFoodCutOffTime()
|
103 |
+
{
|
104 |
+
return $this->_useFoodCutOffTime;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @param boolean $useFoodCutOffTime
|
109 |
+
*
|
110 |
+
* @return $this
|
111 |
+
*/
|
112 |
+
public function setUseFoodCutOffTime($useFoodCutOffTime)
|
113 |
+
{
|
114 |
+
$this->_useFoodCutOffTime = $useFoodCutOffTime;
|
115 |
+
|
116 |
+
return $this;
|
117 |
+
}
|
118 |
+
|
119 |
/**
|
120 |
* Build an array of valid delivery dates. Used for calculating delivery and shipping dates.
|
121 |
*
|
143 |
$shippingDays = Mage::getStoreConfig(self::XPATH_SHIPPING_DAYS, $storeId);
|
144 |
$shippingDays = explode(',', $shippingDays);
|
145 |
|
146 |
+
if ($this->isBe($this->getQuote())) {
|
147 |
+
$sundaySorting = Mage::getStoreConfig(self::XPATH_ALLOW_SUNDAY_SORTING_BE, $storeId);
|
148 |
+
}
|
149 |
+
|
150 |
/**
|
151 |
* Sunday delivery and sunday sorting are not available for letter box parcels.
|
152 |
*/
|
158 |
/**
|
159 |
* If a day is configured as shipping day, this day + the PostNL shipping delay is available as delivery day.
|
160 |
*/
|
161 |
+
foreach ($shippingDays as $shippingDay) {
|
162 |
$dayToEnable = ($shippingDay + $this->_postnlDeliveryDelay) % 7;
|
163 |
$this->_validDeliveryDays[$dayToEnable] = 1;
|
164 |
}
|
230 |
/**
|
231 |
* Calculates the date an order should be delivered, based on the order date
|
232 |
*
|
233 |
+
* @param mixed $date
|
234 |
+
* @param int $storeId
|
235 |
+
* @param bool $allowSameDay
|
236 |
*
|
237 |
* @return DateTime
|
238 |
*/
|
239 |
+
public function getDeliveryDate($date, $storeId, $allowSameDay = true)
|
240 |
{
|
241 |
$orderDateObject = $this->getUtcDateTime($date, $storeId);
|
242 |
|
253 |
$weekday = $orderDateObject->format('N');
|
254 |
$shippingDuration = $this->getQuoteShippingDuration();
|
255 |
|
256 |
+
/**
|
257 |
+
* The shipping duration may only be less than 1 when same day is allowed.
|
258 |
+
*/
|
259 |
+
if ($shippingDuration < 1 && !$allowSameDay) {
|
260 |
+
$shippingDuration = 1;
|
261 |
+
}
|
262 |
+
|
263 |
/**
|
264 |
* Get a possible addition of day(s), if the found deliveryDay is not a valid deliveryday.
|
265 |
*/
|
287 |
$dateObject = $this->getDeliveryDate($date, $storeId);
|
288 |
$sundaySorting = Mage::getStoreConfig(self::XPATH_ALLOW_SUNDAY_SORTING, $storeId);
|
289 |
|
290 |
+
if ($this->isBe($this->getQuote())) {
|
291 |
+
$sundaySorting = Mage::getStoreConfig(self::XPATH_ALLOW_SUNDAY_SORTING_BE, $storeId);
|
292 |
+
}
|
293 |
+
|
294 |
/**
|
295 |
* If the delivery day is monday, the shipment possibly needs to be sent on saturday, if sundaydelivery is not
|
296 |
* allowed, and sundaysorting is active.
|
323 |
* Get required config values and date object.
|
324 |
*/
|
325 |
$sundaySorting = Mage::getStoreConfig(self::XPATH_ALLOW_SUNDAY_SORTING, $storeId);
|
326 |
+
|
327 |
+
if ($this->isBe($this->getQuote())) {
|
328 |
+
$sundaySorting = Mage::getStoreConfig(self::XPATH_ALLOW_SUNDAY_SORTING_BE, $storeId);
|
329 |
+
}
|
330 |
+
|
331 |
$shippingDays = Mage::getStoreConfig(self::XPATH_SHIPPING_DAYS, $storeId);
|
332 |
$shippingDaysArray = explode(',', $shippingDays);
|
333 |
+
$dateObject = $this->getUtcDateTime($deliveryDate, $storeId, false);
|
334 |
|
335 |
/**
|
336 |
* If the delivery day is monday, the shipment possibly needs to be sent on saturday, if sundaydelivery is not
|
342 |
}
|
343 |
}
|
344 |
|
345 |
+
/**
|
346 |
+
* Substract the delivery delay from the delivery date to get to the shipping date.
|
347 |
+
*/
|
348 |
$dateObject->sub(new DateInterval("P{$this->_postnlDeliveryDelay}D"));
|
349 |
+
|
350 |
+
/**
|
351 |
+
* If the projected shipping date is not a valid shipping date, substract 1 day and check again.
|
352 |
+
*/
|
353 |
+
while (!in_array($dateObject->format('N'), $shippingDaysArray)) {
|
354 |
+
$dateObject->sub(new DateInterval("P1D"));
|
355 |
+
}
|
356 |
+
|
357 |
return $dateObject;
|
358 |
}
|
359 |
|
361 |
* Returns an UTC DateTime object built from the orderdate.
|
362 |
*
|
363 |
* @param mixed $date
|
364 |
+
* @param $storeId
|
365 |
+
* @param bool $convertTimeZone
|
366 |
*
|
367 |
* @return DateTime
|
368 |
*/
|
369 |
+
public function getUtcDateTime($date, $storeId, $convertTimeZone = true)
|
370 |
{
|
371 |
/**
|
372 |
* If the orderDate is not an object. Make an object using the current store timezone
|
379 |
/**
|
380 |
* If the orderDate object is not in UTC, change the timezone to UTC.
|
381 |
*/
|
382 |
+
if ($convertTimeZone) {
|
383 |
+
if ($date->getTimeZone()->getName() != 'UTC') {
|
384 |
+
$date->setTimeZone(new DateTimeZone('UTC'));
|
385 |
+
}
|
386 |
}
|
387 |
|
388 |
return $date;
|
391 |
/**
|
392 |
* Calculates if the orderDate is past the configured cutoff time.
|
393 |
*
|
394 |
+
* @param DateTime $orderDateObject
|
395 |
+
* @param int $storeId
|
396 |
+
* @param null|string $type
|
397 |
*
|
398 |
+
* @return bool
|
399 |
*/
|
400 |
+
public function isPastCutOff($orderDateObject, $storeId, $type = null)
|
401 |
{
|
402 |
+
if (!$type) {
|
403 |
+
if ($this->useFoodCutOffTime()) {
|
404 |
+
$type = 'food';
|
405 |
+
} else {
|
406 |
+
$weekDay = $orderDateObject->format('w');
|
407 |
|
408 |
+
/**
|
409 |
+
* If the weekday == 7, we need to check for sunday cutoff time instead.
|
410 |
+
*/
|
411 |
+
$type = 'weekday';
|
412 |
+
if ($weekDay == self::SUNDAY) {
|
413 |
+
$type = 'sunday';
|
414 |
+
}
|
415 |
+
}
|
416 |
}
|
417 |
|
418 |
/**
|
419 |
* Check if the order time is before the cutoff time, disregarding dates.
|
420 |
*/
|
421 |
+
$cutoff = $this->getCutOff($storeId, $type);
|
422 |
$orderTime = $orderDateObject->format("H:i:s");
|
423 |
|
424 |
return ($cutoff < $orderTime);
|
428 |
* Gets the cut off time for the given store. When $forSunday is set to true,
|
429 |
* will return sunday cut off time instead.
|
430 |
*
|
431 |
+
* @param int $storeId
|
432 |
+
* @param string $type
|
433 |
*
|
434 |
* @return DateTime
|
435 |
*/
|
436 |
+
public function getCutOff($storeId = 0, $type = 'weekday')
|
437 |
{
|
438 |
+
switch ($type) {
|
439 |
+
case 'sunday':
|
440 |
+
$xpathToUse = self::XPATH_SUNDAY_CUTOFF_TIME;
|
441 |
+
break;
|
442 |
+
case 'sameday':
|
443 |
+
case 'food':
|
444 |
+
$xpathToUse = self::XPATH_SAMEDAY_CUTOFF_TIME;
|
445 |
+
break;
|
446 |
+
case 'weekday':
|
447 |
+
default:
|
448 |
+
$xpathToUse = self::XPATH_CUTOFF_TIME;
|
449 |
+
break;
|
450 |
}
|
451 |
+
|
452 |
$cutoff = Mage::getStoreConfig($xpathToUse, $storeId);
|
453 |
+
|
454 |
$cutoff = new DateTime($cutoff, new DateTimeZone("Europe/Amsterdam"));
|
455 |
$correctedCutOff = $this->getUtcDateTime($cutoff, $storeId)->format('H:i:s');
|
456 |
return $correctedCutOff;
|
457 |
}
|
458 |
|
459 |
/**
|
460 |
+
* Checks if the found delivery day is valid. If this is not the case, add a day to the delivery day correction,
|
461 |
* point to the next found day, and repeat this.
|
462 |
*
|
463 |
* @param DateTime|int $checkValidDay
|
553 |
|
554 |
return $deliveryDate;
|
555 |
}
|
556 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @todo Cache the available delivery options in the checkout session. That way we only recalculate them if the quote
|
@@ -42,17 +42,21 @@
|
|
42 |
class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
43 |
{
|
44 |
/**
|
45 |
-
* Xpath to delivery options enabled config
|
46 |
*/
|
47 |
-
const XPATH_DELIVERY_OPTIONS_ACTIVE
|
|
|
|
|
48 |
|
49 |
/**
|
50 |
* Xpaths to various possible delivery option settings.
|
51 |
*/
|
52 |
const XPATH_ENABLE_PAKJEGEMAK = 'postnl/delivery_options/enable_pakjegemak';
|
|
|
53 |
const XPATH_ENABLE_PAKJEGEMAK_EXPRESS = 'postnl/delivery_options/enable_pakjegemak_express';
|
54 |
const XPATH_ENABLE_PAKKETAUTOMAAT_LOCATIONS = 'postnl/delivery_options/enable_pakketautomaat_locations';
|
55 |
const XPATH_ENABLE_DELIVERY_DAYS = 'postnl/delivery_options/enable_delivery_days';
|
|
|
56 |
const XPATH_ENABLE_TIMEFRAMES = 'postnl/delivery_options/enable_timeframes';
|
57 |
const XPATH_ENABLE_EVENING_TIMEFRAMES = 'postnl/delivery_options/enable_evening_timeframes';
|
58 |
|
@@ -61,6 +65,7 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
61 |
*/
|
62 |
const XPATH_STOCK_OPTIONS = 'postnl/delivery_options/stock_options';
|
63 |
const XPATH_ALLOW_SUNDAY_SORTING = 'postnl/delivery_options/allow_sunday_sorting';
|
|
|
64 |
const XPATH_SHOW_OPTIONS_FOR_BUSPAKJE = 'postnl/delivery_options/show_options_for_buspakje';
|
65 |
const XPATH_SHOW_ALL_OPTIONS_FOR_BUSPAKJE = 'postnl/delivery_options/show_all_options_for_buspakje';
|
66 |
const XPATH_ENABLE_DELIVERY_DAYS_FOR_BUSPAKJE = 'postnl/delivery_options/enable_delivery_days_for_buspakje';
|
@@ -68,6 +73,9 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
68 |
const XPATH_ENABLE_PAKKETAUTOMAAT_FOR_BUSPAKJE = 'postnl/delivery_options/enable_pakketautomaat_for_buspakje';
|
69 |
const XPATH_STATED_ADDRESS_ONLY_OPTION = 'postnl/delivery_options/stated_address_only_option';
|
70 |
const XPATH_ENABLE_SUNDAY_DELIVERY = 'postnl/delivery_options/enable_sunday_delivery';
|
|
|
|
|
|
|
71 |
|
72 |
/**
|
73 |
* Xpaths to extra fee config settings.
|
@@ -90,10 +98,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
90 |
/**
|
91 |
* Xpath for shipping duration setting.
|
92 |
*/
|
93 |
-
const XPATH_SHIPPING_DURATION
|
94 |
-
const XPATH_CUTOFF_TIME
|
95 |
-
const XPATH_SUNDAY_CUTOFF_TIME
|
96 |
-
const
|
|
|
97 |
|
98 |
/**
|
99 |
* Xpath to the 'stated_address_only_checked' setting.
|
@@ -121,6 +130,12 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
121 |
*/
|
122 |
const MAX_FEE = 2;
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
/**
|
125 |
* @var array
|
126 |
*/
|
@@ -132,6 +147,14 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
132 |
'PA',
|
133 |
'Sunday',
|
134 |
'Monday',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
);
|
136 |
|
137 |
/**
|
@@ -149,6 +172,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
149 |
*/
|
150 |
protected $_configMinQty = null;
|
151 |
|
|
|
|
|
|
|
|
|
|
|
152 |
/**
|
153 |
* @return int
|
154 |
*/
|
@@ -255,8 +283,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
255 |
*/
|
256 |
public function getEveningFee($formatted = false, $includingTax = true, $convert = true)
|
257 |
{
|
258 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
259 |
-
|
|
|
|
|
|
|
260 |
}
|
261 |
|
262 |
/**
|
@@ -273,8 +304,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
273 |
*/
|
274 |
public function getExpressFee($formatted = false, $includingTax = true, $convert = true)
|
275 |
{
|
276 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
277 |
-
|
|
|
|
|
|
|
278 |
}
|
279 |
|
280 |
/**
|
@@ -292,8 +326,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
292 |
*/
|
293 |
public function getPakjeGemakFee($currentRate, $formatted = false, $includingTax = true, $convert = true)
|
294 |
{
|
295 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
296 |
-
|
|
|
|
|
|
|
297 |
}
|
298 |
|
299 |
/**
|
@@ -311,8 +348,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
311 |
*/
|
312 |
public function getOptionsFee(TIG_PostNL_Model_Core_Order $postnlOrder, $formatted = false, $includingTax = true, $convert = true)
|
313 |
{
|
314 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
315 |
-
|
|
|
|
|
|
|
316 |
}
|
317 |
|
318 |
/**
|
@@ -330,8 +370,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
330 |
*/
|
331 |
public function getOptionFee($option, $formatted = false, $includingTax = true, $convert = true)
|
332 |
{
|
333 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
334 |
-
|
|
|
|
|
|
|
335 |
}
|
336 |
|
337 |
/**
|
@@ -511,12 +554,14 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
511 |
}
|
512 |
|
513 |
$shippingAddress = null;
|
|
|
|
|
514 |
if ($postnlOrder->getOrder()) {
|
515 |
$shippingAddress = $postnlOrder->getOrder()->getShippingAddress();
|
516 |
} elseif ($postnlOrder->getQuote()) {
|
517 |
$shippingAddress = $postnlOrder->getQuote()->getShippingAddress();
|
518 |
-
} elseif (
|
519 |
-
$shippingAddress =
|
520 |
}
|
521 |
|
522 |
/**
|
@@ -550,8 +595,9 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
550 |
if ($productCode) {
|
551 |
$deliveryOptionsInfo['product_code'] = $productCode;
|
552 |
|
553 |
-
$
|
554 |
-
|
|
|
555 |
|
556 |
if (array_key_exists($productCode, $allProductOptions)) {
|
557 |
$deliveryOptionsInfo['product_option'] = $allProductOptions[$productCode];
|
@@ -578,7 +624,13 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
578 |
break;
|
579 |
case 'pg':
|
580 |
case 'PG':
|
581 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
582 |
break;
|
583 |
case 'pg_cod':
|
584 |
$deliveryOptionsInfo['formatted_type'] = 'PakjeGemak rembours';
|
@@ -621,31 +673,133 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
621 |
*
|
622 |
* $helper TIG_PostNL_Helper_Date
|
623 |
*
|
624 |
-
* @param $storeId
|
625 |
* @param StdClass[] $timeframes
|
|
|
|
|
626 |
*
|
627 |
-
* @return StdClass[]
|
|
|
628 |
*/
|
629 |
-
public function filterTimeFrames($timeframes, $storeId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
630 |
/** @var TIG_PostNL_Helper_Date $helper */
|
631 |
$helper = Mage::helper('postnl/date');
|
632 |
|
633 |
$deliveryDateArray = $helper->getValidDeliveryDaysArray($storeId);
|
|
|
634 |
|
635 |
-
foreach($timeframes as $key => $timeFrame) {
|
|
|
636 |
$timeFrameDate = new DateTime($timeFrame->Date, new DateTimeZone('UTC'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
$timeFrameDay = $timeFrameDate->format('N');
|
638 |
$correctedTimeFrameDay = $timeFrameDay % 7;
|
639 |
|
640 |
-
if (
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
649 |
}
|
650 |
}
|
651 |
}
|
@@ -695,9 +849,13 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
695 |
* If no quote was specified, try to load the quote.
|
696 |
*/
|
697 |
if (!$quote && $this->isAdmin()) {
|
698 |
-
$
|
|
|
|
|
699 |
} elseif(!$quote) {
|
700 |
-
|
|
|
|
|
701 |
}
|
702 |
|
703 |
if (!$quote) {
|
@@ -708,6 +866,7 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
708 |
* Send a SOAP request to PostNL to get the earliest possible delivery date.
|
709 |
*/
|
710 |
try {
|
|
|
711 |
$cif = Mage::getModel('postnl_deliveryoptions/cif');
|
712 |
$response = $cif->setStoreId(Mage::app()->getStore()->getId())
|
713 |
->getDeliveryDate($postcode, $quote);
|
@@ -739,7 +898,7 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
739 |
*/
|
740 |
public function getShippingDuration(Mage_Sales_Model_Quote $quote = null)
|
741 |
{
|
742 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
743 |
return $this->getQuoteShippingDuration($quote);
|
744 |
}
|
745 |
|
@@ -758,9 +917,13 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
758 |
* If no quote was specified, try to load the quote.
|
759 |
*/
|
760 |
if (!$quote && $this->isAdmin()) {
|
761 |
-
$
|
|
|
|
|
762 |
} elseif(!$quote) {
|
763 |
-
|
|
|
|
|
764 |
}
|
765 |
|
766 |
if (!$quote) {
|
@@ -862,6 +1025,12 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
862 |
|
863 |
$durationArray = $this->_getProductsShippingDuration($productIds, $defaultDuration, $storeId);
|
864 |
|
|
|
|
|
|
|
|
|
|
|
|
|
865 |
if (empty($durationArray)) {
|
866 |
$durationArray = array($defaultDuration);
|
867 |
}
|
@@ -889,10 +1058,10 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
889 |
/**
|
890 |
* Make sure the value is between 1 and 14 days.
|
891 |
*/
|
892 |
-
if ($shippingDuration > 14 || $shippingDuration < 1) {
|
893 |
throw new TIG_PostNL_Exception(
|
894 |
Mage::helper('postnl')->__(
|
895 |
-
'Invalid shipping duration: %s. Shipping duration must be between
|
896 |
$shippingDuration
|
897 |
),
|
898 |
'POSTNL-0127'
|
@@ -912,7 +1081,7 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
912 |
* @return array
|
913 |
* @throws Mage_Core_Exception
|
914 |
*/
|
915 |
-
protected function _getProductsShippingDuration(array $productIds, $configDuration =
|
916 |
{
|
917 |
/**
|
918 |
* Get all products.
|
@@ -926,10 +1095,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
926 |
* Get the shipping duration of all products.
|
927 |
*/
|
928 |
$durationArray = array();
|
|
|
929 |
foreach ($products as $product) {
|
930 |
if ($product->hasData('postnl_shipping_duration')
|
931 |
&& $product->getData('postnl_shipping_duration') !== ''
|
932 |
-
&&
|
933 |
) {
|
934 |
$durationArray[] = (int) $product->getData('postnl_shipping_duration');
|
935 |
} else {
|
@@ -955,8 +1125,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
955 |
*/
|
956 |
public function getPriceWithTax($price, $includingTax, $formatted = false, $convert = true)
|
957 |
{
|
958 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
959 |
-
|
|
|
|
|
|
|
960 |
}
|
961 |
|
962 |
/**
|
@@ -1173,6 +1346,24 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1173 |
return false;
|
1174 |
}
|
1175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1176 |
/**
|
1177 |
* Check if any products in the quote have explicitly disabled PakjeGemak locations.
|
1178 |
*
|
@@ -1223,10 +1414,9 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1223 |
}
|
1224 |
|
1225 |
/**
|
1226 |
-
* PakjeGemak is only available when sending
|
1227 |
*/
|
1228 |
-
|
1229 |
-
if ($senderCountry != 'NL') {
|
1230 |
return false;
|
1231 |
}
|
1232 |
|
@@ -1241,9 +1431,11 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1241 |
/**
|
1242 |
* Checks if PakjeGemak Express is available.
|
1243 |
*
|
1244 |
-
* @
|
|
|
|
|
1245 |
*/
|
1246 |
-
public function canUsePakjeGemakExpress()
|
1247 |
{
|
1248 |
/**
|
1249 |
* Form a unique registry key for the current quote (if available) so we can cache the result of this method in
|
@@ -1285,6 +1477,13 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1285 |
|
1286 |
$allowed = $this->_canUsePakjeGemakExpress();
|
1287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1288 |
if ($cache) {
|
1289 |
/**
|
1290 |
* Save the result in the PostNL cache.
|
@@ -1314,8 +1513,9 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1314 |
/**
|
1315 |
* Check if any PGE product options are available.
|
1316 |
*/
|
1317 |
-
$
|
1318 |
-
|
|
|
1319 |
|
1320 |
$allowed = false;
|
1321 |
if (!empty($pgeOptions)) {
|
@@ -1325,6 +1525,52 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1325 |
return $allowed;
|
1326 |
}
|
1327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1328 |
/**
|
1329 |
* Checks if 'pakketautomaat' is available.
|
1330 |
*
|
@@ -1426,6 +1672,32 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1426 |
return false;
|
1427 |
}
|
1428 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1429 |
/**
|
1430 |
* Check if any product in the quote has explicitly disabled pakketautomaat.
|
1431 |
*
|
@@ -1478,16 +1750,16 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1478 |
/**
|
1479 |
* Pakketautomaat is only available when sending from the Netherlands.
|
1480 |
*/
|
1481 |
-
|
1482 |
-
if ($senderCountry != 'NL') {
|
1483 |
return false;
|
1484 |
}
|
1485 |
|
1486 |
/**
|
1487 |
* Check if any pakketautomaat product options are available.
|
1488 |
*/
|
1489 |
-
$
|
1490 |
-
|
|
|
1491 |
|
1492 |
$allowed = false;
|
1493 |
if (!empty($pakketautomaatOptions)) {
|
@@ -1548,12 +1820,19 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1548 |
return $allowed;
|
1549 |
}
|
1550 |
|
1551 |
-
if (
|
1552 |
$allowed = false;
|
1553 |
} else {
|
1554 |
$storeId = Mage::app()->getStore()->getId();
|
1555 |
|
1556 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1557 |
}
|
1558 |
|
1559 |
if ($cache) {
|
@@ -1604,6 +1883,23 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1604 |
return false;
|
1605 |
}
|
1606 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1607 |
/**
|
1608 |
* @var Mage_Sales_Model_Quote_item $item
|
1609 |
*/
|
@@ -1853,8 +2149,9 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1853 |
return false;
|
1854 |
}
|
1855 |
|
1856 |
-
$
|
1857 |
-
|
|
|
1858 |
|
1859 |
$allowed = false;
|
1860 |
if (!empty($eveningOptions)) {
|
@@ -1864,6 +2161,31 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1864 |
return $allowed;
|
1865 |
}
|
1866 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1867 |
/**
|
1868 |
* Checks if sunday sorting is allowed.
|
1869 |
*
|
@@ -1877,19 +2199,167 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1877 |
return $cache->getPostnlDeliveryOptionsCanUseSundaySorting();
|
1878 |
}
|
1879 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1880 |
$storeId = Mage::app()->getStore()->getId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1881 |
|
1882 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1883 |
$allowed = false;
|
1884 |
} else {
|
1885 |
-
$allowed = Mage::getStoreConfigFlag(self::
|
1886 |
}
|
1887 |
|
1888 |
if ($cache) {
|
1889 |
/**
|
1890 |
* Save the result in the PostNL cache.
|
1891 |
*/
|
1892 |
-
$cache->
|
1893 |
->saveCache();
|
1894 |
}
|
1895 |
|
@@ -1909,7 +2379,7 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1909 |
* Form a unique registry key for the current quote (if available) so we can cache the result of this method in
|
1910 |
* the registry.
|
1911 |
*/
|
1912 |
-
$registryKey = '
|
1913 |
if ($quote && $quote->getId()) {
|
1914 |
$registryKey .= '_quote_id_' . $quote->getId();
|
1915 |
}
|
@@ -1927,7 +2397,7 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
1927 |
/**
|
1928 |
* Delivery options are only available when shipping from the Netherlands.
|
1929 |
*/
|
1930 |
-
if (
|
1931 |
Mage::register($registryKey, false);
|
1932 |
return false;
|
1933 |
}
|
@@ -2029,9 +2499,9 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
2029 |
array(
|
2030 |
'code' => 'POSTNL-0121',
|
2031 |
'message' => $this->__(
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
)
|
2036 |
);
|
2037 |
Mage::register('postnl_delivery_options_can_use_delivery_options_errors', $errors);
|
@@ -2052,8 +2522,9 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
2052 |
}
|
2053 |
|
2054 |
/**
|
2055 |
-
* If the product is a bundled product, check if the
|
2056 |
-
* simple products. Else just check the given product, since this will point correctly to the simple
|
|
|
2057 |
*/
|
2058 |
if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
2059 |
$allowDeliveryOptions = $this->bundleCheckAllowedForSimpleProducts(
|
@@ -2099,6 +2570,14 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
2099 |
}
|
2100 |
}
|
2101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2102 |
return true;
|
2103 |
}
|
2104 |
|
@@ -2180,16 +2659,19 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
2180 |
$stockItem = $product->getStockItem();
|
2181 |
|
2182 |
if (!$stockItem) {
|
2183 |
-
$stockItem
|
|
|
|
|
2184 |
}
|
2185 |
|
|
|
2186 |
$available = false;
|
2187 |
switch ($stockOption) {
|
2188 |
case 'in_stock':
|
2189 |
-
$available = $this->_isStockItemInStock($stockItem, false, $
|
2190 |
break;
|
2191 |
case 'backordered':
|
2192 |
-
$available = $this->_isStockItemInStock($stockItem, true, $
|
2193 |
break;
|
2194 |
}
|
2195 |
|
@@ -2289,14 +2771,16 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
2289 |
}
|
2290 |
|
2291 |
/**
|
2292 |
-
* Delivery options are only available when shipping to the Netherlands.
|
2293 |
-
*
|
2294 |
-
* Delivery options in Belgium are currently unstable and therefor not yet fully supported. Expect this to be
|
2295 |
-
* added in a later release.
|
2296 |
-
*
|
2297 |
-
* @todo add Belgium as a valid country for PostNL delivery options.
|
2298 |
*/
|
2299 |
-
if ($shippingAddress->getCountry() != 'NL'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2300 |
Mage::register($registryKey, false);
|
2301 |
return false;
|
2302 |
}
|
@@ -2641,6 +3125,14 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
2641 |
return false;
|
2642 |
}
|
2643 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2644 |
Mage::register($registryKey, true);
|
2645 |
return true;
|
2646 |
}
|
@@ -2664,8 +3156,15 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
2664 |
/**
|
2665 |
* Check if any valid product options are available.
|
2666 |
*/
|
2667 |
-
$
|
2668 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2669 |
|
2670 |
if (empty($statedAddressOnlyOptions)) {
|
2671 |
return false;
|
@@ -2871,7 +3370,9 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
2871 |
*
|
2872 |
* N.B. The PostNL shipping methods are not dependant on the selected store view.
|
2873 |
*/
|
2874 |
-
|
|
|
|
|
2875 |
|
2876 |
$conflictingShippingMethods = array_intersect($goMageDeliveryDateShippingMethods, $postnlShippingMethods);
|
2877 |
if (empty($conflictingShippingMethods)) {
|
@@ -2909,6 +3410,45 @@ class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
|
2909 |
}
|
2910 |
|
2911 |
return $allow;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2912 |
|
|
|
|
|
2913 |
}
|
2914 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @todo Cache the available delivery options in the checkout session. That way we only recalculate them if the quote
|
42 |
class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
43 |
{
|
44 |
/**
|
45 |
+
* Xpath to delivery options enabled config settings.
|
46 |
*/
|
47 |
+
const XPATH_DELIVERY_OPTIONS_ACTIVE = 'postnl/delivery_options/delivery_options_active';
|
48 |
+
const XPATH_DELIVERY_OPTIONS_BE_ACTIVE = 'postnl/delivery_options/delivery_options_be_active';
|
49 |
+
const XPATH_USE_DUTCH_PRODUCTS = 'postnl/cif_labels_and_confirming/use_dutch_products';
|
50 |
|
51 |
/**
|
52 |
* Xpaths to various possible delivery option settings.
|
53 |
*/
|
54 |
const XPATH_ENABLE_PAKJEGEMAK = 'postnl/delivery_options/enable_pakjegemak';
|
55 |
+
const XPATH_ENABLE_PAKJEGEMAK_BE = 'postnl/delivery_options/enable_pakjegemak_be';
|
56 |
const XPATH_ENABLE_PAKJEGEMAK_EXPRESS = 'postnl/delivery_options/enable_pakjegemak_express';
|
57 |
const XPATH_ENABLE_PAKKETAUTOMAAT_LOCATIONS = 'postnl/delivery_options/enable_pakketautomaat_locations';
|
58 |
const XPATH_ENABLE_DELIVERY_DAYS = 'postnl/delivery_options/enable_delivery_days';
|
59 |
+
const XPATH_ENABLE_DELIVERY_DAYS_BE = 'postnl/delivery_options/enable_delivery_days_be';
|
60 |
const XPATH_ENABLE_TIMEFRAMES = 'postnl/delivery_options/enable_timeframes';
|
61 |
const XPATH_ENABLE_EVENING_TIMEFRAMES = 'postnl/delivery_options/enable_evening_timeframes';
|
62 |
|
65 |
*/
|
66 |
const XPATH_STOCK_OPTIONS = 'postnl/delivery_options/stock_options';
|
67 |
const XPATH_ALLOW_SUNDAY_SORTING = 'postnl/delivery_options/allow_sunday_sorting';
|
68 |
+
const XPATH_ALLOW_SUNDAY_SORTING_BE = 'postnl/delivery_options/allow_sunday_sorting_be';
|
69 |
const XPATH_SHOW_OPTIONS_FOR_BUSPAKJE = 'postnl/delivery_options/show_options_for_buspakje';
|
70 |
const XPATH_SHOW_ALL_OPTIONS_FOR_BUSPAKJE = 'postnl/delivery_options/show_all_options_for_buspakje';
|
71 |
const XPATH_ENABLE_DELIVERY_DAYS_FOR_BUSPAKJE = 'postnl/delivery_options/enable_delivery_days_for_buspakje';
|
73 |
const XPATH_ENABLE_PAKKETAUTOMAAT_FOR_BUSPAKJE = 'postnl/delivery_options/enable_pakketautomaat_for_buspakje';
|
74 |
const XPATH_STATED_ADDRESS_ONLY_OPTION = 'postnl/delivery_options/stated_address_only_option';
|
75 |
const XPATH_ENABLE_SUNDAY_DELIVERY = 'postnl/delivery_options/enable_sunday_delivery';
|
76 |
+
const XPATH_ENABLE_SAMEDAY_DELIVERY = 'postnl/delivery_options/enable_sameday_delivery';
|
77 |
+
const XPATH_ENABLE_FOOD_DELIVERY = 'postnl/delivery_options/enable_food_delivery';
|
78 |
+
const XPATH_AVAILABLE_PRODUCT_OPTIONS = 'postnl/grid/supported_product_options';
|
79 |
|
80 |
/**
|
81 |
* Xpaths to extra fee config settings.
|
98 |
/**
|
99 |
* Xpath for shipping duration setting.
|
100 |
*/
|
101 |
+
const XPATH_SHIPPING_DURATION = 'postnl/cif_labels_and_confirming/shipping_duration';
|
102 |
+
const XPATH_CUTOFF_TIME = 'postnl/cif_labels_and_confirming/cutoff_time';
|
103 |
+
const XPATH_SUNDAY_CUTOFF_TIME = 'postnl/cif_labels_and_confirming/sunday_cutoff_time';
|
104 |
+
const XPATH_SAMEDAY_CUTOFF_TIME = 'postnl/delivery_options/sameday_delivery_cutoff_time';
|
105 |
+
const XPATH_SHIPPING_DAYS = 'postnl/cif_labels_and_confirming/shipping_days';
|
106 |
|
107 |
/**
|
108 |
* Xpath to the 'stated_address_only_checked' setting.
|
130 |
*/
|
131 |
const MAX_FEE = 2;
|
132 |
|
133 |
+
/**
|
134 |
+
* The two supported food delivery types.
|
135 |
+
*/
|
136 |
+
const FOOD_TYPE_DRY_GROCERIES = 1;
|
137 |
+
const FOOD_TYPE_COOL_PRODUCTS = 2;
|
138 |
+
|
139 |
/**
|
140 |
* @var array
|
141 |
*/
|
147 |
'PA',
|
148 |
'Sunday',
|
149 |
'Monday',
|
150 |
+
'Sameday',
|
151 |
+
'Food',
|
152 |
+
'Cooledfood',
|
153 |
+
);
|
154 |
+
|
155 |
+
protected $_foodProductCodes = array(
|
156 |
+
'3083',
|
157 |
+
'3084',
|
158 |
);
|
159 |
|
160 |
/**
|
172 |
*/
|
173 |
protected $_configMinQty = null;
|
174 |
|
175 |
+
/**
|
176 |
+
* @var null
|
177 |
+
*/
|
178 |
+
protected $_canUseDutchProducts = null;
|
179 |
+
|
180 |
/**
|
181 |
* @return int
|
182 |
*/
|
283 |
*/
|
284 |
public function getEveningFee($formatted = false, $includingTax = true, $convert = true)
|
285 |
{
|
286 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
287 |
+
|
288 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_fee $helper */
|
289 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
290 |
+
return $helper->getEveningFee($formatted, $includingTax, $convert);
|
291 |
}
|
292 |
|
293 |
/**
|
304 |
*/
|
305 |
public function getExpressFee($formatted = false, $includingTax = true, $convert = true)
|
306 |
{
|
307 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
308 |
+
|
309 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_fee $helper */
|
310 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
311 |
+
return $helper->getExpressFee($formatted, $includingTax, $convert);
|
312 |
}
|
313 |
|
314 |
/**
|
326 |
*/
|
327 |
public function getPakjeGemakFee($currentRate, $formatted = false, $includingTax = true, $convert = true)
|
328 |
{
|
329 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
330 |
+
|
331 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_fee $helper */
|
332 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
333 |
+
return $helper->getPakjeGemakFee($currentRate, $formatted, $includingTax, $convert);
|
334 |
}
|
335 |
|
336 |
/**
|
348 |
*/
|
349 |
public function getOptionsFee(TIG_PostNL_Model_Core_Order $postnlOrder, $formatted = false, $includingTax = true, $convert = true)
|
350 |
{
|
351 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
352 |
+
|
353 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_fee $helper */
|
354 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
355 |
+
return $helper->getOptionsFee($postnlOrder, $formatted, $includingTax, $convert);
|
356 |
}
|
357 |
|
358 |
/**
|
370 |
*/
|
371 |
public function getOptionFee($option, $formatted = false, $includingTax = true, $convert = true)
|
372 |
{
|
373 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
374 |
+
|
375 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_fee $helper */
|
376 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
377 |
+
return $helper->getOptionFee($option, $formatted, $includingTax, $convert);
|
378 |
}
|
379 |
|
380 |
/**
|
554 |
}
|
555 |
|
556 |
$shippingAddress = null;
|
557 |
+
/** @var Mage_Checkout_Model_Session $session */
|
558 |
+
$session = Mage::getSingleton('checkout/session');
|
559 |
if ($postnlOrder->getOrder()) {
|
560 |
$shippingAddress = $postnlOrder->getOrder()->getShippingAddress();
|
561 |
} elseif ($postnlOrder->getQuote()) {
|
562 |
$shippingAddress = $postnlOrder->getQuote()->getShippingAddress();
|
563 |
+
} elseif ($session->getQuote()) {
|
564 |
+
$shippingAddress = $session->getQuote()->getShippingAddress();
|
565 |
}
|
566 |
|
567 |
/**
|
595 |
if ($productCode) {
|
596 |
$deliveryOptionsInfo['product_code'] = $productCode;
|
597 |
|
598 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $productOptionsModel */
|
599 |
+
$productOptionsModel = Mage::getModel('postnl_core/system_config_source_allProductOptions');
|
600 |
+
$allProductOptions = $productOptionsModel->getOptions(array(), true);
|
601 |
|
602 |
if (array_key_exists($productCode, $allProductOptions)) {
|
603 |
$deliveryOptionsInfo['product_option'] = $allProductOptions[$productCode];
|
624 |
break;
|
625 |
case 'pg':
|
626 |
case 'PG':
|
627 |
+
$formattedType = 'PakjeGemak';
|
628 |
+
|
629 |
+
if ($shippingAddress->getCountryId() == 'BE') {
|
630 |
+
$formattedType .= ' (België)';
|
631 |
+
}
|
632 |
+
|
633 |
+
$deliveryOptionsInfo['formatted_type'] = $formattedType;
|
634 |
break;
|
635 |
case 'pg_cod':
|
636 |
$deliveryOptionsInfo['formatted_type'] = 'PakjeGemak rembours';
|
673 |
*
|
674 |
* $helper TIG_PostNL_Helper_Date
|
675 |
*
|
|
|
676 |
* @param StdClass[] $timeframes
|
677 |
+
* @param int $storeId
|
678 |
+
* @param string $destinationCountry
|
679 |
*
|
680 |
+
* @return false|StdClass[]
|
681 |
+
* @throws TIG_PostNL_Exception
|
682 |
*/
|
683 |
+
public function filterTimeFrames($timeframes, $storeId, $destinationCountry = 'NL')
|
684 |
+
{
|
685 |
+
/**
|
686 |
+
* Retrieves required config values.
|
687 |
+
*/
|
688 |
+
$sundayDelivery = Mage::getStoreConfig(self::XPATH_ENABLE_SUNDAY_DELIVERY, $storeId);
|
689 |
+
$sundaySorting = Mage::getStoreConfig(self::XPATH_ALLOW_SUNDAY_SORTING, $storeId);
|
690 |
+
|
691 |
/** @var TIG_PostNL_Helper_Date $helper */
|
692 |
$helper = Mage::helper('postnl/date');
|
693 |
|
694 |
$deliveryDateArray = $helper->getValidDeliveryDaysArray($storeId);
|
695 |
+
$today = new DateTime('now', new DateTimeZone('UTC'));
|
696 |
|
697 |
+
foreach ($timeframes as $key => $timeFrame) {
|
698 |
+
$forceSameDayTimeFrame = false;
|
699 |
$timeFrameDate = new DateTime($timeFrame->Date, new DateTimeZone('UTC'));
|
700 |
+
|
701 |
+
/**
|
702 |
+
* Check if the time frame's date is today. If so, it is probably a same day delivery time frame.
|
703 |
+
*/
|
704 |
+
if ($timeFrameDate->format('Y-m-d') == $today->format('Y-m-d') && $this->canUseSameDayDelivery(true)) {
|
705 |
+
/**
|
706 |
+
* Check for each sub-timeframe if it is indeed same day delivery.
|
707 |
+
*/
|
708 |
+
foreach ($timeFrame->Timeframes->TimeframeTimeFrame as $timeFrameTimeFrameKey => $timeFrameTimeFrame) {
|
709 |
+
$sameDay = false;
|
710 |
+
|
711 |
+
/**
|
712 |
+
* Same day delivery timeframes may have multiple 'options'. Only one of these needs to actually be
|
713 |
+
* 'Sameday'.
|
714 |
+
*/
|
715 |
+
foreach ($timeFrameTimeFrame->Options->string as $timeFrameTimeFrameOption) {
|
716 |
+
if ($timeFrameTimeFrameOption == 'Sameday') {
|
717 |
+
$forceSameDayTimeFrame = true;
|
718 |
+
$sameDay = true;
|
719 |
+
}
|
720 |
+
}
|
721 |
+
|
722 |
+
if (!$sameDay) {
|
723 |
+
unset($timeFrame->Timeframes->TimeframeTimeFrame[$timeFrameTimeFrameKey]);
|
724 |
+
}
|
725 |
+
}
|
726 |
+
/**
|
727 |
+
* Reset the indices of the TimeframeTimeFrame's array.
|
728 |
+
*/
|
729 |
+
$timeFrame->Timeframes->TimeframeTimeFrame = array_values($timeFrame->Timeframes->TimeframeTimeFrame);
|
730 |
+
} elseif ($timeFrameDate->format('Y-m-d') == $today->format('Y-m-d')) {
|
731 |
+
/**
|
732 |
+
* If same day delivery it not allowed, remove the time frame.
|
733 |
+
*/
|
734 |
+
unset($timeframes[$key]);
|
735 |
+
continue;
|
736 |
+
}
|
737 |
+
|
738 |
$timeFrameDay = $timeFrameDate->format('N');
|
739 |
$correctedTimeFrameDay = $timeFrameDay % 7;
|
740 |
|
741 |
+
if (!$forceSameDayTimeFrame) {
|
742 |
+
if ($deliveryDateArray[$correctedTimeFrameDay] == 0) {
|
743 |
+
if (!$helper->canUseFoodDelivery()) {
|
744 |
+
unset($timeframes[$key]);
|
745 |
+
}
|
746 |
+
} elseif ($timeFrameDay == TIG_PostNL_Helper_Date::MONDAY) {
|
747 |
+
/**
|
748 |
+
* If:
|
749 |
+
* - Sunday delivery is not active
|
750 |
+
* - Sunday sorting (monday delivery) IS active
|
751 |
+
* - Today is saturday
|
752 |
+
* - We are after the cut-off time
|
753 |
+
*
|
754 |
+
* Then monday is not a valid delivery day.
|
755 |
+
*/
|
756 |
+
if (
|
757 |
+
!$sundayDelivery &&
|
758 |
+
$sundaySorting &&
|
759 |
+
$today->format('N') == TIG_PostNL_Helper_Date::SATURDAY &&
|
760 |
+
$helper->isPastCutOff($today, $storeId)
|
761 |
+
) {
|
762 |
+
unset($timeframes[$key]);
|
763 |
+
} else {
|
764 |
+
foreach (
|
765 |
+
$timeFrame->Timeframes->TimeframeTimeFrame as $timeframeTimeframeKey => $timeframeTimeframe
|
766 |
+
) {
|
767 |
+
if ($timeframeTimeframe->Options->string[0] == 'Daytime' && $destinationCountry == 'NL') {
|
768 |
+
$timeframes[$key]
|
769 |
+
->Timeframes
|
770 |
+
->TimeframeTimeFrame[$timeframeTimeframeKey]
|
771 |
+
->Options
|
772 |
+
->string[0] = 'Monday';
|
773 |
+
}
|
774 |
+
}
|
775 |
+
}
|
776 |
+
} elseif ($timeFrameDay == TIG_PostNL_Helper_Date::TUESDAY) {
|
777 |
+
$date = $timeFrame->Date;
|
778 |
+
|
779 |
+
$shippingDate = $helper->getShippingDateFromDeliveryDate($date, $storeId);
|
780 |
+
$utcShippingDate = $helper->getUtcDateTime($shippingDate, $storeId, false);
|
781 |
+
$now = $helper->getUtcDateTime('now', 0)->setTime(0, 0, 0);
|
782 |
+
|
783 |
+
$timeFrameIsInPast = $now->diff($utcShippingDate, true)->invert;
|
784 |
+
|
785 |
+
if ($timeFrameIsInPast) {
|
786 |
+
unset($timeframes[$key]);
|
787 |
+
}
|
788 |
+
|
789 |
+
}
|
790 |
+
}
|
791 |
+
|
792 |
+
/**
|
793 |
+
* If the quote is a food quote, every delivery option should be of the type 'Food'.
|
794 |
+
*/
|
795 |
+
if ($this->canUseFoodDelivery(true)) {
|
796 |
+
$isFood = $this->quoteIsFood();
|
797 |
+
if ($isFood) {
|
798 |
+
$foodType = $this->getQuoteFoodType();
|
799 |
+
if ($foodType == self::FOOD_TYPE_DRY_GROCERIES) {
|
800 |
+
$timeFrame->Timeframes->TimeframeTimeFrame[0]->Options->string = array('Food');
|
801 |
+
} elseif ($foodType == self::FOOD_TYPE_COOL_PRODUCTS) {
|
802 |
+
$timeFrame->Timeframes->TimeframeTimeFrame[0]->Options->string = array('Cooledfood');
|
803 |
}
|
804 |
}
|
805 |
}
|
849 |
* If no quote was specified, try to load the quote.
|
850 |
*/
|
851 |
if (!$quote && $this->isAdmin()) {
|
852 |
+
/** @var Mage_Adminhtml_Model_Session_Quote $session */
|
853 |
+
$session = Mage::getSingleton('adminhtml/session_quote');
|
854 |
+
$quote = $session->getQuote();
|
855 |
} elseif(!$quote) {
|
856 |
+
/** @var Mage_Checkout_Model_Session $session */
|
857 |
+
$session = Mage::getSingleton('checkout/session');
|
858 |
+
$quote = $session->getQuote();
|
859 |
}
|
860 |
|
861 |
if (!$quote) {
|
866 |
* Send a SOAP request to PostNL to get the earliest possible delivery date.
|
867 |
*/
|
868 |
try {
|
869 |
+
/** @var TIG_PostNL_Model_DeliveryOptions_Cif $cif */
|
870 |
$cif = Mage::getModel('postnl_deliveryoptions/cif');
|
871 |
$response = $cif->setStoreId(Mage::app()->getStore()->getId())
|
872 |
->getDeliveryDate($postcode, $quote);
|
898 |
*/
|
899 |
public function getShippingDuration(Mage_Sales_Model_Quote $quote = null)
|
900 |
{
|
901 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
902 |
return $this->getQuoteShippingDuration($quote);
|
903 |
}
|
904 |
|
917 |
* If no quote was specified, try to load the quote.
|
918 |
*/
|
919 |
if (!$quote && $this->isAdmin()) {
|
920 |
+
/** @var Mage_Adminhtml_Model_Session_Quote $session */
|
921 |
+
$session = Mage::getSingleton('adminhtml/session_quote');
|
922 |
+
$quote = $session->getQuote();
|
923 |
} elseif(!$quote) {
|
924 |
+
/** @var Mage_Checkout_Model_Session $session */
|
925 |
+
$session = Mage::getSingleton('checkout/session');
|
926 |
+
$quote = $session->getQuote();
|
927 |
}
|
928 |
|
929 |
if (!$quote) {
|
1025 |
|
1026 |
$durationArray = $this->_getProductsShippingDuration($productIds, $defaultDuration, $storeId);
|
1027 |
|
1028 |
+
foreach ($durationArray as $key => $duration) {
|
1029 |
+
if ($duration == '-1') {
|
1030 |
+
unset($durationArray[$key]);
|
1031 |
+
}
|
1032 |
+
}
|
1033 |
+
|
1034 |
if (empty($durationArray)) {
|
1035 |
$durationArray = array($defaultDuration);
|
1036 |
}
|
1058 |
/**
|
1059 |
* Make sure the value is between 1 and 14 days.
|
1060 |
*/
|
1061 |
+
if ($shippingDuration > 14 || $shippingDuration < -1) {
|
1062 |
throw new TIG_PostNL_Exception(
|
1063 |
Mage::helper('postnl')->__(
|
1064 |
+
'Invalid shipping duration: %s. Shipping duration must be between 0 and 14 days.',
|
1065 |
$shippingDuration
|
1066 |
),
|
1067 |
'POSTNL-0127'
|
1081 |
* @return array
|
1082 |
* @throws Mage_Core_Exception
|
1083 |
*/
|
1084 |
+
protected function _getProductsShippingDuration(array $productIds, $configDuration = 0, $storeId = null)
|
1085 |
{
|
1086 |
/**
|
1087 |
* Get all products.
|
1095 |
* Get the shipping duration of all products.
|
1096 |
*/
|
1097 |
$durationArray = array();
|
1098 |
+
/** @var Mage_Catalog_Model_Product $product */
|
1099 |
foreach ($products as $product) {
|
1100 |
if ($product->hasData('postnl_shipping_duration')
|
1101 |
&& $product->getData('postnl_shipping_duration') !== ''
|
1102 |
+
&& $product->getData('postnl_shipping_duration') !== -1
|
1103 |
) {
|
1104 |
$durationArray[] = (int) $product->getData('postnl_shipping_duration');
|
1105 |
} else {
|
1125 |
*/
|
1126 |
public function getPriceWithTax($price, $includingTax, $formatted = false, $convert = true)
|
1127 |
{
|
1128 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
1129 |
+
|
1130 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_fee $helper */
|
1131 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
1132 |
+
return $helper->getPriceWithTax($price, $includingTax, $formatted, $convert);
|
1133 |
}
|
1134 |
|
1135 |
/**
|
1346 |
return false;
|
1347 |
}
|
1348 |
|
1349 |
+
$shippingAddress = $quote->getShippingAddress();
|
1350 |
+
if ($shippingAddress
|
1351 |
+
&& $shippingAddress->getCountryId() == 'BE'
|
1352 |
+
&& Mage::getStoreConfigFlag(self::XPATH_ENABLE_PAKJEGEMAK_BE, $quote->getStoreId()) === false
|
1353 |
+
) {
|
1354 |
+
Mage::register($registryKey, false);
|
1355 |
+
return false;
|
1356 |
+
}
|
1357 |
+
|
1358 |
+
/**
|
1359 |
+
* If the current quote should be sent as a Food Delivery, PakjeGemak should not be shown.
|
1360 |
+
*/
|
1361 |
+
$isFood = $this->quoteIsFood();
|
1362 |
+
if ($isFood) {
|
1363 |
+
Mage::register($registryKey, false);
|
1364 |
+
return false;
|
1365 |
+
}
|
1366 |
+
|
1367 |
/**
|
1368 |
* Check if any products in the quote have explicitly disabled PakjeGemak locations.
|
1369 |
*
|
1414 |
}
|
1415 |
|
1416 |
/**
|
1417 |
+
* PakjeGemak is only available when sending using Dutch products.
|
1418 |
*/
|
1419 |
+
if (!$this->canUseDutchProducts()) {
|
|
|
1420 |
return false;
|
1421 |
}
|
1422 |
|
1431 |
/**
|
1432 |
* Checks if PakjeGemak Express is available.
|
1433 |
*
|
1434 |
+
* @param bool $checkQuote
|
1435 |
+
*
|
1436 |
+
* @return bool
|
1437 |
*/
|
1438 |
+
public function canUsePakjeGemakExpress($checkQuote = true)
|
1439 |
{
|
1440 |
/**
|
1441 |
* Form a unique registry key for the current quote (if available) so we can cache the result of this method in
|
1477 |
|
1478 |
$allowed = $this->_canUsePakjeGemakExpress();
|
1479 |
|
1480 |
+
if ($allowed && $checkQuote) {
|
1481 |
+
/**
|
1482 |
+
* Check if these options are allowed for this specific quote.
|
1483 |
+
*/
|
1484 |
+
$allowed = $this->canUsePakjeGemakExpressForQuote();
|
1485 |
+
}
|
1486 |
+
|
1487 |
if ($cache) {
|
1488 |
/**
|
1489 |
* Save the result in the PostNL cache.
|
1513 |
/**
|
1514 |
* Check if any PGE product options are available.
|
1515 |
*/
|
1516 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions $pgeOptionsModel */
|
1517 |
+
$pgeOptionsModel = Mage::getModel('postnl_core/system_config_source_pakjeGemakProductOptions');
|
1518 |
+
$pgeOptions = $pgeOptionsModel->getAvailablePgeOptions($storeId);
|
1519 |
|
1520 |
$allowed = false;
|
1521 |
if (!empty($pgeOptions)) {
|
1525 |
return $allowed;
|
1526 |
}
|
1527 |
|
1528 |
+
/**
|
1529 |
+
* Check if 'pakje gemak express' is allowed for the current quote.
|
1530 |
+
*
|
1531 |
+
* @return bool
|
1532 |
+
*/
|
1533 |
+
public function canUsePakjeGemakExpressForQuote()
|
1534 |
+
{
|
1535 |
+
/**
|
1536 |
+
* Form a unique registry key for the current quote (if available) so we can cache the result of this method in
|
1537 |
+
* the registry.
|
1538 |
+
*/
|
1539 |
+
$quote = $this->getQuote();
|
1540 |
+
if (!$quote) {
|
1541 |
+
return true;
|
1542 |
+
}
|
1543 |
+
|
1544 |
+
$registryKey = 'can_use_pakje_gemak_express_for_quote_' . $quote->getId();
|
1545 |
+
|
1546 |
+
/**
|
1547 |
+
* Check if the result of this method has been cached in the registry.
|
1548 |
+
*/
|
1549 |
+
if (Mage::registry($registryKey) !== null) {
|
1550 |
+
return Mage::registry($registryKey);
|
1551 |
+
}
|
1552 |
+
|
1553 |
+
/**
|
1554 |
+
* If no shipping address is available, we have nothing to check and delivery options will not be allowed.
|
1555 |
+
*/
|
1556 |
+
$shippingAddress = $quote->getShippingAddress();
|
1557 |
+
if (!$shippingAddress) {
|
1558 |
+
Mage::register($registryKey, false);
|
1559 |
+
return false;
|
1560 |
+
}
|
1561 |
+
|
1562 |
+
/**
|
1563 |
+
* PakjeGemak Express is only available when shipping to the Netherlands.
|
1564 |
+
*/
|
1565 |
+
if ($shippingAddress->getCountry() != 'NL') {
|
1566 |
+
Mage::register($registryKey, false);
|
1567 |
+
return false;
|
1568 |
+
}
|
1569 |
+
|
1570 |
+
Mage::register($registryKey, true);
|
1571 |
+
return true;
|
1572 |
+
}
|
1573 |
+
|
1574 |
/**
|
1575 |
* Checks if 'pakketautomaat' is available.
|
1576 |
*
|
1672 |
return false;
|
1673 |
}
|
1674 |
|
1675 |
+
/**
|
1676 |
+
* If no shipping address is available, we have nothing to check and delivery options will not be allowed.
|
1677 |
+
*/
|
1678 |
+
$shippingAddress = $quote->getShippingAddress();
|
1679 |
+
if (!$shippingAddress) {
|
1680 |
+
Mage::register($registryKey, false);
|
1681 |
+
return false;
|
1682 |
+
}
|
1683 |
+
|
1684 |
+
/**
|
1685 |
+
* Pakketautomaat is only available when shipping to the Netherlands.
|
1686 |
+
*/
|
1687 |
+
if ($shippingAddress->getCountryId() != 'NL') {
|
1688 |
+
Mage::register($registryKey, false);
|
1689 |
+
return false;
|
1690 |
+
}
|
1691 |
+
|
1692 |
+
/**
|
1693 |
+
* If the current quote should be sent as a Food Delivery, PakjeGemak should not be shown.
|
1694 |
+
*/
|
1695 |
+
$isFood = $this->quoteIsFood();
|
1696 |
+
if ($isFood) {
|
1697 |
+
Mage::register($registryKey, false);
|
1698 |
+
return false;
|
1699 |
+
}
|
1700 |
+
|
1701 |
/**
|
1702 |
* Check if any product in the quote has explicitly disabled pakketautomaat.
|
1703 |
*
|
1750 |
/**
|
1751 |
* Pakketautomaat is only available when sending from the Netherlands.
|
1752 |
*/
|
1753 |
+
if (!$this->canUseDutchProducts()) {
|
|
|
1754 |
return false;
|
1755 |
}
|
1756 |
|
1757 |
/**
|
1758 |
* Check if any pakketautomaat product options are available.
|
1759 |
*/
|
1760 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_PakketautomaatProductOptions $pakketautomaatOptionsModel */
|
1761 |
+
$pakketautomaatOptionsModel = Mage::getModel('postnl_core/system_config_source_pakketautomaatProductOptions');
|
1762 |
+
$pakketautomaatOptions = $pakketautomaatOptionsModel->getAvailableOptions();
|
1763 |
|
1764 |
$allowed = false;
|
1765 |
if (!empty($pakketautomaatOptions)) {
|
1820 |
return $allowed;
|
1821 |
}
|
1822 |
|
1823 |
+
if (!$this->canUseDutchProducts()) {
|
1824 |
$allowed = false;
|
1825 |
} else {
|
1826 |
$storeId = Mage::app()->getStore()->getId();
|
1827 |
|
1828 |
+
$quote = $this->getQuote();
|
1829 |
+
|
1830 |
+
$allowedXpath = self::XPATH_ENABLE_DELIVERY_DAYS;
|
1831 |
+
if ($quote && $quote->getShippingAddress() && $quote->getShippingAddress()->getCountryId() == 'BE') {
|
1832 |
+
$allowedXpath = self::XPATH_ENABLE_DELIVERY_DAYS_BE;
|
1833 |
+
}
|
1834 |
+
|
1835 |
+
$allowed = Mage::getStoreConfigFlag($allowedXpath, $storeId);
|
1836 |
}
|
1837 |
|
1838 |
if ($cache) {
|
1883 |
return false;
|
1884 |
}
|
1885 |
|
1886 |
+
/**
|
1887 |
+
* If no shipping address is available, we have nothing to check and delivery options will not be allowed.
|
1888 |
+
*/
|
1889 |
+
$shippingAddress = $quote->getShippingAddress();
|
1890 |
+
if (!$shippingAddress) {
|
1891 |
+
Mage::register($registryKey, false);
|
1892 |
+
return false;
|
1893 |
+
}
|
1894 |
+
|
1895 |
+
/**
|
1896 |
+
* Delivery days are only available when shipping to the Netherlands or Belgium.
|
1897 |
+
*/
|
1898 |
+
if ($shippingAddress->getCountry() != 'NL' && $shippingAddress->getCountry() != 'BE') {
|
1899 |
+
Mage::register($registryKey, false);
|
1900 |
+
return false;
|
1901 |
+
}
|
1902 |
+
|
1903 |
/**
|
1904 |
* @var Mage_Sales_Model_Quote_item $item
|
1905 |
*/
|
2149 |
return false;
|
2150 |
}
|
2151 |
|
2152 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions $eveningOptionsModel */
|
2153 |
+
$eveningOptionsModel = Mage::getModel('postnl_core/system_config_source_standardProductOptions');
|
2154 |
+
$eveningOptions = $eveningOptionsModel->getAvailableAvondOptions($storeId);
|
2155 |
|
2156 |
$allowed = false;
|
2157 |
if (!empty($eveningOptions)) {
|
2161 |
return $allowed;
|
2162 |
}
|
2163 |
|
2164 |
+
/**
|
2165 |
+
* Determines if the DeliveryOptions can show the default FallBack Timeframe. This function is not cached,
|
2166 |
+
* since this is dependant on the quote.
|
2167 |
+
*
|
2168 |
+
* @return bool
|
2169 |
+
*/
|
2170 |
+
public function canUseFallBackTimeframe()
|
2171 |
+
{
|
2172 |
+
$allowed = $this->_canUseFallBackTimeframe();
|
2173 |
+
|
2174 |
+
return $allowed;
|
2175 |
+
}
|
2176 |
+
|
2177 |
+
/**
|
2178 |
+
* @return bool
|
2179 |
+
*/
|
2180 |
+
protected function _canUseFallBackTimeframe()
|
2181 |
+
{
|
2182 |
+
if ($this->canUseFoodDelivery()) {
|
2183 |
+
return false;
|
2184 |
+
}
|
2185 |
+
|
2186 |
+
return true;
|
2187 |
+
}
|
2188 |
+
|
2189 |
/**
|
2190 |
* Checks if sunday sorting is allowed.
|
2191 |
*
|
2199 |
return $cache->getPostnlDeliveryOptionsCanUseSundaySorting();
|
2200 |
}
|
2201 |
|
2202 |
+
if (!$this->canUseDutchProducts()) {
|
2203 |
+
$allowed = false;
|
2204 |
+
} else {
|
2205 |
+
$storeId = Mage::app()->getStore()->getId();
|
2206 |
+
|
2207 |
+
$quote = $this->getQuote();
|
2208 |
+
|
2209 |
+
$allowedXpath = self::XPATH_ALLOW_SUNDAY_SORTING;
|
2210 |
+
if ($quote && $quote->getShippingAddress() && $quote->getShippingAddress()->getCountryId() == 'BE') {
|
2211 |
+
$allowedXpath = self::XPATH_ALLOW_SUNDAY_SORTING_BE;
|
2212 |
+
}
|
2213 |
+
|
2214 |
+
$allowed = Mage::getStoreConfigFlag($allowedXpath, $storeId);
|
2215 |
+
}
|
2216 |
+
|
2217 |
+
if ($cache) {
|
2218 |
+
/**
|
2219 |
+
* Save the result in the PostNL cache.
|
2220 |
+
*/
|
2221 |
+
$cache->setPostnlDeliveryOptionsCanUseSundaySorting($allowed)
|
2222 |
+
->saveCache();
|
2223 |
+
}
|
2224 |
+
|
2225 |
+
return $allowed;
|
2226 |
+
}
|
2227 |
+
|
2228 |
+
/**
|
2229 |
+
* Determines if food delivery is allowed by checking the current quote and configuration.
|
2230 |
+
*
|
2231 |
+
* @param bool $checkQuote
|
2232 |
+
*
|
2233 |
+
* @return bool
|
2234 |
+
*/
|
2235 |
+
public function canUseFoodDelivery($checkQuote = true)
|
2236 |
+
{
|
2237 |
+
$allowed = $this->_canUseFoodDelivery();
|
2238 |
+
|
2239 |
+
if ($allowed && $checkQuote) {
|
2240 |
+
$allowed = $this->quoteIsFood();
|
2241 |
+
}
|
2242 |
+
|
2243 |
+
return $allowed;
|
2244 |
+
}
|
2245 |
+
|
2246 |
+
/**
|
2247 |
+
* Checks the configured (and possibly cached) options to determine if Food Delivery is allowed.
|
2248 |
+
*
|
2249 |
+
* @return bool
|
2250 |
+
*/
|
2251 |
+
protected function _canUseFoodDelivery()
|
2252 |
+
{
|
2253 |
+
$allowed = false;
|
2254 |
+
|
2255 |
+
$cache = $this->getCache();
|
2256 |
+
|
2257 |
+
if ($cache && $cache->hasPostnlDeliveryOptionsCanUseFoodDelivery()) {
|
2258 |
+
return $cache->getPostnlDeliveryOptionsCanUseFoodDelivery();
|
2259 |
+
}
|
2260 |
+
|
2261 |
$storeId = Mage::app()->getStore()->getId();
|
2262 |
+
$foodDeliveryEnabled = Mage::getStoreConfigFlag(self::XPATH_ENABLE_FOOD_DELIVERY, $storeId);
|
2263 |
+
|
2264 |
+
if ($this->canUseDutchProducts() == 'NL'
|
2265 |
+
&& $foodDeliveryEnabled
|
2266 |
+
&& $this->_getFoodProductOptionsAvailable($storeId)
|
2267 |
+
) {
|
2268 |
+
$allowed = true;
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
if ($cache) {
|
2272 |
+
/**
|
2273 |
+
* Save the result in the PostNL cache.
|
2274 |
+
*/
|
2275 |
+
$cache->setPostnlDeliveryOptionsCanUseFoodDelivery($allowed)
|
2276 |
+
->saveCache();
|
2277 |
+
}
|
2278 |
|
2279 |
+
return $allowed;
|
2280 |
+
}
|
2281 |
+
|
2282 |
+
/**
|
2283 |
+
* Check if at least one food product code is avaialble in the config.
|
2284 |
+
*
|
2285 |
+
* @param null $storeId
|
2286 |
+
*
|
2287 |
+
* @return bool
|
2288 |
+
*/
|
2289 |
+
protected function _getFoodProductOptionsAvailable($storeId = null)
|
2290 |
+
{
|
2291 |
+
$available = false;
|
2292 |
+
|
2293 |
+
if (!$storeId) {
|
2294 |
+
$storeId = Mage::app()->getStore()->getId();
|
2295 |
+
}
|
2296 |
+
|
2297 |
+
$availableProductOptions = explode(',', Mage::getStoreConfig(self::XPATH_AVAILABLE_PRODUCT_OPTIONS, $storeId));
|
2298 |
+
|
2299 |
+
foreach ($this->_foodProductCodes as $foodProductCode) {
|
2300 |
+
if (in_array($foodProductCode, $availableProductOptions)) {
|
2301 |
+
$available = true;
|
2302 |
+
break;
|
2303 |
+
}
|
2304 |
+
}
|
2305 |
+
|
2306 |
+
return $available;
|
2307 |
+
}
|
2308 |
+
|
2309 |
+
/**
|
2310 |
+
* Checks if sunday sorting is allowed.
|
2311 |
+
*
|
2312 |
+
* @param bool $checkCutOffTime
|
2313 |
+
*
|
2314 |
+
* @return bool
|
2315 |
+
*/
|
2316 |
+
public function canUseSameDayDelivery($checkCutOffTime = false)
|
2317 |
+
{
|
2318 |
+
$allowed = $this->_canUseSameDayDelivery();
|
2319 |
+
|
2320 |
+
if ($allowed && $checkCutOffTime) {
|
2321 |
+
/** @var TIG_PostNL_Helper_Date $helper */
|
2322 |
+
$helper = Mage::helper('postnl/date');
|
2323 |
+
$isPastCutOff = $helper->isPastCutOff(
|
2324 |
+
new DateTime('now', new DateTimeZone('UTC')),
|
2325 |
+
Mage::app()->getStore()->getId(),
|
2326 |
+
'sameday'
|
2327 |
+
);
|
2328 |
+
|
2329 |
+
if ($isPastCutOff) {
|
2330 |
+
$allowed = false;
|
2331 |
+
}
|
2332 |
+
}
|
2333 |
+
|
2334 |
+
return $allowed;
|
2335 |
+
}
|
2336 |
+
|
2337 |
+
/**
|
2338 |
+
* Checks if sunday sorting is allowed.
|
2339 |
+
*
|
2340 |
+
* @return bool
|
2341 |
+
*/
|
2342 |
+
protected function _canUseSameDayDelivery()
|
2343 |
+
{
|
2344 |
+
$cache = $this->getCache();
|
2345 |
+
|
2346 |
+
if ($cache && $cache->hasPostnlDeliveryOptionsCanUseSameDayDelivery()) {
|
2347 |
+
return $cache->getPostnlDeliveryOptionsCanUseSameDayDelivery();
|
2348 |
+
}
|
2349 |
+
|
2350 |
+
$storeId = Mage::app()->getStore()->getId();
|
2351 |
+
|
2352 |
+
if (!$this->canUseDutchProducts()) {
|
2353 |
$allowed = false;
|
2354 |
} else {
|
2355 |
+
$allowed = Mage::getStoreConfigFlag(self::XPATH_ENABLE_SAMEDAY_DELIVERY, $storeId);
|
2356 |
}
|
2357 |
|
2358 |
if ($cache) {
|
2359 |
/**
|
2360 |
* Save the result in the PostNL cache.
|
2361 |
*/
|
2362 |
+
$cache->setPostnlDeliveryOptionsCanUseSameDayDelivery($allowed)
|
2363 |
->saveCache();
|
2364 |
}
|
2365 |
|
2379 |
* Form a unique registry key for the current quote (if available) so we can cache the result of this method in
|
2380 |
* the registry.
|
2381 |
*/
|
2382 |
+
$registryKey = 'can_use_delivery_options_' . $this->getDomesticCountry();
|
2383 |
if ($quote && $quote->getId()) {
|
2384 |
$registryKey .= '_quote_id_' . $quote->getId();
|
2385 |
}
|
2397 |
/**
|
2398 |
* Delivery options are only available when shipping from the Netherlands.
|
2399 |
*/
|
2400 |
+
if (!$this->canUseDutchProducts()) {
|
2401 |
Mage::register($registryKey, false);
|
2402 |
return false;
|
2403 |
}
|
2499 |
array(
|
2500 |
'code' => 'POSTNL-0121',
|
2501 |
'message' => $this->__(
|
2502 |
+
'Delivery options are not allowed for one or more itme sin the cart based on the' .
|
2503 |
+
' configured stock options.'
|
2504 |
+
),
|
2505 |
)
|
2506 |
);
|
2507 |
Mage::register('postnl_delivery_options_can_use_delivery_options_errors', $errors);
|
2522 |
}
|
2523 |
|
2524 |
/**
|
2525 |
+
* If the product is a bundled product, check if the delivery options are allowed for all underlying
|
2526 |
+
* simple products. Else just check the given product, since this will point correctly to the simple
|
2527 |
+
* product.
|
2528 |
*/
|
2529 |
if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
2530 |
$allowDeliveryOptions = $this->bundleCheckAllowedForSimpleProducts(
|
2570 |
}
|
2571 |
}
|
2572 |
|
2573 |
+
if (
|
2574 |
+
$quote->getShippingAddress()->getCountryId() !== null &&
|
2575 |
+
$quote->getShippingAddress()->getCountryId() != 'NL' &&
|
2576 |
+
$this->getDomesticCountry() != 'NL'
|
2577 |
+
) {
|
2578 |
+
return false;
|
2579 |
+
}
|
2580 |
+
|
2581 |
return true;
|
2582 |
}
|
2583 |
|
2659 |
$stockItem = $product->getStockItem();
|
2660 |
|
2661 |
if (!$stockItem) {
|
2662 |
+
/** @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
|
2663 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item');
|
2664 |
+
$stockItem->loadByProduct($product);
|
2665 |
}
|
2666 |
|
2667 |
+
$itemQty = $item->getParentItem() ? $item->getParentItem()->getQty() : $item->getQty();
|
2668 |
$available = false;
|
2669 |
switch ($stockOption) {
|
2670 |
case 'in_stock':
|
2671 |
+
$available = $this->_isStockItemInStock($stockItem, false, $itemQty);
|
2672 |
break;
|
2673 |
case 'backordered':
|
2674 |
+
$available = $this->_isStockItemInStock($stockItem, true, $itemQty);
|
2675 |
break;
|
2676 |
}
|
2677 |
|
2771 |
}
|
2772 |
|
2773 |
/**
|
2774 |
+
* Delivery options are only available when shipping to the Netherlands or Belgium.
|
|
|
|
|
|
|
|
|
|
|
2775 |
*/
|
2776 |
+
if ($shippingAddress->getCountry() != 'NL' && $shippingAddress->getCountry() != 'BE') {
|
2777 |
+
Mage::register($registryKey, false);
|
2778 |
+
return false;
|
2779 |
+
}
|
2780 |
+
|
2781 |
+
if ($shippingAddress->getCountry() == 'BE'
|
2782 |
+
&& Mage::getStoreConfigFlag(self::XPATH_DELIVERY_OPTIONS_BE_ACTIVE, $quote->getStoreId()) === false
|
2783 |
+
) {
|
2784 |
Mage::register($registryKey, false);
|
2785 |
return false;
|
2786 |
}
|
3125 |
return false;
|
3126 |
}
|
3127 |
|
3128 |
+
/**
|
3129 |
+
* If the shipment is a Food Delivery shipment, this option should not be shown.
|
3130 |
+
*/
|
3131 |
+
if ($this->quoteIsFood()) {
|
3132 |
+
Mage::register($registryKey, false);
|
3133 |
+
return false;
|
3134 |
+
}
|
3135 |
+
|
3136 |
Mage::register($registryKey, true);
|
3137 |
return true;
|
3138 |
}
|
3156 |
/**
|
3157 |
* Check if any valid product options are available.
|
3158 |
*/
|
3159 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $statedAddressOnlyOptionsModel */
|
3160 |
+
$statedAddressOnlyOptionsModel = Mage::getSingleton('postnl_core/system_config_source_allProductOptions');
|
3161 |
+
$statedAddressOnlyOptions = $statedAddressOnlyOptionsModel->getOptions(
|
3162 |
+
array(
|
3163 |
+
'statedAddressOnly' => true
|
3164 |
+
),
|
3165 |
+
true,
|
3166 |
+
true
|
3167 |
+
);
|
3168 |
|
3169 |
if (empty($statedAddressOnlyOptions)) {
|
3170 |
return false;
|
3370 |
*
|
3371 |
* N.B. The PostNL shipping methods are not dependant on the selected store view.
|
3372 |
*/
|
3373 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
3374 |
+
$helper = Mage::helper('postnl/carrier');
|
3375 |
+
$postnlShippingMethods = $helper->getPostnlShippingMethods();
|
3376 |
|
3377 |
$conflictingShippingMethods = array_intersect($goMageDeliveryDateShippingMethods, $postnlShippingMethods);
|
3378 |
if (empty($conflictingShippingMethods)) {
|
3410 |
}
|
3411 |
|
3412 |
return $allow;
|
3413 |
+
}
|
3414 |
+
|
3415 |
+
/**
|
3416 |
+
* Check if we can use Dutch products.
|
3417 |
+
*
|
3418 |
+
* @return bool|null
|
3419 |
+
*/
|
3420 |
+
public function canUseDutchProducts()
|
3421 |
+
{
|
3422 |
+
if ($this->_canUseDutchProducts !== null) {
|
3423 |
+
return $this->_canUseDutchProducts;
|
3424 |
+
}
|
3425 |
+
|
3426 |
+
/**
|
3427 |
+
* The Netherlands is always allowed.
|
3428 |
+
*/
|
3429 |
+
if ($this->getDomesticCountry() == 'NL') {
|
3430 |
+
$this->_canUseDutchProducts = true;
|
3431 |
+
return $this->_canUseDutchProducts;
|
3432 |
+
}
|
3433 |
+
|
3434 |
+
/**
|
3435 |
+
* In some cases Belgium is also allowed. Other countries are never allowed.
|
3436 |
+
*/
|
3437 |
+
if ($this->getDomesticCountry() != 'BE') {
|
3438 |
+
$this->_canUseDutchProducts = false;
|
3439 |
+
return $this->_canUseDutchProducts;
|
3440 |
+
}
|
3441 |
+
|
3442 |
+
/**
|
3443 |
+
* If the user enabled the option "Use dutch products", and is in Belgium, it is allowed to use Dutch products.
|
3444 |
+
*/
|
3445 |
+
$use_dutch_products = Mage::getStoreConfig(self::XPATH_USE_DUTCH_PRODUCTS, Mage::app()->getStore()->getId());
|
3446 |
+
if ($use_dutch_products == '1') {
|
3447 |
+
$this->_canUseDutchProducts = true;
|
3448 |
+
return $this->_canUseDutchProducts;
|
3449 |
+
}
|
3450 |
|
3451 |
+
$this->_canUseDutchProducts = false;
|
3452 |
+
return $this->_canUseDutchProducts;
|
3453 |
}
|
3454 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
@@ -43,6 +43,7 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
43 |
*/
|
44 |
const XPATH_EVENING_TIMEFRAME_FEE = 'postnl/delivery_options/evening_timeframe_fee';
|
45 |
const XPATH_SUNDAY_DELIVERY_FEE = 'postnl/delivery_options/sunday_delivery_fee';
|
|
|
46 |
const XPATH_PAKJEGEMAK_EXPRESS_FEE = 'postnl/delivery_options/pakjegemak_express_fee';
|
47 |
const XPATH_ONLY_STATED_ADDRESS_FEE = 'postnl/delivery_options/stated_address_only_fee';
|
48 |
|
@@ -57,6 +58,7 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
57 |
*/
|
58 |
const FEE_TYPE_EVENING = 'Evening';
|
59 |
const FEE_TYPE_SUNDAY = 'Sunday';
|
|
|
60 |
const FEE_TYPE_EXPRESS = 'Express';
|
61 |
|
62 |
/**
|
@@ -77,6 +79,12 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
77 |
const SUNDAY_FEE_MIN = 0;
|
78 |
const SUNDAY_FEE_MAX = 10;
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
/**
|
81 |
* Get the fee limit, min or max, for the supplied fee type
|
82 |
*
|
@@ -117,6 +125,9 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
117 |
case self::FEE_TYPE_SUNDAY:
|
118 |
$fee = self::SUNDAY_FEE_MIN;
|
119 |
break;
|
|
|
|
|
|
|
120 |
case self::FEE_TYPE_EXPRESS:
|
121 |
$fee = self::EXPRESS_FEE_MIN;
|
122 |
break;
|
@@ -143,6 +154,9 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
143 |
case self::FEE_TYPE_SUNDAY:
|
144 |
$fee = self::SUNDAY_FEE_MAX;
|
145 |
break;
|
|
|
|
|
|
|
146 |
case self::FEE_TYPE_EXPRESS:
|
147 |
$fee = self::EXPRESS_FEE_MAX;
|
148 |
break;
|
@@ -185,6 +199,22 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
185 |
return $this->_getFee($feeType, $formatted, $includingTax, $convert);
|
186 |
}
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
/**
|
189 |
* Get the fee charged for PakjeGemak Express.
|
190 |
*
|
@@ -253,7 +283,6 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
253 |
* @param string $feeType
|
254 |
*
|
255 |
* @return string
|
256 |
-
* @todo add default with throw new exception
|
257 |
*/
|
258 |
protected function _getFeeRegistryKey($feeType)
|
259 |
{
|
@@ -264,9 +293,14 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
264 |
case self::FEE_TYPE_SUNDAY:
|
265 |
$registryKey = 'postnl_sunday_fee';
|
266 |
break;
|
|
|
|
|
|
|
267 |
case self::FEE_TYPE_EXPRESS:
|
268 |
$registryKey = 'postnl_express_fee';
|
269 |
break;
|
|
|
|
|
270 |
}
|
271 |
|
272 |
return $registryKey;
|
@@ -276,7 +310,6 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
276 |
* @param string $feeType
|
277 |
*
|
278 |
* @return string
|
279 |
-
* @todo add default with throw new exception
|
280 |
*/
|
281 |
protected function _getFeeConfigXpath($feeType)
|
282 |
{
|
@@ -287,9 +320,14 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
287 |
case self::FEE_TYPE_SUNDAY:
|
288 |
$xpath = self::XPATH_SUNDAY_DELIVERY_FEE;
|
289 |
break;
|
|
|
|
|
|
|
290 |
case self::FEE_TYPE_EXPRESS:
|
291 |
$xpath = self::XPATH_PAKJEGEMAK_EXPRESS_FEE;
|
292 |
break;
|
|
|
|
|
293 |
}
|
294 |
|
295 |
return $xpath;
|
@@ -313,19 +351,12 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
313 |
$registryKey .= '_incl';
|
314 |
}
|
315 |
|
316 |
-
/**
|
317 |
-
* If the current order is not a buspakje order, the fee is 0.
|
318 |
-
*/
|
319 |
-
if (!$this->isBuspakjeConfigApplicableToQuote()) {
|
320 |
-
Mage::register($registryKey, 0);
|
321 |
-
|
322 |
-
return 0;
|
323 |
-
}
|
324 |
-
|
325 |
if (Mage::registry($registryKey) !== null) {
|
326 |
$price = Mage::registry($registryKey);
|
327 |
} else {
|
328 |
-
|
|
|
|
|
329 |
if (!$pakjeGemakShippingRates) {
|
330 |
return 0;
|
331 |
}
|
@@ -342,8 +373,7 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
342 |
}
|
343 |
|
344 |
if ($convert) {
|
345 |
-
$
|
346 |
-
$store = $quote->getStore();
|
347 |
|
348 |
$price = $store->convertPrice($price, false, false);
|
349 |
}
|
@@ -475,7 +505,9 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
475 |
$quote = $this->getQuote();
|
476 |
$store = $quote->getStore();
|
477 |
|
478 |
-
|
|
|
|
|
479 |
|
480 |
if ($convert) {
|
481 |
$shippingPrice = $store->convertPrice($shippingPrice, $formatted, false);
|
@@ -484,4 +516,4 @@ class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
|
484 |
return $shippingPrice;
|
485 |
}
|
486 |
|
487 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_DeliveryOptions_Fee extends TIG_PostNL_Helper_Data
|
43 |
*/
|
44 |
const XPATH_EVENING_TIMEFRAME_FEE = 'postnl/delivery_options/evening_timeframe_fee';
|
45 |
const XPATH_SUNDAY_DELIVERY_FEE = 'postnl/delivery_options/sunday_delivery_fee';
|
46 |
+
const XPATH_SAMEDAY_DELIVERY_FEE = 'postnl/delivery_options/sameday_delivery_fee';
|
47 |
const XPATH_PAKJEGEMAK_EXPRESS_FEE = 'postnl/delivery_options/pakjegemak_express_fee';
|
48 |
const XPATH_ONLY_STATED_ADDRESS_FEE = 'postnl/delivery_options/stated_address_only_fee';
|
49 |
|
58 |
*/
|
59 |
const FEE_TYPE_EVENING = 'Evening';
|
60 |
const FEE_TYPE_SUNDAY = 'Sunday';
|
61 |
+
const FEE_TYPE_SAMEDAY = 'Sameday';
|
62 |
const FEE_TYPE_EXPRESS = 'Express';
|
63 |
|
64 |
/**
|
79 |
const SUNDAY_FEE_MIN = 0;
|
80 |
const SUNDAY_FEE_MAX = 10;
|
81 |
|
82 |
+
/**
|
83 |
+
* Same day delivery fee limits
|
84 |
+
*/
|
85 |
+
const SAMEDAY_FEE_MIN = 0;
|
86 |
+
const SAMEDAY_FEE_MAX = 25;
|
87 |
+
|
88 |
/**
|
89 |
* Get the fee limit, min or max, for the supplied fee type
|
90 |
*
|
125 |
case self::FEE_TYPE_SUNDAY:
|
126 |
$fee = self::SUNDAY_FEE_MIN;
|
127 |
break;
|
128 |
+
case self::FEE_TYPE_SAMEDAY:
|
129 |
+
$fee = self::SAMEDAY_FEE_MIN;
|
130 |
+
break;
|
131 |
case self::FEE_TYPE_EXPRESS:
|
132 |
$fee = self::EXPRESS_FEE_MIN;
|
133 |
break;
|
154 |
case self::FEE_TYPE_SUNDAY:
|
155 |
$fee = self::SUNDAY_FEE_MAX;
|
156 |
break;
|
157 |
+
case self::FEE_TYPE_SAMEDAY:
|
158 |
+
$fee = self::SAMEDAY_FEE_MAX;
|
159 |
+
break;
|
160 |
case self::FEE_TYPE_EXPRESS:
|
161 |
$fee = self::EXPRESS_FEE_MAX;
|
162 |
break;
|
199 |
return $this->_getFee($feeType, $formatted, $includingTax, $convert);
|
200 |
}
|
201 |
|
202 |
+
/**
|
203 |
+
* Get the fee charged for same day delivery.
|
204 |
+
*
|
205 |
+
* @param boolean $formatted
|
206 |
+
* @param boolean $includingTax
|
207 |
+
* @param boolean $convert
|
208 |
+
*
|
209 |
+
* @return float
|
210 |
+
*/
|
211 |
+
public function getSameDayFee($formatted = false, $includingTax = true, $convert = true)
|
212 |
+
{
|
213 |
+
$feeType = self::FEE_TYPE_SAMEDAY;
|
214 |
+
|
215 |
+
return $this->_getFee($feeType, $formatted, $includingTax, $convert);
|
216 |
+
}
|
217 |
+
|
218 |
/**
|
219 |
* Get the fee charged for PakjeGemak Express.
|
220 |
*
|
283 |
* @param string $feeType
|
284 |
*
|
285 |
* @return string
|
|
|
286 |
*/
|
287 |
protected function _getFeeRegistryKey($feeType)
|
288 |
{
|
293 |
case self::FEE_TYPE_SUNDAY:
|
294 |
$registryKey = 'postnl_sunday_fee';
|
295 |
break;
|
296 |
+
case self::FEE_TYPE_SAMEDAY:
|
297 |
+
$registryKey = 'postnl_sameday_fee';
|
298 |
+
break;
|
299 |
case self::FEE_TYPE_EXPRESS:
|
300 |
$registryKey = 'postnl_express_fee';
|
301 |
break;
|
302 |
+
default:
|
303 |
+
throw new InvalidArgumentException("Invalid feeType supplied.");
|
304 |
}
|
305 |
|
306 |
return $registryKey;
|
310 |
* @param string $feeType
|
311 |
*
|
312 |
* @return string
|
|
|
313 |
*/
|
314 |
protected function _getFeeConfigXpath($feeType)
|
315 |
{
|
320 |
case self::FEE_TYPE_SUNDAY:
|
321 |
$xpath = self::XPATH_SUNDAY_DELIVERY_FEE;
|
322 |
break;
|
323 |
+
case self::FEE_TYPE_SAMEDAY:
|
324 |
+
$xpath = self::XPATH_SAMEDAY_DELIVERY_FEE;
|
325 |
+
break;
|
326 |
case self::FEE_TYPE_EXPRESS:
|
327 |
$xpath = self::XPATH_PAKJEGEMAK_EXPRESS_FEE;
|
328 |
break;
|
329 |
+
default:
|
330 |
+
throw new InvalidArgumentException("Invalid feeType supplied.");
|
331 |
}
|
332 |
|
333 |
return $xpath;
|
351 |
$registryKey .= '_incl';
|
352 |
}
|
353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
if (Mage::registry($registryKey) !== null) {
|
355 |
$price = Mage::registry($registryKey);
|
356 |
} else {
|
357 |
+
/** @var TIG_PostNL_Helper_Carrier $carierHelper */
|
358 |
+
$carierHelper = Mage::helper('postnl/carrier');
|
359 |
+
$pakjeGemakShippingRates = $carierHelper->getParcelShippingRate($this->getQuote());
|
360 |
if (!$pakjeGemakShippingRates) {
|
361 |
return 0;
|
362 |
}
|
373 |
}
|
374 |
|
375 |
if ($convert) {
|
376 |
+
$store = $this->getQuote()->getStore();
|
|
|
377 |
|
378 |
$price = $store->convertPrice($price, false, false);
|
379 |
}
|
505 |
$quote = $this->getQuote();
|
506 |
$store = $quote->getStore();
|
507 |
|
508 |
+
/** @var Mage_Tax_Helper_Data $helper */
|
509 |
+
$helper = Mage::helper('tax');
|
510 |
+
$shippingPrice = $helper->getShippingPrice($price, $includingTax, $quote->getShippingAddress());
|
511 |
|
512 |
if ($convert) {
|
513 |
$shippingPrice = $store->convertPrice($shippingPrice, $formatted, false);
|
516 |
return $shippingPrice;
|
517 |
}
|
518 |
|
519 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Mijnpakket extends TIG_PostNL_Helper_Data
|
@@ -104,7 +104,9 @@ class TIG_PostNL_Helper_Mijnpakket extends TIG_PostNL_Helper_Data
|
|
104 |
/**
|
105 |
* MijnPakket login is only available if delivery options are enabled.
|
106 |
*/
|
107 |
-
|
|
|
|
|
108 |
return false;
|
109 |
}
|
110 |
|
@@ -127,7 +129,9 @@ class TIG_PostNL_Helper_Mijnpakket extends TIG_PostNL_Helper_Data
|
|
127 |
return $cache->getPostnlMijnpakketCanShowNotification();
|
128 |
}
|
129 |
|
130 |
-
|
|
|
|
|
131 |
return false;
|
132 |
}
|
133 |
|
@@ -141,4 +145,4 @@ class TIG_PostNL_Helper_Mijnpakket extends TIG_PostNL_Helper_Data
|
|
141 |
|
142 |
return $canShowNotification;
|
143 |
}
|
144 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Mijnpakket extends TIG_PostNL_Helper_Data
|
104 |
/**
|
105 |
* MijnPakket login is only available if delivery options are enabled.
|
106 |
*/
|
107 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
108 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
109 |
+
if (!$helper->isDeliveryOptionsEnabled()) {
|
110 |
return false;
|
111 |
}
|
112 |
|
129 |
return $cache->getPostnlMijnpakketCanShowNotification();
|
130 |
}
|
131 |
|
132 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
133 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
134 |
+
if (!$helper->canUseDeliveryOptions()) {
|
135 |
return false;
|
136 |
}
|
137 |
|
145 |
|
146 |
return $canShowNotification;
|
147 |
}
|
148 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Parcelware extends TIG_PostNL_Helper_Data
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Helper_Parcelware extends TIG_PostNL_Helper_Data
|
@@ -35,7 +35,7 @@
|
|
35 |
*
|
36 |
* @category TIG
|
37 |
* @package TIG_PostNL
|
38 |
-
* @copyright Copyright (c)
|
39 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
40 |
* @link http://store.tig.nl/tig/postnl.html
|
41 |
*/
|
@@ -79,6 +79,7 @@ class TIG_PostNL_Helper_Payment extends TIG_PostNL_Helper_Data
|
|
79 |
return $this->_serviceModel;
|
80 |
}
|
81 |
|
|
|
82 |
$serviceModel = Mage::getModel('postnl_payment/service');
|
83 |
|
84 |
$this->setServiceModel($serviceModel);
|
@@ -141,4 +142,4 @@ class TIG_PostNL_Helper_Payment extends TIG_PostNL_Helper_Data
|
|
141 |
|
142 |
return $fullInfo;
|
143 |
}
|
144 |
-
}
|
35 |
*
|
36 |
* @category TIG
|
37 |
* @package TIG_PostNL
|
38 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
39 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
40 |
* @link http://store.tig.nl/tig/postnl.html
|
41 |
*/
|
79 |
return $this->_serviceModel;
|
80 |
}
|
81 |
|
82 |
+
/** @var TIG_PostNL_Model_Payment_Service $serviceModel */
|
83 |
$serviceModel = Mage::getModel('postnl_payment/service');
|
84 |
|
85 |
$this->setServiceModel($serviceModel);
|
142 |
|
143 |
return $fullInfo;
|
144 |
}
|
145 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
@@ -140,7 +140,9 @@ class TIG_PostNL_Helper_Webservices extends TIG_PostNL_Helper_Data
|
|
140 |
{
|
141 |
$value = (string) $value;
|
142 |
|
143 |
-
|
|
|
|
|
144 |
|
145 |
return $encrypted;
|
146 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
140 |
{
|
141 |
$value = (string) $value;
|
142 |
|
143 |
+
/** @var Mage_Core_Helper_Data $helper */
|
144 |
+
$helper = Mage::helper('core');
|
145 |
+
$encrypted = $helper->encrypt($value);
|
146 |
|
147 |
return $encrypted;
|
148 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_AddressValidation_Cendris extends TIG_PostNL_Model_AddressValidation_Cendris_Abstract
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_AddressValidation_Cendris extends TIG_PostNL_Model_AddressValidation_Cendris_Abstract
|
@@ -33,7 +33,7 @@ advanced * Do not edit or add to this file if you wish to upgrade this module to
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_AddressValidation_Cendris_Abstract extends Varien_Object
|
@@ -96,7 +96,9 @@ class TIG_PostNL_Model_AddressValidation_Cendris_Abstract extends Varien_Object
|
|
96 |
$soapParams
|
97 |
);
|
98 |
|
99 |
-
|
|
|
|
|
100 |
return $response;
|
101 |
} catch(SoapFault $e) {
|
102 |
/**
|
@@ -105,7 +107,9 @@ class TIG_PostNL_Model_AddressValidation_Cendris_Abstract extends Varien_Object
|
|
105 |
if (!isset($client)) {
|
106 |
$client = false;
|
107 |
}
|
108 |
-
|
|
|
|
|
109 |
|
110 |
throw $e;
|
111 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_AddressValidation_Cendris_Abstract extends Varien_Object
|
96 |
$soapParams
|
97 |
);
|
98 |
|
99 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
100 |
+
$helper = Mage::helper('postnl/addressValidation');
|
101 |
+
$helper->logCendrisCall($client);
|
102 |
return $response;
|
103 |
} catch(SoapFault $e) {
|
104 |
/**
|
107 |
if (!isset($client)) {
|
108 |
$client = false;
|
109 |
}
|
110 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
111 |
+
$helper = Mage::helper('postnl/addressValidation');
|
112 |
+
$helper->logCendrisException($e, $client);
|
113 |
|
114 |
throw $e;
|
115 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasAddressBlockClass()
|
@@ -89,7 +89,8 @@ class TIG_PostNL_Model_AddressValidation_Observer_AddressBook extends Varien_Obj
|
|
89 |
*
|
90 |
* @var Mage_Customer_Block_Address_Edit $block
|
91 |
*/
|
92 |
-
|
|
|
93 |
$blockClass = $this->getAddressBlockClass();
|
94 |
|
95 |
if (get_class($block) !== $blockClass) {
|
@@ -99,7 +100,9 @@ class TIG_PostNL_Model_AddressValidation_Observer_AddressBook extends Varien_Obj
|
|
99 |
/**
|
100 |
* Check if the extension is active
|
101 |
*/
|
102 |
-
|
|
|
|
|
103 |
return $this;
|
104 |
}
|
105 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasAddressBlockClass()
|
89 |
*
|
90 |
* @var Mage_Customer_Block_Address_Edit $block
|
91 |
*/
|
92 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
93 |
+
$block = $observer->getBlock();
|
94 |
$blockClass = $this->getAddressBlockClass();
|
95 |
|
96 |
if (get_class($block) !== $blockClass) {
|
100 |
/**
|
101 |
* Check if the extension is active
|
102 |
*/
|
103 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
104 |
+
$helper = Mage::helper('postnl/addressValidation');
|
105 |
+
if (!$helper->isPostcodeCheckEnabled(null, self::POSTCODECHECK_ENV)) {
|
106 |
return $this;
|
107 |
}
|
108 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasAddressBlockClass()
|
@@ -96,7 +96,8 @@ class TIG_PostNL_Model_AddressValidation_Observer_OneStepCheckout extends Varien
|
|
96 |
*
|
97 |
* @var Idev_OneStepCheckout_Block_Fields $block
|
98 |
*/
|
99 |
-
|
|
|
100 |
$blockClass = $this->getAddressBlockClass();
|
101 |
|
102 |
if (get_class($block) !== $blockClass) {
|
@@ -108,14 +109,16 @@ class TIG_PostNL_Model_AddressValidation_Observer_OneStepCheckout extends Varien
|
|
108 |
}
|
109 |
|
110 |
/**
|
111 |
-
* Check if the extension is active
|
112 |
*/
|
113 |
-
|
|
|
|
|
114 |
return $this;
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
-
* Get the blocks alias and alter it's template based on this
|
119 |
*/
|
120 |
$blockAlias = $block->getBlockAlias();
|
121 |
switch ($blockAlias) {
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasAddressBlockClass()
|
96 |
*
|
97 |
* @var Idev_OneStepCheckout_Block_Fields $block
|
98 |
*/
|
99 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
100 |
+
$block = $observer->getBlock();
|
101 |
$blockClass = $this->getAddressBlockClass();
|
102 |
|
103 |
if (get_class($block) !== $blockClass) {
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
+
* Check if the extension is active.
|
113 |
*/
|
114 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
115 |
+
$helper = Mage::helper('postnl/addressValidation');
|
116 |
+
if (!$helper->isPostcodeCheckEnabled(null, self::POSTCODECHECK_ENV)) {
|
117 |
return $this;
|
118 |
}
|
119 |
|
120 |
/**
|
121 |
+
* Get the blocks alias and alter it's template based on this.
|
122 |
*/
|
123 |
$blockAlias = $block->getBlockAlias();
|
124 |
switch ($blockAlias) {
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasBillingAddressBlockClass()
|
@@ -109,7 +109,8 @@ class TIG_PostNL_Model_AddressValidation_Observer_Onepage extends Varien_Object
|
|
109 |
*
|
110 |
* @var Mage_Checkout_Block_Onepage_Billing $block
|
111 |
*/
|
112 |
-
|
|
|
113 |
$blockClass = $this->getBillingAddressBlockClass();
|
114 |
|
115 |
if (get_class($block) !== $blockClass) {
|
@@ -121,9 +122,11 @@ class TIG_PostNL_Model_AddressValidation_Observer_Onepage extends Varien_Object
|
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
-
* Check if the extension is active
|
125 |
*/
|
126 |
-
|
|
|
|
|
127 |
return $this;
|
128 |
}
|
129 |
|
@@ -153,7 +156,8 @@ class TIG_PostNL_Model_AddressValidation_Observer_Onepage extends Varien_Object
|
|
153 |
*
|
154 |
* @var Mage_Checkout_Block_Onepage_Shipping $block
|
155 |
*/
|
156 |
-
|
|
|
157 |
$blockClass = $this->getShippingAddressBlockClass();
|
158 |
|
159 |
if (get_class($block) !== $blockClass) {
|
@@ -167,7 +171,9 @@ class TIG_PostNL_Model_AddressValidation_Observer_Onepage extends Varien_Object
|
|
167 |
/**
|
168 |
* Check if the extension is active
|
169 |
*/
|
170 |
-
|
|
|
|
|
171 |
return $this;
|
172 |
}
|
173 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasBillingAddressBlockClass()
|
109 |
*
|
110 |
* @var Mage_Checkout_Block_Onepage_Billing $block
|
111 |
*/
|
112 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
113 |
+
$block = $observer->getBlock();
|
114 |
$blockClass = $this->getBillingAddressBlockClass();
|
115 |
|
116 |
if (get_class($block) !== $blockClass) {
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
+
* Check if the extension is active.
|
126 |
*/
|
127 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
128 |
+
$helper = Mage::helper('postnl/addressValidation');
|
129 |
+
if (!$helper->isPostcodeCheckEnabled(null, self::POSTCODECHECK_ENV)) {
|
130 |
return $this;
|
131 |
}
|
132 |
|
156 |
*
|
157 |
* @var Mage_Checkout_Block_Onepage_Shipping $block
|
158 |
*/
|
159 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
160 |
+
$block = $observer->getBlock();
|
161 |
$blockClass = $this->getShippingAddressBlockClass();
|
162 |
|
163 |
if (get_class($block) !== $blockClass) {
|
171 |
/**
|
172 |
* Check if the extension is active
|
173 |
*/
|
174 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
175 |
+
$helper = Mage::helper('postnl/addressValidation');
|
176 |
+
if (!$helper->isPostcodeCheckEnabled(null, self::POSTCODECHECK_ENV)) {
|
177 |
return $this;
|
178 |
}
|
179 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasStoreId()
|
@@ -90,6 +90,7 @@ class TIG_PostNL_Model_AddressValidation_System_Config_Backend_ValidateAccount e
|
|
90 |
}
|
91 |
|
92 |
$websiteCode = $this->getWebsiteCode();
|
|
|
93 |
$website = Mage::getModel('core/website')->load($websiteCode, 'code');
|
94 |
|
95 |
$this->setWebsite($website);
|
@@ -144,7 +145,9 @@ class TIG_PostNL_Model_AddressValidation_System_Config_Backend_ValidateAccount e
|
|
144 |
* Decrypt and then hash the password.
|
145 |
*/
|
146 |
$password = trim($password);
|
147 |
-
|
|
|
|
|
148 |
|
149 |
/**
|
150 |
* Put all credentials into an array.
|
@@ -159,11 +162,10 @@ class TIG_PostNL_Model_AddressValidation_System_Config_Backend_ValidateAccount e
|
|
159 |
|
160 |
/**
|
161 |
* Load the CIF model and set to test mode to false.
|
162 |
-
*
|
163 |
-
* @var TIG_PostNL_Model_Core_Cif $cif
|
164 |
*/
|
165 |
-
$cif
|
166 |
-
|
|
|
167 |
|
168 |
/**
|
169 |
* Attempt to generate a barcode to test the account settings. This will result in an exception if the settings
|
@@ -274,6 +276,7 @@ class TIG_PostNL_Model_AddressValidation_System_Config_Backend_ValidateAccount e
|
|
274 |
* Get the error from the extension's config.xml
|
275 |
*/
|
276 |
$error = Mage::getConfig()->getNode('tig/errors/POSTNL-0114');
|
|
|
277 |
$link = (string) $error->url;
|
278 |
|
279 |
/**
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasStoreId()
|
90 |
}
|
91 |
|
92 |
$websiteCode = $this->getWebsiteCode();
|
93 |
+
/** @var Mage_Core_Model_Website $website */
|
94 |
$website = Mage::getModel('core/website')->load($websiteCode, 'code');
|
95 |
|
96 |
$this->setWebsite($website);
|
145 |
* Decrypt and then hash the password.
|
146 |
*/
|
147 |
$password = trim($password);
|
148 |
+
/** @var Mage_Core_Helper_Data $helper */
|
149 |
+
$helper = Mage::helper('core');
|
150 |
+
$password = sha1($helper->decrypt($password));
|
151 |
|
152 |
/**
|
153 |
* Put all credentials into an array.
|
162 |
|
163 |
/**
|
164 |
* Load the CIF model and set to test mode to false.
|
|
|
|
|
165 |
*/
|
166 |
+
/** @var TIG_PostNL_Model_Core_Cif $cif */
|
167 |
+
$cif = Mage::getModel('postnl_core/cif');
|
168 |
+
$cif->setTestMode($testMode);
|
169 |
|
170 |
/**
|
171 |
* Attempt to generate a barcode to test the account settings. This will result in an exception if the settings
|
276 |
* Get the error from the extension's config.xml
|
277 |
*/
|
278 |
$error = Mage::getConfig()->getNode('tig/errors/POSTNL-0114');
|
279 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
280 |
$link = (string) $error->url;
|
281 |
|
282 |
/**
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* The only reason this class exists is because the add() method and it's derivatives are only present since EE 1.12 and
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* The only reason this class exists is because the add() method and it's derivatives are only present since EE 1.12 and
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated this class is no longer used as of v1.7.0.
|
@@ -47,15 +47,13 @@ class TIG_PostNL_Model_Admin_Logging_Handler_Postnl extends Enterprise_Logging_M
|
|
47 |
* @param Enterprise_Logging_Model_Event $eventModel
|
48 |
*
|
49 |
* @return boolean
|
50 |
-
*
|
51 |
-
* @deprecated v1.7.0
|
52 |
*/
|
53 |
-
public function postDispatchSaveMassAction(
|
|
|
54 |
{
|
55 |
-
trigger_error('This method is deprecated and may be removed in the future.', E_USER_DEPRECATED);
|
56 |
-
|
57 |
$request = Mage::app()->getRequest();
|
58 |
if ($request->getParam('shipment_ids')) {
|
|
|
59 |
$eventModel->setInfo(
|
60 |
Mage::helper('enterprise_logging')->implodeValues($request->getParam('shipment_ids'))
|
61 |
);
|
@@ -64,6 +62,7 @@ class TIG_PostNL_Model_Admin_Logging_Handler_Postnl extends Enterprise_Logging_M
|
|
64 |
}
|
65 |
|
66 |
if ($request->getParam('order_ids')) {
|
|
|
67 |
$eventModel->setInfo(
|
68 |
Mage::helper('enterprise_logging')->implodeValues($request->getParam('order_ids'))
|
69 |
);
|
@@ -81,13 +80,10 @@ class TIG_PostNL_Model_Admin_Logging_Handler_Postnl extends Enterprise_Logging_M
|
|
81 |
* @param Enterprise_Logging_Model_Event $eventModel
|
82 |
*
|
83 |
* @return boolean
|
84 |
-
*
|
85 |
-
* @deprecated v1.7.0
|
86 |
*/
|
87 |
-
public function postDispatchAction(
|
|
|
88 |
{
|
89 |
-
trigger_error('This method is deprecated and may be removed in the future.', E_USER_DEPRECATED);
|
90 |
-
|
91 |
return true;
|
92 |
}
|
93 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated this class is no longer used as of v1.7.0.
|
47 |
* @param Enterprise_Logging_Model_Event $eventModel
|
48 |
*
|
49 |
* @return boolean
|
|
|
|
|
50 |
*/
|
51 |
+
public function postDispatchSaveMassAction(/** @noinspection PhpUnusedParameterInspection */
|
52 |
+
$config, $eventModel)
|
53 |
{
|
|
|
|
|
54 |
$request = Mage::app()->getRequest();
|
55 |
if ($request->getParam('shipment_ids')) {
|
56 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
57 |
$eventModel->setInfo(
|
58 |
Mage::helper('enterprise_logging')->implodeValues($request->getParam('shipment_ids'))
|
59 |
);
|
62 |
}
|
63 |
|
64 |
if ($request->getParam('order_ids')) {
|
65 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
66 |
$eventModel->setInfo(
|
67 |
Mage::helper('enterprise_logging')->implodeValues($request->getParam('order_ids'))
|
68 |
);
|
80 |
* @param Enterprise_Logging_Model_Event $eventModel
|
81 |
*
|
82 |
* @return boolean
|
|
|
|
|
83 |
*/
|
84 |
+
public function postDispatchAction(/** @noinspection PhpUnusedParameterInspection */
|
85 |
+
$config, $eventModel)
|
86 |
{
|
|
|
|
|
87 |
return true;
|
88 |
}
|
89 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated this class is no longer used as of v1.7.0.
|
@@ -54,10 +54,11 @@ class TIG_PostNL_Model_Admin_Logging_Observer
|
|
54 |
*/
|
55 |
public function controllerPostdispatch(Varien_Event_Observer $observer)
|
56 |
{
|
57 |
-
trigger_error('This method is deprecated and may be removed in the future.',
|
58 |
|
|
|
59 |
$loggingObserverClassName = Mage::getConfig()->getModelClassName('enterprise_logging/observer');
|
60 |
-
$found
|
61 |
|
62 |
/**
|
63 |
* If we can't find the model, there's nothing that can be logged.
|
@@ -66,8 +67,10 @@ class TIG_PostNL_Model_Admin_Logging_Observer
|
|
66 |
return $this;
|
67 |
}
|
68 |
|
69 |
-
|
|
|
|
|
70 |
|
71 |
return $this;
|
72 |
}
|
73 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated this class is no longer used as of v1.7.0.
|
54 |
*/
|
55 |
public function controllerPostdispatch(Varien_Event_Observer $observer)
|
56 |
{
|
57 |
+
trigger_error('This method is deprecated and may be removed in the future.', E_USER_NOTICE);
|
58 |
|
59 |
+
/** @noinspection PhpParamsInspection */
|
60 |
$loggingObserverClassName = Mage::getConfig()->getModelClassName('enterprise_logging/observer');
|
61 |
+
$found = mageFindClassFile($loggingObserverClassName);
|
62 |
|
63 |
/**
|
64 |
* If we can't find the model, there's nothing that can be logged.
|
67 |
return $this;
|
68 |
}
|
69 |
|
70 |
+
/** @var Enterprise_Logging_Model_Observer $loggingObserver */
|
71 |
+
$loggingObserver = Mage::getModel('enterprise_logging/observer');
|
72 |
+
$loggingObserver->controllerPostdispatch($observer);
|
73 |
|
74 |
return $this;
|
75 |
}
|
76 |
+
}
|
@@ -33,8 +33,14 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_Form_Element_Checkbox extends Varien_Data_Form_Element_Checkbox
|
40 |
{
|
@@ -58,6 +64,7 @@ class TIG_PostNL_Model_Adminhtml_Form_Element_Checkbox extends Varien_Data_Form_
|
|
58 |
$html .= '<input id="'.$this->getHtmlId().'_checkbox" name="'.$this->getName()
|
59 |
.'_checkbox" value="'.$this->getEscapedValue().'" '.$this->serialize($this->getHtmlAttributes()).'/>'."\n";
|
60 |
|
|
|
61 |
$html .= '<script type="text/javascript">' . PHP_EOL
|
62 |
. '//<![CDATA[' . PHP_EOL
|
63 |
. '$("'.$this->getHtmlId().'_checkbox").observe("click", '
|
@@ -86,4 +93,4 @@ class TIG_PostNL_Model_Adminhtml_Form_Element_Checkbox extends Varien_Data_Form_
|
|
86 |
}
|
87 |
return $html;
|
88 |
}
|
89 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*
|
39 |
+
* @method boolean getChecked()
|
40 |
+
* @method string getLabel()
|
41 |
+
* @method boolean getRequired()
|
42 |
+
*
|
43 |
+
* @method TIG_PostNL_Model_Adminhtml_Form_Element_Checkbox setChecked($checked)
|
44 |
*/
|
45 |
class TIG_PostNL_Model_Adminhtml_Form_Element_Checkbox extends Varien_Data_Form_Element_Checkbox
|
46 |
{
|
64 |
$html .= '<input id="'.$this->getHtmlId().'_checkbox" name="'.$this->getName()
|
65 |
.'_checkbox" value="'.$this->getEscapedValue().'" '.$this->serialize($this->getHtmlAttributes()).'/>'."\n";
|
66 |
|
67 |
+
/** @noinspection JSUnresolvedVariable */
|
68 |
$html .= '<script type="text/javascript">' . PHP_EOL
|
69 |
. '//<![CDATA[' . PHP_EOL
|
70 |
. '$("'.$this->getHtmlId().'_checkbox").observe("click", '
|
93 |
}
|
94 |
return $html;
|
95 |
}
|
96 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Observer to edit the sales > order grid
|
@@ -108,6 +108,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
108 |
*
|
109 |
* Unfortunately there is no unique event for this block.
|
110 |
*/
|
|
|
111 |
$block = $observer->getBlock();
|
112 |
$orderGridClass = Mage::getConfig()->getBlockClassName(self::ORDER_GRID_BLOCK_NAME);
|
113 |
|
@@ -118,7 +119,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
118 |
/**
|
119 |
* check if the extension is active
|
120 |
*/
|
121 |
-
|
|
|
|
|
122 |
return $this;
|
123 |
}
|
124 |
|
@@ -127,6 +130,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
127 |
* @var Mage_Sales_Model_Resource_Order_Collection $currentCollection
|
128 |
*/
|
129 |
$currentCollection = $block->getCollection();
|
|
|
130 |
$select = $currentCollection->getSelect()->reset(Zend_Db_Select::WHERE);
|
131 |
|
132 |
/**
|
@@ -135,6 +139,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
135 |
*
|
136 |
* @todo see if this can be avoided in any way
|
137 |
*/
|
|
|
138 |
$collection = Mage::getResourceModel('postnl/order_grid_collection');
|
139 |
$collection->setSelect($select)
|
140 |
->setPageSize($currentCollection->getPageSize())
|
@@ -142,6 +147,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
142 |
|
143 |
$this->setCollection($collection);
|
144 |
$this->setBlock($block);
|
|
|
145 |
|
146 |
$this->_joinCollection($collection);
|
147 |
$this->_modifyColumns($block);
|
@@ -149,7 +155,6 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
149 |
$this->_applySortAndFilter();
|
150 |
$this->_addMassaction($block);
|
151 |
|
152 |
-
$block->setCollection($collection);
|
153 |
return $this;
|
154 |
}
|
155 |
|
@@ -212,6 +217,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
212 |
*/
|
213 |
protected function _joinCollection($collection)
|
214 |
{
|
|
|
215 |
$resource = Mage::getSingleton('core/resource');
|
216 |
|
217 |
/**
|
@@ -338,6 +344,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
338 |
*/
|
339 |
$incrementIdColumn = $block->getColumn('real_order_id');
|
340 |
if ($incrementIdColumn) {
|
|
|
341 |
$incrementIdColumn->setFilterIndex('main_table.increment_id');
|
342 |
}
|
343 |
|
@@ -346,6 +353,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
346 |
*/
|
347 |
$massactionColumn = $block->getColumn('massaction');
|
348 |
if ($massactionColumn) {
|
|
|
349 |
$massactionColumn->setFilterIndex('main_table.entity_id');
|
350 |
}
|
351 |
|
@@ -354,6 +362,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
354 |
*/
|
355 |
$statusColumn = $block->getColumn('status');
|
356 |
if ($statusColumn) {
|
|
|
357 |
$statusColumn->setFilterIndex('main_table.status');
|
358 |
}
|
359 |
|
@@ -362,6 +371,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
362 |
*/
|
363 |
$createdAtColumn = $block->getColumn('created_at');
|
364 |
if ($createdAtColumn) {
|
|
|
365 |
$createdAtColumn->setFilterIndex('main_table.created_at');
|
366 |
}
|
367 |
|
@@ -370,6 +380,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
370 |
*/
|
371 |
$baseGrandTotalColumn = $block->getColumn('base_grand_total');
|
372 |
if ($baseGrandTotalColumn) {
|
|
|
373 |
$baseGrandTotalColumn->setFilterIndex('main_table.base_grand_total');
|
374 |
}
|
375 |
|
@@ -378,6 +389,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
378 |
*/
|
379 |
$grandTotalColumn = $block->getColumn('grand_total');
|
380 |
if ($grandTotalColumn) {
|
|
|
381 |
$grandTotalColumn->setFilterIndex('main_table.grand_total');
|
382 |
}
|
383 |
|
@@ -386,6 +398,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
386 |
*/
|
387 |
$storeIdColumn = $block->getColumn('store_id');
|
388 |
if ($storeIdColumn) {
|
|
|
389 |
$storeIdColumn->setFilterIndex('main_table.store_id');
|
390 |
}
|
391 |
|
@@ -410,6 +423,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
410 |
*/
|
411 |
$adyenEventCodeColumn = $block->getColumn('adyen_event_code');
|
412 |
if ($adyenEventCodeColumn) {
|
|
|
413 |
$adyenEventCodeColumn->setFilterIndex('main_table.adyen_event_code');
|
414 |
}
|
415 |
|
@@ -445,7 +459,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
445 |
'avond' => $helper->__('Evening Delivery'),
|
446 |
'sunday' => $helper->__('Sunday Delivery'),
|
447 |
'monday' => $helper->__('Monday Delivery'),
|
|
|
448 |
'pakje_gemak_express' => $helper->__('Early Pickup'),
|
|
|
|
|
449 |
),
|
450 |
);
|
451 |
|
@@ -541,7 +558,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
541 |
* Decorates the confirm_sate column
|
542 |
*
|
543 |
* @param string|null $value
|
544 |
-
* @param
|
545 |
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
546 |
* @param boolean $isExport
|
547 |
*
|
@@ -555,9 +572,12 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
555 |
|
556 |
$class = $this->_getConfirmDateClass($value, $row, $column);
|
557 |
|
|
|
558 |
$origValue = $row->getData($column->getIndex());
|
559 |
|
560 |
-
|
|
|
|
|
561 |
|
562 |
$html = "<span class='{$class}' title='{$formattedDate}'><span>{$value}</span></span>";
|
563 |
return $html;
|
@@ -578,7 +598,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
578 |
return '';
|
579 |
}
|
580 |
|
|
|
581 |
$origValue = $row->getData($column->getIndex());
|
|
|
582 |
$dateModel = Mage::getModel('core/date');
|
583 |
$now = new DateTime($dateModel->gmtDate(), new DateTimeZone('UTC'));
|
584 |
|
@@ -598,6 +620,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
598 |
*/
|
599 |
$interval = $now->diff($origDate);
|
600 |
$isConfirmed = $this->_isRowConfirmed($row);
|
|
|
601 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
602 |
|
603 |
if ($isConfirmed ||
|
@@ -623,17 +646,19 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
623 |
/**
|
624 |
* Checks if the row has been fully confirmed.
|
625 |
*
|
626 |
-
* @param
|
627 |
*
|
628 |
* @return boolean
|
629 |
*/
|
630 |
protected function _isRowConfirmed($row)
|
631 |
{
|
|
|
632 |
$confirmStatus = $row->getConfirmStatus();
|
633 |
|
634 |
/**
|
635 |
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
636 |
*/
|
|
|
637 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
638 |
$statusses = explode(',', $confirmStatus);
|
639 |
foreach ($statusses as $status) {
|
@@ -665,6 +690,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
665 |
return '';
|
666 |
}
|
667 |
|
|
|
668 |
$origValues = $row->getData($column->getIndex());
|
669 |
if (!$origValues) {
|
670 |
$html = '<span class="grid-severity-minor"><span>' . $values . '</span></span>';
|
@@ -695,6 +721,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
695 |
/**
|
696 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
697 |
*/
|
|
|
698 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
699 |
|
700 |
switch ($status) {
|
@@ -734,6 +761,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
734 |
}
|
735 |
|
736 |
$html = '';
|
|
|
737 |
$shippingPhases = explode(',', $row->getData($column->getIndex()));
|
738 |
$values = explode(',', $values);
|
739 |
|
@@ -757,6 +785,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
757 |
/**
|
758 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
759 |
*/
|
|
|
760 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
761 |
|
762 |
switch ($phase) {
|
@@ -792,6 +821,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
792 |
*/
|
793 |
protected function _addMassaction($block)
|
794 |
{
|
|
|
795 |
$helper = Mage::helper('postnl');
|
796 |
|
797 |
/**
|
@@ -885,14 +915,17 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
885 |
*/
|
886 |
protected function _getCreateShipmentMassAction()
|
887 |
{
|
|
|
888 |
$helper = Mage::helper('postnl');
|
|
|
|
|
889 |
|
890 |
/**
|
891 |
* Build an array of options for the massaction item.
|
892 |
*/
|
893 |
$massActionData = array(
|
894 |
'label'=> $helper->__('PostNL - Create Shipments'),
|
895 |
-
'url' =>
|
896 |
);
|
897 |
|
898 |
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
@@ -963,6 +996,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
963 |
);
|
964 |
}
|
965 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
if (!empty($options['postnl_pg_options'])) {
|
967 |
$config['postnl_pg_options'] = array(
|
968 |
'name' => 'product_options[pg_options]',
|
@@ -972,6 +1014,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
972 |
);
|
973 |
}
|
974 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
975 |
if (!empty($options['postnl_pge_options'])) {
|
976 |
$config['postnl_pge_options'] = array(
|
977 |
'name' => 'product_options[pge_options]',
|
@@ -1035,6 +1086,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1035 |
);
|
1036 |
}
|
1037 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1038 |
if (!empty($options['postnl_pa_options'])) {
|
1039 |
$config['postnl_pa_options'] = array(
|
1040 |
'name' => 'product_options[pa_options]',
|
@@ -1071,6 +1131,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1071 |
*/
|
1072 |
protected function _getProductOptions()
|
1073 |
{
|
|
|
1074 |
$optionsModel = Mage::getModel('postnl_core/system_config_source_allProductOptions');
|
1075 |
$options = array(
|
1076 |
'postnl_domestic_options' => $optionsModel->getOptions(
|
@@ -1085,6 +1146,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1085 |
array(
|
1086 |
'group' => 'standard_options',
|
1087 |
'isCod' => false,
|
|
|
1088 |
),
|
1089 |
false,
|
1090 |
true
|
@@ -1097,6 +1159,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1097 |
false,
|
1098 |
true
|
1099 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1100 |
'postnl_pge_options' => $optionsModel->getOptions(
|
1101 |
array(
|
1102 |
'group' => 'pakjegemak_options',
|
@@ -1175,7 +1246,24 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1175 |
),
|
1176 |
false,
|
1177 |
true
|
1178 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1179 |
);
|
1180 |
|
1181 |
return $options;
|
@@ -1188,14 +1276,17 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1188 |
*/
|
1189 |
protected function _getFullPostnlFlowMassAction()
|
1190 |
{
|
|
|
1191 |
$helper = Mage::helper('postnl');
|
|
|
|
|
1192 |
|
1193 |
/**
|
1194 |
* Build an array of options for the massaction item.
|
1195 |
*/
|
1196 |
$massActionData = array(
|
1197 |
'label' => $helper->__('PostNL - Create shipments, print labels and confirm'),
|
1198 |
-
'url' =>
|
1199 |
);
|
1200 |
|
1201 |
$defaultMassAction = Mage::getStoreConfig(
|
@@ -1217,14 +1308,17 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1217 |
*/
|
1218 |
protected function _getFullPostnlFlowPackingSlipMassAction()
|
1219 |
{
|
|
|
1220 |
$helper = Mage::helper('postnl');
|
|
|
|
|
1221 |
|
1222 |
/**
|
1223 |
* Build an array of options for the massaction item.
|
1224 |
*/
|
1225 |
$massActionData = array(
|
1226 |
'label' => $helper->__('PostNL - Create shipments, print packing slips and confirm'),
|
1227 |
-
'url' =>
|
1228 |
'adminhtml/postnlAdminhtml_shipment/massFullPostnlFlowWithPackingSlip'
|
1229 |
),
|
1230 |
);
|
@@ -1248,14 +1342,17 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1248 |
*/
|
1249 |
protected function _getCreatePackingSlipMassAction()
|
1250 |
{
|
|
|
1251 |
$helper = Mage::helper('postnl');
|
|
|
|
|
1252 |
|
1253 |
/**
|
1254 |
* Build an array of options for the massaction item.
|
1255 |
*/
|
1256 |
$massActionData = array(
|
1257 |
'label' => $helper->__('PostNL - Print packing slips'),
|
1258 |
-
'url' =>
|
1259 |
);
|
1260 |
|
1261 |
$defaultMassAction = Mage::getStoreConfig(
|
@@ -1277,12 +1374,16 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1277 |
*/
|
1278 |
protected function _applySortAndFilter()
|
1279 |
{
|
|
|
|
|
|
|
1280 |
$session = Mage::getSingleton('adminhtml/session');
|
1281 |
|
1282 |
$filter = $session->getData(self::ORDER_GRID_FILTER_VAR_NAME);
|
1283 |
-
$filter =
|
1284 |
|
1285 |
if ($filter) {
|
|
|
1286 |
$this->_filterCollection($filter);
|
1287 |
}
|
1288 |
|
@@ -1309,12 +1410,14 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1309 |
$block = $this->getBlock();
|
1310 |
|
1311 |
foreach ($filter as $columnName => $value) {
|
|
|
1312 |
$column = $block->getColumn($columnName);
|
1313 |
|
1314 |
if (!$column) {
|
1315 |
continue;
|
1316 |
}
|
1317 |
|
|
|
1318 |
$column->getFilter()->setValue($value);
|
1319 |
$this->_addColumnFilterToCollection($column);
|
1320 |
}
|
@@ -1332,13 +1435,16 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1332 |
*/
|
1333 |
protected function _filterShipmentType($collection, $column)
|
1334 |
{
|
1335 |
-
|
|
|
1336 |
$filterCond = $cond['eq'];
|
1337 |
|
1338 |
/**
|
1339 |
* First filter out all non-postnl orders.
|
1340 |
*/
|
1341 |
-
|
|
|
|
|
1342 |
$postnlShippingMethodsRegex = '';
|
1343 |
foreach ($postnlShippingMethods as $method) {
|
1344 |
if ($postnlShippingMethodsRegex) {
|
@@ -1394,6 +1500,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1394 |
return $this;
|
1395 |
}
|
1396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1397 |
/**
|
1398 |
* If the filter condition is PakjeGemak, filter out all non-PakjeGemak orders
|
1399 |
*/
|
@@ -1439,7 +1554,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1439 |
* PakjeGemak Express, evening delivery and pakketautomaat shipments are also shipped to the Netherlands so we
|
1440 |
* need to explicitly filter those as well.
|
1441 |
*/
|
1442 |
-
$domesticCountry =
|
1443 |
if ($filterCond == strtolower($domesticCountry)) {
|
1444 |
$collection->addFieldToFilter('country_id', $cond);
|
1445 |
$collection->addFieldToFilter(
|
@@ -1471,7 +1586,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1471 |
* If the filter condition is EU, filter out all orders not being shipped to the EU and those being shipped to
|
1472 |
* the Netherlands
|
1473 |
*/
|
1474 |
-
$
|
|
|
|
|
1475 |
if ($filterCond == 'eu') {
|
1476 |
$collection->addFieldToFilter('country_id', array('neq' => 'NL'));
|
1477 |
$collection->addFieldToFilter('country_id', array('in', $euCountries));
|
@@ -1479,6 +1596,34 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1479 |
return $this;
|
1480 |
}
|
1481 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1482 |
/**
|
1483 |
* Lastly, filter out all orders who are being shipped to the Netherlands or other EU countries
|
1484 |
*/
|
@@ -1504,6 +1649,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1504 |
return $this;
|
1505 |
}
|
1506 |
|
|
|
1507 |
$cond = $filter->getCondition();
|
1508 |
if (!$cond) {
|
1509 |
return $this;
|
@@ -1536,13 +1682,17 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1536 |
return $this;
|
1537 |
}
|
1538 |
|
|
|
1539 |
$field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
|
|
|
1540 |
if ($column->getFilterConditionCallback()) {
|
|
|
1541 |
call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
|
1542 |
|
1543 |
return $this;
|
1544 |
}
|
1545 |
|
|
|
1546 |
$cond = $column->getFilter()->getCondition();
|
1547 |
if ($field && isset($cond)) {
|
1548 |
/**
|
@@ -1566,11 +1716,13 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1566 |
protected function _sortCollection($sort, $dir)
|
1567 |
{
|
1568 |
$block = $this->getBlock();
|
|
|
1569 |
$column = $block->getColumn($sort);
|
1570 |
if (!$column) {
|
1571 |
return $this;
|
1572 |
}
|
1573 |
|
|
|
1574 |
$column->setDir($dir);
|
1575 |
$this->_setCollectionOrder($column);
|
1576 |
|
@@ -1591,7 +1743,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
1591 |
return $this;
|
1592 |
}
|
1593 |
|
|
|
1594 |
$columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
|
|
|
1595 |
$collection->setOrder($columnIndex, strtoupper($column->getDir()));
|
1596 |
return $this;
|
1597 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Observer to edit the sales > order grid
|
108 |
*
|
109 |
* Unfortunately there is no unique event for this block.
|
110 |
*/
|
111 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
112 |
$block = $observer->getBlock();
|
113 |
$orderGridClass = Mage::getConfig()->getBlockClassName(self::ORDER_GRID_BLOCK_NAME);
|
114 |
|
119 |
/**
|
120 |
* check if the extension is active
|
121 |
*/
|
122 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
123 |
+
$helper = Mage::helper('postnl');
|
124 |
+
if (!$helper->isEnabled()) {
|
125 |
return $this;
|
126 |
}
|
127 |
|
130 |
* @var Mage_Sales_Model_Resource_Order_Collection $currentCollection
|
131 |
*/
|
132 |
$currentCollection = $block->getCollection();
|
133 |
+
/** @noinspection PhpUndefinedClassInspection */
|
134 |
$select = $currentCollection->getSelect()->reset(Zend_Db_Select::WHERE);
|
135 |
|
136 |
/**
|
139 |
*
|
140 |
* @todo see if this can be avoided in any way
|
141 |
*/
|
142 |
+
/** @var TIG_PostNL_Model_Resource_Order_Grid_Collection $collection */
|
143 |
$collection = Mage::getResourceModel('postnl/order_grid_collection');
|
144 |
$collection->setSelect($select)
|
145 |
->setPageSize($currentCollection->getPageSize())
|
147 |
|
148 |
$this->setCollection($collection);
|
149 |
$this->setBlock($block);
|
150 |
+
$block->setCollection($collection);
|
151 |
|
152 |
$this->_joinCollection($collection);
|
153 |
$this->_modifyColumns($block);
|
155 |
$this->_applySortAndFilter();
|
156 |
$this->_addMassaction($block);
|
157 |
|
|
|
158 |
return $this;
|
159 |
}
|
160 |
|
217 |
*/
|
218 |
protected function _joinCollection($collection)
|
219 |
{
|
220 |
+
/** @var Mage_Core_Model_Resource $resource */
|
221 |
$resource = Mage::getSingleton('core/resource');
|
222 |
|
223 |
/**
|
344 |
*/
|
345 |
$incrementIdColumn = $block->getColumn('real_order_id');
|
346 |
if ($incrementIdColumn) {
|
347 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
348 |
$incrementIdColumn->setFilterIndex('main_table.increment_id');
|
349 |
}
|
350 |
|
353 |
*/
|
354 |
$massactionColumn = $block->getColumn('massaction');
|
355 |
if ($massactionColumn) {
|
356 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
357 |
$massactionColumn->setFilterIndex('main_table.entity_id');
|
358 |
}
|
359 |
|
362 |
*/
|
363 |
$statusColumn = $block->getColumn('status');
|
364 |
if ($statusColumn) {
|
365 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
366 |
$statusColumn->setFilterIndex('main_table.status');
|
367 |
}
|
368 |
|
371 |
*/
|
372 |
$createdAtColumn = $block->getColumn('created_at');
|
373 |
if ($createdAtColumn) {
|
374 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
375 |
$createdAtColumn->setFilterIndex('main_table.created_at');
|
376 |
}
|
377 |
|
380 |
*/
|
381 |
$baseGrandTotalColumn = $block->getColumn('base_grand_total');
|
382 |
if ($baseGrandTotalColumn) {
|
383 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
384 |
$baseGrandTotalColumn->setFilterIndex('main_table.base_grand_total');
|
385 |
}
|
386 |
|
389 |
*/
|
390 |
$grandTotalColumn = $block->getColumn('grand_total');
|
391 |
if ($grandTotalColumn) {
|
392 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
393 |
$grandTotalColumn->setFilterIndex('main_table.grand_total');
|
394 |
}
|
395 |
|
398 |
*/
|
399 |
$storeIdColumn = $block->getColumn('store_id');
|
400 |
if ($storeIdColumn) {
|
401 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
402 |
$storeIdColumn->setFilterIndex('main_table.store_id');
|
403 |
}
|
404 |
|
423 |
*/
|
424 |
$adyenEventCodeColumn = $block->getColumn('adyen_event_code');
|
425 |
if ($adyenEventCodeColumn) {
|
426 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
427 |
$adyenEventCodeColumn->setFilterIndex('main_table.adyen_event_code');
|
428 |
}
|
429 |
|
459 |
'avond' => $helper->__('Evening Delivery'),
|
460 |
'sunday' => $helper->__('Sunday Delivery'),
|
461 |
'monday' => $helper->__('Monday Delivery'),
|
462 |
+
'sameday' => $helper->__('Same Day Delivery'),
|
463 |
'pakje_gemak_express' => $helper->__('Early Pickup'),
|
464 |
+
'food' => $helper->__('Food Delivery'),
|
465 |
+
'cooledfood' => $helper->__('Cooled Food Delivery'),
|
466 |
),
|
467 |
);
|
468 |
|
558 |
* Decorates the confirm_sate column
|
559 |
*
|
560 |
* @param string|null $value
|
561 |
+
* @param Mage_Sales_Model_Order $row
|
562 |
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
563 |
* @param boolean $isExport
|
564 |
*
|
572 |
|
573 |
$class = $this->_getConfirmDateClass($value, $row, $column);
|
574 |
|
575 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
576 |
$origValue = $row->getData($column->getIndex());
|
577 |
|
578 |
+
/** @var Mage_Core_Helper_Data $helper */
|
579 |
+
$helper = Mage::helper('core');
|
580 |
+
$formattedDate = $helper->formatDate($origValue, 'full', false);
|
581 |
|
582 |
$html = "<span class='{$class}' title='{$formattedDate}'><span>{$value}</span></span>";
|
583 |
return $html;
|
598 |
return '';
|
599 |
}
|
600 |
|
601 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
602 |
$origValue = $row->getData($column->getIndex());
|
603 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
604 |
$dateModel = Mage::getModel('core/date');
|
605 |
$now = new DateTime($dateModel->gmtDate(), new DateTimeZone('UTC'));
|
606 |
|
620 |
*/
|
621 |
$interval = $now->diff($origDate);
|
622 |
$isConfirmed = $this->_isRowConfirmed($row);
|
623 |
+
/** @noinspection PhpParamsInspection */
|
624 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
625 |
|
626 |
if ($isConfirmed ||
|
646 |
/**
|
647 |
* Checks if the row has been fully confirmed.
|
648 |
*
|
649 |
+
* @param Mage_Sales_Model_Order $row
|
650 |
*
|
651 |
* @return boolean
|
652 |
*/
|
653 |
protected function _isRowConfirmed($row)
|
654 |
{
|
655 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
656 |
$confirmStatus = $row->getConfirmStatus();
|
657 |
|
658 |
/**
|
659 |
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
660 |
*/
|
661 |
+
/** @noinspection PhpParamsInspection */
|
662 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
663 |
$statusses = explode(',', $confirmStatus);
|
664 |
foreach ($statusses as $status) {
|
690 |
return '';
|
691 |
}
|
692 |
|
693 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
694 |
$origValues = $row->getData($column->getIndex());
|
695 |
if (!$origValues) {
|
696 |
$html = '<span class="grid-severity-minor"><span>' . $values . '</span></span>';
|
721 |
/**
|
722 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
723 |
*/
|
724 |
+
/** @noinspection PhpParamsInspection */
|
725 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
726 |
|
727 |
switch ($status) {
|
761 |
}
|
762 |
|
763 |
$html = '';
|
764 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
765 |
$shippingPhases = explode(',', $row->getData($column->getIndex()));
|
766 |
$values = explode(',', $values);
|
767 |
|
785 |
/**
|
786 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
787 |
*/
|
788 |
+
/** @noinspection PhpParamsInspection */
|
789 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
790 |
|
791 |
switch ($phase) {
|
821 |
*/
|
822 |
protected function _addMassaction($block)
|
823 |
{
|
824 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
825 |
$helper = Mage::helper('postnl');
|
826 |
|
827 |
/**
|
915 |
*/
|
916 |
protected function _getCreateShipmentMassAction()
|
917 |
{
|
918 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
919 |
$helper = Mage::helper('postnl');
|
920 |
+
/** @var Mage_Adminhtml_Helper_Data $adminhtmlHelper */
|
921 |
+
$adminhtmlHelper = Mage::helper('adminhtml');
|
922 |
|
923 |
/**
|
924 |
* Build an array of options for the massaction item.
|
925 |
*/
|
926 |
$massActionData = array(
|
927 |
'label'=> $helper->__('PostNL - Create Shipments'),
|
928 |
+
'url' => $adminhtmlHelper->getUrl('adminhtml/postnlAdminhtml_shipment/massCreateShipments'),
|
929 |
);
|
930 |
|
931 |
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
996 |
);
|
997 |
}
|
998 |
|
999 |
+
if (!empty($options['postnl_sameday_options'])) {
|
1000 |
+
$config['postnl_sameday_options'] = array(
|
1001 |
+
'name' => 'product_options[sameday_options]',
|
1002 |
+
'type' => 'select',
|
1003 |
+
'label' => $optionLabel,
|
1004 |
+
'values' => $options['postnl_sameday_options'],
|
1005 |
+
);
|
1006 |
+
}
|
1007 |
+
|
1008 |
if (!empty($options['postnl_pg_options'])) {
|
1009 |
$config['postnl_pg_options'] = array(
|
1010 |
'name' => 'product_options[pg_options]',
|
1014 |
);
|
1015 |
}
|
1016 |
|
1017 |
+
if (!empty($options['postnl_pg_be_options'])) {
|
1018 |
+
$config['postnl_pg_be_options'] = array(
|
1019 |
+
'name' => 'product_options[pg_be_options]',
|
1020 |
+
'type' => 'select',
|
1021 |
+
'label' => $optionLabel,
|
1022 |
+
'values' => $options['postnl_pg_be_options'],
|
1023 |
+
);
|
1024 |
+
}
|
1025 |
+
|
1026 |
if (!empty($options['postnl_pge_options'])) {
|
1027 |
$config['postnl_pge_options'] = array(
|
1028 |
'name' => 'product_options[pge_options]',
|
1086 |
);
|
1087 |
}
|
1088 |
|
1089 |
+
if (!empty($options['postnl_sameday_cod_options'])) {
|
1090 |
+
$config['postnl_sameday_cod_options'] = array(
|
1091 |
+
'name' => 'product_options[sameday_cod_options]',
|
1092 |
+
'type' => 'select',
|
1093 |
+
'label' => $optionLabel,
|
1094 |
+
'values' => $options['postnl_sameday_cod_options'],
|
1095 |
+
);
|
1096 |
+
}
|
1097 |
+
|
1098 |
if (!empty($options['postnl_pa_options'])) {
|
1099 |
$config['postnl_pa_options'] = array(
|
1100 |
'name' => 'product_options[pa_options]',
|
1131 |
*/
|
1132 |
protected function _getProductOptions()
|
1133 |
{
|
1134 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $optionsModel */
|
1135 |
$optionsModel = Mage::getModel('postnl_core/system_config_source_allProductOptions');
|
1136 |
$options = array(
|
1137 |
'postnl_domestic_options' => $optionsModel->getOptions(
|
1146 |
array(
|
1147 |
'group' => 'standard_options',
|
1148 |
'isCod' => false,
|
1149 |
+
'isAvond' => true,
|
1150 |
),
|
1151 |
false,
|
1152 |
true
|
1159 |
false,
|
1160 |
true
|
1161 |
),
|
1162 |
+
'postnl_pg_be_options' => $optionsModel->getOptions(
|
1163 |
+
array(
|
1164 |
+
'group' => 'pakjegemak_be_options',
|
1165 |
+
'isCod' => false,
|
1166 |
+
'isBelgiumOnly' => true,
|
1167 |
+
),
|
1168 |
+
false,
|
1169 |
+
true
|
1170 |
+
),
|
1171 |
'postnl_pge_options' => $optionsModel->getOptions(
|
1172 |
array(
|
1173 |
'group' => 'pakjegemak_options',
|
1246 |
),
|
1247 |
false,
|
1248 |
true
|
1249 |
+
),
|
1250 |
+
'postnl_sameday_options' => $optionsModel->getOptions(
|
1251 |
+
array(
|
1252 |
+
'group' => 'standard_options',
|
1253 |
+
'isSameDay' => true,
|
1254 |
+
),
|
1255 |
+
false,
|
1256 |
+
true
|
1257 |
+
),
|
1258 |
+
'postnl_sameday_cod_options' => $optionsModel->getOptions(
|
1259 |
+
array(
|
1260 |
+
'group' => 'standard_options',
|
1261 |
+
'isCod' => true,
|
1262 |
+
'isSameDay' => true,
|
1263 |
+
),
|
1264 |
+
false,
|
1265 |
+
true
|
1266 |
+
),
|
1267 |
);
|
1268 |
|
1269 |
return $options;
|
1276 |
*/
|
1277 |
protected function _getFullPostnlFlowMassAction()
|
1278 |
{
|
1279 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1280 |
$helper = Mage::helper('postnl');
|
1281 |
+
/** @var Mage_Adminhtml_Helper_Data $adminhtmlHelper */
|
1282 |
+
$adminhtmlHelper = Mage::helper('adminhtml');
|
1283 |
|
1284 |
/**
|
1285 |
* Build an array of options for the massaction item.
|
1286 |
*/
|
1287 |
$massActionData = array(
|
1288 |
'label' => $helper->__('PostNL - Create shipments, print labels and confirm'),
|
1289 |
+
'url' => $adminhtmlHelper->getUrl('adminhtml/postnlAdminhtml_shipment/massFullPostnlFlow'),
|
1290 |
);
|
1291 |
|
1292 |
$defaultMassAction = Mage::getStoreConfig(
|
1308 |
*/
|
1309 |
protected function _getFullPostnlFlowPackingSlipMassAction()
|
1310 |
{
|
1311 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1312 |
$helper = Mage::helper('postnl');
|
1313 |
+
/** @var Mage_Adminhtml_Helper_Data $adminhtmlHelper */
|
1314 |
+
$adminhtmlHelper = Mage::helper('adminhtml');
|
1315 |
|
1316 |
/**
|
1317 |
* Build an array of options for the massaction item.
|
1318 |
*/
|
1319 |
$massActionData = array(
|
1320 |
'label' => $helper->__('PostNL - Create shipments, print packing slips and confirm'),
|
1321 |
+
'url' => $adminhtmlHelper->getUrl(
|
1322 |
'adminhtml/postnlAdminhtml_shipment/massFullPostnlFlowWithPackingSlip'
|
1323 |
),
|
1324 |
);
|
1342 |
*/
|
1343 |
protected function _getCreatePackingSlipMassAction()
|
1344 |
{
|
1345 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1346 |
$helper = Mage::helper('postnl');
|
1347 |
+
/** @var Mage_Adminhtml_Helper_Data $adminhtmlHelper */
|
1348 |
+
$adminhtmlHelper = Mage::helper('adminhtml');
|
1349 |
|
1350 |
/**
|
1351 |
* Build an array of options for the massaction item.
|
1352 |
*/
|
1353 |
$massActionData = array(
|
1354 |
'label' => $helper->__('PostNL - Print packing slips'),
|
1355 |
+
'url' => $adminhtmlHelper->getUrl('adminhtml/postnlAdminhtml_shipment/massPrintPackingslips'),
|
1356 |
);
|
1357 |
|
1358 |
$defaultMassAction = Mage::getStoreConfig(
|
1374 |
*/
|
1375 |
protected function _applySortAndFilter()
|
1376 |
{
|
1377 |
+
/** @var Mage_Adminhtml_Helper_Data $adminhtmlHelper */
|
1378 |
+
$adminhtmlHelper = Mage::helper('adminhtml');
|
1379 |
+
|
1380 |
$session = Mage::getSingleton('adminhtml/session');
|
1381 |
|
1382 |
$filter = $session->getData(self::ORDER_GRID_FILTER_VAR_NAME);
|
1383 |
+
$filter = $adminhtmlHelper->prepareFilterString($filter);
|
1384 |
|
1385 |
if ($filter) {
|
1386 |
+
/** @noinspection PhpParamsInspection */
|
1387 |
$this->_filterCollection($filter);
|
1388 |
}
|
1389 |
|
1410 |
$block = $this->getBlock();
|
1411 |
|
1412 |
foreach ($filter as $columnName => $value) {
|
1413 |
+
/** @var Mage_Adminhtml_Block_Widget_Grid_Column $column */
|
1414 |
$column = $block->getColumn($columnName);
|
1415 |
|
1416 |
if (!$column) {
|
1417 |
continue;
|
1418 |
}
|
1419 |
|
1420 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1421 |
$column->getFilter()->setValue($value);
|
1422 |
$this->_addColumnFilterToCollection($column);
|
1423 |
}
|
1435 |
*/
|
1436 |
protected function _filterShipmentType($collection, $column)
|
1437 |
{
|
1438 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1439 |
+
$cond = $column->getFilter()->getCondition();
|
1440 |
$filterCond = $cond['eq'];
|
1441 |
|
1442 |
/**
|
1443 |
* First filter out all non-postnl orders.
|
1444 |
*/
|
1445 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
1446 |
+
$helper = Mage::helper('postnl/carrier');
|
1447 |
+
$postnlShippingMethods = $helper->getPostnlShippingMethods();
|
1448 |
$postnlShippingMethodsRegex = '';
|
1449 |
foreach ($postnlShippingMethods as $method) {
|
1450 |
if ($postnlShippingMethodsRegex) {
|
1500 |
return $this;
|
1501 |
}
|
1502 |
|
1503 |
+
/**
|
1504 |
+
* If the filter condition is same day delivery, filter out all other orders
|
1505 |
+
*/
|
1506 |
+
if ($filterCond == 'sameday') {
|
1507 |
+
$collection->addFieldToFilter('postnl_order.type', array('eq' => 'Sameday'));
|
1508 |
+
|
1509 |
+
return $this;
|
1510 |
+
}
|
1511 |
+
|
1512 |
/**
|
1513 |
* If the filter condition is PakjeGemak, filter out all non-PakjeGemak orders
|
1514 |
*/
|
1554 |
* PakjeGemak Express, evening delivery and pakketautomaat shipments are also shipped to the Netherlands so we
|
1555 |
* need to explicitly filter those as well.
|
1556 |
*/
|
1557 |
+
$domesticCountry = $helper->getDomesticCountry();
|
1558 |
if ($filterCond == strtolower($domesticCountry)) {
|
1559 |
$collection->addFieldToFilter('country_id', $cond);
|
1560 |
$collection->addFieldToFilter(
|
1586 |
* If the filter condition is EU, filter out all orders not being shipped to the EU and those being shipped to
|
1587 |
* the Netherlands
|
1588 |
*/
|
1589 |
+
/** @var TIG_PostNL_Helper_Cif $cifHelper */
|
1590 |
+
$cifHelper = Mage::helper('postnl/cif');
|
1591 |
+
$euCountries = $cifHelper->getEuCountries();
|
1592 |
if ($filterCond == 'eu') {
|
1593 |
$collection->addFieldToFilter('country_id', array('neq' => 'NL'));
|
1594 |
$collection->addFieldToFilter('country_id', array('in', $euCountries));
|
1596 |
return $this;
|
1597 |
}
|
1598 |
|
1599 |
+
/**
|
1600 |
+
* If the filter is set to cooled food, only return postnlorders of the type 'Cooledfood'.
|
1601 |
+
*/
|
1602 |
+
if ($filterCond == 'cooledfood') {
|
1603 |
+
$collection->addFieldToFilter(
|
1604 |
+
'postnl_order.type',
|
1605 |
+
array(
|
1606 |
+
array('eq' => 'Cooledfood'),
|
1607 |
+
)
|
1608 |
+
);
|
1609 |
+
|
1610 |
+
return $this;
|
1611 |
+
}
|
1612 |
+
|
1613 |
+
/**
|
1614 |
+
* If the filter is set to food, only return postnlorders of the type 'Food'.
|
1615 |
+
*/
|
1616 |
+
if ($filterCond == 'food') {
|
1617 |
+
$collection->addFieldToFilter(
|
1618 |
+
'postnl_order.type',
|
1619 |
+
array(
|
1620 |
+
array('eq' => 'Food'),
|
1621 |
+
)
|
1622 |
+
);
|
1623 |
+
|
1624 |
+
return $this;
|
1625 |
+
}
|
1626 |
+
|
1627 |
/**
|
1628 |
* Lastly, filter out all orders who are being shipped to the Netherlands or other EU countries
|
1629 |
*/
|
1649 |
return $this;
|
1650 |
}
|
1651 |
|
1652 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1653 |
$cond = $filter->getCondition();
|
1654 |
if (!$cond) {
|
1655 |
return $this;
|
1682 |
return $this;
|
1683 |
}
|
1684 |
|
1685 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1686 |
$field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
|
1687 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1688 |
if ($column->getFilterConditionCallback()) {
|
1689 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1690 |
call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
|
1691 |
|
1692 |
return $this;
|
1693 |
}
|
1694 |
|
1695 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1696 |
$cond = $column->getFilter()->getCondition();
|
1697 |
if ($field && isset($cond)) {
|
1698 |
/**
|
1716 |
protected function _sortCollection($sort, $dir)
|
1717 |
{
|
1718 |
$block = $this->getBlock();
|
1719 |
+
/** @var Mage_Adminhtml_Block_Widget_Grid_Column $column */
|
1720 |
$column = $block->getColumn($sort);
|
1721 |
if (!$column) {
|
1722 |
return $this;
|
1723 |
}
|
1724 |
|
1725 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1726 |
$column->setDir($dir);
|
1727 |
$this->_setCollectionOrder($column);
|
1728 |
|
1743 |
return $this;
|
1744 |
}
|
1745 |
|
1746 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1747 |
$columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
|
1748 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1749 |
$collection->setOrder($columnIndex, strtoupper($column->getDir()));
|
1750 |
return $this;
|
1751 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Observer to edit the sales > shipments grid
|
@@ -145,8 +145,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
145 |
*
|
146 |
* Unfortunately there is no unique event for this block
|
147 |
*/
|
148 |
-
|
149 |
-
$
|
|
|
150 |
$postnlReturnsGridClass = Mage::getConfig()->getBlockClassName(self::POSTNL_RETURNS_GRID_CLASS_NAME);
|
151 |
|
152 |
if (!($block instanceof $shipmentGridClass) || ($block instanceof $postnlReturnsGridClass)) {
|
@@ -156,7 +157,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
156 |
/**
|
157 |
* check if the extension is active
|
158 |
*/
|
159 |
-
|
|
|
|
|
160 |
return $this;
|
161 |
}
|
162 |
|
@@ -165,12 +168,14 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
165 |
* @var Mage_Sales_Model_Resource_Order_Shipment_Collection $currentCollection
|
166 |
*/
|
167 |
$currentCollection = $block->getCollection();
|
|
|
168 |
$select = $currentCollection->getSelect()->reset(Zend_Db_Select::WHERE);
|
169 |
|
170 |
/**
|
171 |
* replace the collection as the default collection has a bug preventing it from being reset.
|
172 |
* Without being able to reset it, we can't edit it. Therefore we are forced to replace it altogether.
|
173 |
*/
|
|
|
174 |
$collection = Mage::getResourceModel('postnl/order_shipment_grid_collection');
|
175 |
$collection->setSelect($select)
|
176 |
->setPageSize($currentCollection->getPageSize())
|
@@ -178,6 +183,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
178 |
|
179 |
$this->setCollection($collection);
|
180 |
$this->setBlock($block);
|
|
|
181 |
|
182 |
$this->_joinCollection($collection);
|
183 |
$this->_modifyColumns($block);
|
@@ -185,7 +191,6 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
185 |
$this->_applySortAndFilter();
|
186 |
$this->_addMassaction($block);
|
187 |
|
188 |
-
$block->setCollection($this->getCollection());
|
189 |
return $this;
|
190 |
}
|
191 |
|
@@ -243,6 +248,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
243 |
*/
|
244 |
protected function _joinCollection($collection)
|
245 |
{
|
|
|
246 |
$resource = Mage::getSingleton('core/resource');
|
247 |
|
248 |
$select = $collection->getSelect();
|
@@ -318,12 +324,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
318 |
protected function _modifyColumns($block)
|
319 |
{
|
320 |
$incrementIdColumn = $block->getColumn('increment_id');
|
|
|
321 |
$incrementIdColumn->setFilterIndex('main_table.increment_id');
|
322 |
|
323 |
$createdAtColumn = $block->getColumn('created_at');
|
|
|
324 |
$createdAtColumn->setFilterIndex('main_table.created_at');
|
325 |
|
326 |
$massactionColumn = $block->getColumn('massaction');
|
|
|
327 |
$massactionColumn->setFilterIndex('main_table.entity_id');
|
328 |
|
329 |
return $this;
|
@@ -338,13 +347,17 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
338 |
*/
|
339 |
protected function _addColumns($block)
|
340 |
{
|
341 |
-
$helper
|
|
|
342 |
|
343 |
/**
|
344 |
* Get an array of which optional columns should be shown
|
345 |
*/
|
346 |
$columnsToDisplay = $this->getOptionalColumnsToDisplay();
|
347 |
|
|
|
|
|
|
|
348 |
/**
|
349 |
* This variable is the column ID of each column that the next column will follow.
|
350 |
* By changing this variable after each column is added we guarantee the correct
|
@@ -376,8 +389,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
376 |
'index' => 'shipping_description',
|
377 |
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_shippingDescription',
|
378 |
'column_css_class' => 'nobr',
|
379 |
-
'options' =>
|
380 |
-
->getAvailableOptions(true),
|
381 |
),
|
382 |
$after
|
383 |
);
|
@@ -413,6 +425,8 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
413 |
TIG_PostNL_Model_Core_Shipment::SHIPMENT_TYPE_PGE => $helper->__('Early Pickup'),
|
414 |
TIG_PostNL_Model_Core_Shipment::SHIPMENT_TYPE_PGE_COD => $helper->__('Early Pickup (COD)'),
|
415 |
TIG_PostNL_Model_Core_Shipment::SHIPMENT_TYPE_BUSPAKJE => $helper->__('Letter Box Parcel'),
|
|
|
|
|
416 |
),
|
417 |
),
|
418 |
$after
|
@@ -431,8 +445,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
431 |
'type' => 'options',
|
432 |
'filter_index' => 'postnl_shipment.product_code',
|
433 |
'column_css_class' => 'nobr',
|
434 |
-
'options' =>
|
435 |
-
->getAvailableOptions(true),
|
436 |
),
|
437 |
$after
|
438 |
);
|
@@ -498,6 +511,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
498 |
/**
|
499 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
500 |
*/
|
|
|
501 |
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
502 |
|
503 |
$block->addColumnAfter(
|
@@ -604,7 +618,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
604 |
'align' => 'left',
|
605 |
'index' => 'shipping_phase',
|
606 |
'type' => 'options',
|
607 |
-
'options' =>
|
608 |
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_shippingPhase',
|
609 |
'frame_callback' => array($this, 'decorateShippingPhase'),
|
610 |
),
|
@@ -622,18 +636,20 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
622 |
'align' => 'left',
|
623 |
'index' => 'return_phase',
|
624 |
'type' => 'options',
|
625 |
-
'options' =>
|
626 |
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_shippingPhase',
|
627 |
'frame_callback' => array($this, 'decorateShippingPhase'),
|
628 |
),
|
629 |
$after
|
630 |
);
|
631 |
|
|
|
632 |
$after = 'return_phase'; //Defined in case of future additions to the grid.
|
633 |
}
|
634 |
|
635 |
$actionColumn = $block->getColumn('action');
|
636 |
if ($actionColumn) {
|
|
|
637 |
$actions = $actionColumn->getActions();
|
638 |
|
639 |
if ($helper->checkIsPostnlActionAllowed('print_label')) {
|
@@ -655,6 +671,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
655 |
);
|
656 |
}
|
657 |
|
|
|
658 |
$actionColumn->setActions($actions)
|
659 |
->setWidth('150px')
|
660 |
->setData('renderer', 'postnl_adminhtml/widget_grid_column_renderer_action');
|
@@ -687,9 +704,12 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
687 |
$class = '';
|
688 |
}
|
689 |
|
|
|
690 |
$origValue = $row->getData($column->getIndex());
|
691 |
|
692 |
-
|
|
|
|
|
693 |
|
694 |
$html = "<span class='{$class}' title='{$formattedDate}'><span>{$value}</span></span>";
|
695 |
return $html;
|
@@ -706,13 +726,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
706 |
protected function _getConfirmDateClass($row, $column)
|
707 |
{
|
708 |
|
|
|
709 |
$origValue = $row->getData($column->getIndex());
|
710 |
|
711 |
if (!$origValue) {
|
712 |
return '';
|
713 |
}
|
714 |
|
715 |
-
$dateModel
|
|
|
716 |
|
717 |
/**
|
718 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
@@ -720,6 +742,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
720 |
$origDate = new DateTime($origValue, new DateTimeZone('UTC'));
|
721 |
$now = new DateTime($dateModel->gmtDate(), new DateTimeZone('UTC'));
|
722 |
$interval = $now->diff($origDate);
|
|
|
723 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
724 |
|
725 |
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED
|
@@ -765,7 +788,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
765 |
/**
|
766 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
767 |
*/
|
|
|
768 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
|
|
769 |
switch ($row->getData($column->getIndex())) {
|
770 |
case null: //rows with no value (non-PostNL shipments)
|
771 |
$class = '';
|
@@ -808,6 +833,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
808 |
return $value;
|
809 |
}
|
810 |
|
|
|
811 |
switch ($row->getData($column->getIndex())) {
|
812 |
case null: //rows with no value (non-PostNL shipments)
|
813 |
$class = '';
|
@@ -849,8 +875,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
849 |
/**
|
850 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
851 |
*/
|
|
|
852 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
853 |
|
|
|
854 |
switch ($row->getData($column->getIndex())) {
|
855 |
case null: //rows with no value (non-PostNL shipments) or unconfirmed shipments.
|
856 |
$class = '';
|
@@ -889,7 +917,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
889 |
*/
|
890 |
protected function _addMassaction($block)
|
891 |
{
|
|
|
892 |
$helper = Mage::helper('postnl/parcelware');
|
|
|
893 |
$adminhtmlHelper = Mage::helper('adminhtml');
|
894 |
|
895 |
$massactionBlock = $block->getMassactionBlock();
|
@@ -1064,9 +1094,12 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
1064 |
$session = Mage::getSingleton('adminhtml/session');
|
1065 |
|
1066 |
$filter = $session->getData(self::SHIPMENT_GRID_FILTER_VAR_NAME);
|
1067 |
-
|
|
|
|
|
1068 |
|
1069 |
if ($filter) {
|
|
|
1070 |
$this->_filterCollection($filter);
|
1071 |
}
|
1072 |
|
@@ -1093,12 +1126,14 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
1093 |
$block = $this->getBlock();
|
1094 |
|
1095 |
foreach ($filter as $columnName => $value) {
|
|
|
1096 |
$column = $block->getColumn($columnName);
|
1097 |
|
1098 |
if (!$column) {
|
1099 |
continue;
|
1100 |
}
|
1101 |
|
|
|
1102 |
$column->getFilter()->setValue($value);
|
1103 |
$this->_addColumnFilterToCollection($column);
|
1104 |
}
|
@@ -1121,13 +1156,17 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
1121 |
return $this;
|
1122 |
}
|
1123 |
|
|
|
1124 |
if ($column->getFilterConditionCallback()) {
|
|
|
1125 |
call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
|
1126 |
|
1127 |
return $this;
|
1128 |
}
|
1129 |
|
|
|
1130 |
$field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
|
|
|
1131 |
$cond = $column->getFilter()->getCondition();
|
1132 |
if ($field && isset($cond)) {
|
1133 |
$this->getCollection()->addFieldToFilter($field , $cond);
|
@@ -1153,6 +1192,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
1153 |
return $this;
|
1154 |
}
|
1155 |
|
|
|
1156 |
$column->setDir($dir);
|
1157 |
$this->_setCollectionOrder($column);
|
1158 |
|
@@ -1173,8 +1213,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
1173 |
return $this;
|
1174 |
}
|
1175 |
|
|
|
1176 |
$columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
|
1177 |
|
|
|
1178 |
$collection->setOrder($columnIndex, strtoupper($column->getDir()));
|
1179 |
return $this;
|
1180 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Observer to edit the sales > shipments grid
|
145 |
*
|
146 |
* Unfortunately there is no unique event for this block
|
147 |
*/
|
148 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
149 |
+
$block = $observer->getBlock();
|
150 |
+
$shipmentGridClass = Mage::getConfig()->getBlockClassName(self::SHIPMENT_GRID_CLASS_NAME);
|
151 |
$postnlReturnsGridClass = Mage::getConfig()->getBlockClassName(self::POSTNL_RETURNS_GRID_CLASS_NAME);
|
152 |
|
153 |
if (!($block instanceof $shipmentGridClass) || ($block instanceof $postnlReturnsGridClass)) {
|
157 |
/**
|
158 |
* check if the extension is active
|
159 |
*/
|
160 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
161 |
+
$helper = Mage::helper('postnl');
|
162 |
+
if (!$helper->isEnabled()) {
|
163 |
return $this;
|
164 |
}
|
165 |
|
168 |
* @var Mage_Sales_Model_Resource_Order_Shipment_Collection $currentCollection
|
169 |
*/
|
170 |
$currentCollection = $block->getCollection();
|
171 |
+
/** @noinspection PhpUndefinedClassInspection */
|
172 |
$select = $currentCollection->getSelect()->reset(Zend_Db_Select::WHERE);
|
173 |
|
174 |
/**
|
175 |
* replace the collection as the default collection has a bug preventing it from being reset.
|
176 |
* Without being able to reset it, we can't edit it. Therefore we are forced to replace it altogether.
|
177 |
*/
|
178 |
+
/** @var TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection */
|
179 |
$collection = Mage::getResourceModel('postnl/order_shipment_grid_collection');
|
180 |
$collection->setSelect($select)
|
181 |
->setPageSize($currentCollection->getPageSize())
|
183 |
|
184 |
$this->setCollection($collection);
|
185 |
$this->setBlock($block);
|
186 |
+
$block->setCollection($collection);
|
187 |
|
188 |
$this->_joinCollection($collection);
|
189 |
$this->_modifyColumns($block);
|
191 |
$this->_applySortAndFilter();
|
192 |
$this->_addMassaction($block);
|
193 |
|
|
|
194 |
return $this;
|
195 |
}
|
196 |
|
248 |
*/
|
249 |
protected function _joinCollection($collection)
|
250 |
{
|
251 |
+
/** @var Mage_Core_Model_Resource $resource */
|
252 |
$resource = Mage::getSingleton('core/resource');
|
253 |
|
254 |
$select = $collection->getSelect();
|
324 |
protected function _modifyColumns($block)
|
325 |
{
|
326 |
$incrementIdColumn = $block->getColumn('increment_id');
|
327 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
328 |
$incrementIdColumn->setFilterIndex('main_table.increment_id');
|
329 |
|
330 |
$createdAtColumn = $block->getColumn('created_at');
|
331 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
332 |
$createdAtColumn->setFilterIndex('main_table.created_at');
|
333 |
|
334 |
$massactionColumn = $block->getColumn('massaction');
|
335 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
336 |
$massactionColumn->setFilterIndex('main_table.entity_id');
|
337 |
|
338 |
return $this;
|
347 |
*/
|
348 |
protected function _addColumns($block)
|
349 |
{
|
350 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
351 |
+
$helper = Mage::helper('postnl/cif');
|
352 |
|
353 |
/**
|
354 |
* Get an array of which optional columns should be shown
|
355 |
*/
|
356 |
$columnsToDisplay = $this->getOptionalColumnsToDisplay();
|
357 |
|
358 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $productOptionsModel */
|
359 |
+
$productOptionsModel = Mage::getModel('postnl_core/system_config_source_allProductOptions');
|
360 |
+
|
361 |
/**
|
362 |
* This variable is the column ID of each column that the next column will follow.
|
363 |
* By changing this variable after each column is added we guarantee the correct
|
389 |
'index' => 'shipping_description',
|
390 |
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_shippingDescription',
|
391 |
'column_css_class' => 'nobr',
|
392 |
+
'options' => $productOptionsModel->getAvailableOptions(true),
|
|
|
393 |
),
|
394 |
$after
|
395 |
);
|
425 |
TIG_PostNL_Model_Core_Shipment::SHIPMENT_TYPE_PGE => $helper->__('Early Pickup'),
|
426 |
TIG_PostNL_Model_Core_Shipment::SHIPMENT_TYPE_PGE_COD => $helper->__('Early Pickup (COD)'),
|
427 |
TIG_PostNL_Model_Core_Shipment::SHIPMENT_TYPE_BUSPAKJE => $helper->__('Letter Box Parcel'),
|
428 |
+
TIG_PostNL_Model_Core_Shipment::SHIPMENT_TYPE_FOOD => $helper->__('Food Delivery'),
|
429 |
+
TIG_PostNL_Model_Core_Shipment::SHIPMENT_TYPE_COOLED => $helper->__('Cooled Food Delivery'),
|
430 |
),
|
431 |
),
|
432 |
$after
|
445 |
'type' => 'options',
|
446 |
'filter_index' => 'postnl_shipment.product_code',
|
447 |
'column_css_class' => 'nobr',
|
448 |
+
'options' => $productOptionsModel->getAvailableOptions(true),
|
|
|
449 |
),
|
450 |
$after
|
451 |
);
|
511 |
/**
|
512 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
513 |
*/
|
514 |
+
/** @noinspection PhpParamsInspection */
|
515 |
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
516 |
|
517 |
$block->addColumnAfter(
|
618 |
'align' => 'left',
|
619 |
'index' => 'shipping_phase',
|
620 |
'type' => 'options',
|
621 |
+
'options' => $helper->getShippingPhases(),
|
622 |
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_shippingPhase',
|
623 |
'frame_callback' => array($this, 'decorateShippingPhase'),
|
624 |
),
|
636 |
'align' => 'left',
|
637 |
'index' => 'return_phase',
|
638 |
'type' => 'options',
|
639 |
+
'options' => $helper->getShippingPhases(),
|
640 |
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_shippingPhase',
|
641 |
'frame_callback' => array($this, 'decorateShippingPhase'),
|
642 |
),
|
643 |
$after
|
644 |
);
|
645 |
|
646 |
+
/** @noinspection PhpUnusedLocalVariableInspection */
|
647 |
$after = 'return_phase'; //Defined in case of future additions to the grid.
|
648 |
}
|
649 |
|
650 |
$actionColumn = $block->getColumn('action');
|
651 |
if ($actionColumn) {
|
652 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
653 |
$actions = $actionColumn->getActions();
|
654 |
|
655 |
if ($helper->checkIsPostnlActionAllowed('print_label')) {
|
671 |
);
|
672 |
}
|
673 |
|
674 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
675 |
$actionColumn->setActions($actions)
|
676 |
->setWidth('150px')
|
677 |
->setData('renderer', 'postnl_adminhtml/widget_grid_column_renderer_action');
|
704 |
$class = '';
|
705 |
}
|
706 |
|
707 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
708 |
$origValue = $row->getData($column->getIndex());
|
709 |
|
710 |
+
/** @var Mage_Core_Helper_Data $helper */
|
711 |
+
$helper = Mage::helper('core');
|
712 |
+
$formattedDate = $helper->formatDate($origValue, 'full', false);
|
713 |
|
714 |
$html = "<span class='{$class}' title='{$formattedDate}'><span>{$value}</span></span>";
|
715 |
return $html;
|
726 |
protected function _getConfirmDateClass($row, $column)
|
727 |
{
|
728 |
|
729 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
730 |
$origValue = $row->getData($column->getIndex());
|
731 |
|
732 |
if (!$origValue) {
|
733 |
return '';
|
734 |
}
|
735 |
|
736 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
737 |
+
$dateModel = Mage::getSingleton('core/date');
|
738 |
|
739 |
/**
|
740 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
742 |
$origDate = new DateTime($origValue, new DateTimeZone('UTC'));
|
743 |
$now = new DateTime($dateModel->gmtDate(), new DateTimeZone('UTC'));
|
744 |
$interval = $now->diff($origDate);
|
745 |
+
/** @noinspection PhpParamsInspection */
|
746 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
747 |
|
748 |
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED
|
788 |
/**
|
789 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
790 |
*/
|
791 |
+
/** @noinspection PhpParamsInspection */
|
792 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
793 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
794 |
switch ($row->getData($column->getIndex())) {
|
795 |
case null: //rows with no value (non-PostNL shipments)
|
796 |
$class = '';
|
833 |
return $value;
|
834 |
}
|
835 |
|
836 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
837 |
switch ($row->getData($column->getIndex())) {
|
838 |
case null: //rows with no value (non-PostNL shipments)
|
839 |
$class = '';
|
875 |
/**
|
876 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
877 |
*/
|
878 |
+
/** @noinspection PhpParamsInspection */
|
879 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
880 |
|
881 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
882 |
switch ($row->getData($column->getIndex())) {
|
883 |
case null: //rows with no value (non-PostNL shipments) or unconfirmed shipments.
|
884 |
$class = '';
|
917 |
*/
|
918 |
protected function _addMassaction($block)
|
919 |
{
|
920 |
+
/** @var TIG_PostNL_Helper_Parcelware $helper */
|
921 |
$helper = Mage::helper('postnl/parcelware');
|
922 |
+
/** @var Mage_Adminhtml_Helper_Data $adminhtmlHelper */
|
923 |
$adminhtmlHelper = Mage::helper('adminhtml');
|
924 |
|
925 |
$massactionBlock = $block->getMassactionBlock();
|
1094 |
$session = Mage::getSingleton('adminhtml/session');
|
1095 |
|
1096 |
$filter = $session->getData(self::SHIPMENT_GRID_FILTER_VAR_NAME);
|
1097 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
1098 |
+
$helper = Mage::helper('adminhtml');
|
1099 |
+
$filter = $helper->prepareFilterString($filter);
|
1100 |
|
1101 |
if ($filter) {
|
1102 |
+
/** @noinspection PhpParamsInspection */
|
1103 |
$this->_filterCollection($filter);
|
1104 |
}
|
1105 |
|
1126 |
$block = $this->getBlock();
|
1127 |
|
1128 |
foreach ($filter as $columnName => $value) {
|
1129 |
+
/** @var Mage_Adminhtml_Block_Widget_Grid_Column $column */
|
1130 |
$column = $block->getColumn($columnName);
|
1131 |
|
1132 |
if (!$column) {
|
1133 |
continue;
|
1134 |
}
|
1135 |
|
1136 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1137 |
$column->getFilter()->setValue($value);
|
1138 |
$this->_addColumnFilterToCollection($column);
|
1139 |
}
|
1156 |
return $this;
|
1157 |
}
|
1158 |
|
1159 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1160 |
if ($column->getFilterConditionCallback()) {
|
1161 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1162 |
call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
|
1163 |
|
1164 |
return $this;
|
1165 |
}
|
1166 |
|
1167 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1168 |
$field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
|
1169 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1170 |
$cond = $column->getFilter()->getCondition();
|
1171 |
if ($field && isset($cond)) {
|
1172 |
$this->getCollection()->addFieldToFilter($field , $cond);
|
1192 |
return $this;
|
1193 |
}
|
1194 |
|
1195 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1196 |
$column->setDir($dir);
|
1197 |
$this->_setCollectionOrder($column);
|
1198 |
|
1213 |
return $this;
|
1214 |
}
|
1215 |
|
1216 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1217 |
$columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
|
1218 |
|
1219 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1220 |
$collection->setOrder($columnIndex, strtoupper($column->getDir()));
|
1221 |
return $this;
|
1222 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Observer to edit the shipment view
|
@@ -63,7 +63,8 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
63 |
*
|
64 |
* Unfortunately there is no unique event for this block.
|
65 |
*/
|
66 |
-
|
|
|
67 |
$shipmentViewClass = Mage::getConfig()->getBlockClassName(self::SHIPMENT_VIEW_BLOCK_NAME);
|
68 |
|
69 |
/**
|
@@ -73,7 +74,8 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
73 |
return $this;
|
74 |
}
|
75 |
|
76 |
-
$helper
|
|
|
77 |
|
78 |
/**
|
79 |
* check if the extension is active
|
@@ -88,7 +90,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
88 |
* @var Mage_Sales_Model_Order_Shipment $shipment
|
89 |
*/
|
90 |
$shipment = Mage::registry('current_shipment');
|
91 |
-
if (
|
92 |
return $this;
|
93 |
}
|
94 |
|
@@ -118,6 +120,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
118 |
public function addPostnlButtons(Mage_Adminhtml_BLock_Sales_Order_Shipment_View $block,
|
119 |
Mage_Sales_Model_Order_Shipment $shipment)
|
120 |
{
|
|
|
121 |
$helper = Mage::helper('postnl');
|
122 |
|
123 |
/**
|
@@ -146,6 +149,8 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
146 |
*/
|
147 |
if (!$postnlShipment->isConfirmed()
|
148 |
&& $postnlShipment->canConfirm()
|
|
|
|
|
149 |
&& $confirmAllowed
|
150 |
) {
|
151 |
$confirmUrl = $this->getConfirmUrl($shipment->getId());
|
@@ -200,7 +205,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
200 |
*/
|
201 |
if ($printReturnLabelAllowed
|
202 |
&& $postnlShipment->canPrintReturnLabels()
|
203 |
-
&&
|
204 |
) {
|
205 |
$printShippingLabelUrl = $this->getPrintReturnLabelUrl($shipment->getId());
|
206 |
|
@@ -242,7 +247,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
242 |
*/
|
243 |
if ($sendReturnLabelAllowed
|
244 |
&& $postnlShipment->canSendReturnLabelEmail()
|
245 |
-
&&
|
246 |
) {
|
247 |
$sendReturnLabelEmailUrl = $this->getSendReturnLabelEmailUrl($shipment->getId());
|
248 |
|
@@ -388,7 +393,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
388 |
*/
|
389 |
public function getPrintShippingLabelUrl($shipmentId)
|
390 |
{
|
391 |
-
|
|
|
|
|
392 |
'adminhtml/postnlAdminhtml_shipment/printLabel',
|
393 |
array('shipment_id' => $shipmentId)
|
394 |
);
|
@@ -405,7 +412,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
405 |
*/
|
406 |
public function getPrintReturnLabelUrl($shipmentId)
|
407 |
{
|
408 |
-
|
|
|
|
|
409 |
'adminhtml/postnlAdminhtml_shipment/printReturnLabel',
|
410 |
array('shipment_id' => $shipmentId)
|
411 |
);
|
@@ -422,7 +431,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
422 |
*/
|
423 |
public function getPrintPackingSlipUrl($shipmentId)
|
424 |
{
|
425 |
-
|
|
|
|
|
426 |
'adminhtml/postnlAdminhtml_shipment/printPackingSlip',
|
427 |
array('shipment_id' => $shipmentId)
|
428 |
);
|
@@ -439,7 +450,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
439 |
*/
|
440 |
public function getResetConfirmationUrl($shipmentId)
|
441 |
{
|
442 |
-
|
|
|
|
|
443 |
'adminhtml/postnlAdminhtml_shipment/resetConfirmation',
|
444 |
array('shipment_id' => $shipmentId)
|
445 |
);
|
@@ -456,7 +469,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
456 |
*/
|
457 |
public function getRemoveLabelsUrl($shipmentId)
|
458 |
{
|
459 |
-
|
|
|
|
|
460 |
'adminhtml/postnlAdminhtml_shipment/removeLabels',
|
461 |
array('shipment_id' => $shipmentId)
|
462 |
);
|
@@ -473,7 +488,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
473 |
*/
|
474 |
public function getResendTrackAndTraceUrl($shipmentId)
|
475 |
{
|
476 |
-
|
|
|
|
|
477 |
'adminhtml/postnlAdminhtml_shipment/sendTrackAndTrace',
|
478 |
array('shipment_id' => $shipmentId)
|
479 |
);
|
@@ -490,7 +507,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
490 |
*/
|
491 |
public function getConfirmUrl($shipmentId)
|
492 |
{
|
493 |
-
|
|
|
|
|
494 |
'adminhtml/postnlAdminhtml_shipment/confirm',
|
495 |
array(
|
496 |
'shipment_id' => $shipmentId,
|
@@ -510,7 +529,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
510 |
*/
|
511 |
public function getConvertToBuspakjeUrl($shipmentId)
|
512 |
{
|
513 |
-
|
|
|
|
|
514 |
'adminhtml/postnlAdminhtml_shipment/convertToBuspakje',
|
515 |
array(
|
516 |
'shipment_id' => $shipmentId,
|
@@ -530,7 +551,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
530 |
*/
|
531 |
public function getConvertToPackageUrl($shipmentId)
|
532 |
{
|
533 |
-
|
|
|
|
|
534 |
'adminhtml/postnlAdminhtml_shipment/convertToPackage',
|
535 |
array(
|
536 |
'shipment_id' => $shipmentId,
|
@@ -550,7 +573,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
550 |
*/
|
551 |
public function getSendReturnLabelEmailUrl($shipmentId)
|
552 |
{
|
553 |
-
|
|
|
|
|
554 |
'adminhtml/postnlAdminhtml_shipment/sendReturnLabelEmail',
|
555 |
array(
|
556 |
'shipment_id' => $shipmentId,
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Observer to edit the shipment view
|
63 |
*
|
64 |
* Unfortunately there is no unique event for this block.
|
65 |
*/
|
66 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
67 |
+
$block = $observer->getBlock();
|
68 |
$shipmentViewClass = Mage::getConfig()->getBlockClassName(self::SHIPMENT_VIEW_BLOCK_NAME);
|
69 |
|
70 |
/**
|
74 |
return $this;
|
75 |
}
|
76 |
|
77 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
78 |
+
$helper = Mage::helper('postnl/carrier');
|
79 |
|
80 |
/**
|
81 |
* check if the extension is active
|
90 |
* @var Mage_Sales_Model_Order_Shipment $shipment
|
91 |
*/
|
92 |
$shipment = Mage::registry('current_shipment');
|
93 |
+
if (!$helper->isPostnlShippingMethod($shipment->getOrder()->getShippingMethod())) {
|
94 |
return $this;
|
95 |
}
|
96 |
|
120 |
public function addPostnlButtons(Mage_Adminhtml_BLock_Sales_Order_Shipment_View $block,
|
121 |
Mage_Sales_Model_Order_Shipment $shipment)
|
122 |
{
|
123 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
124 |
$helper = Mage::helper('postnl');
|
125 |
|
126 |
/**
|
149 |
*/
|
150 |
if (!$postnlShipment->isConfirmed()
|
151 |
&& $postnlShipment->canConfirm()
|
152 |
+
&& !$postnlShipment->isGlobalShipment() //@todo remove this check once PostNl fixes the issue with
|
153 |
+
// GlobalPack confirmations
|
154 |
&& $confirmAllowed
|
155 |
) {
|
156 |
$confirmUrl = $this->getConfirmUrl($shipment->getId());
|
205 |
*/
|
206 |
if ($printReturnLabelAllowed
|
207 |
&& $postnlShipment->canPrintReturnLabels()
|
208 |
+
&& $helper->isReturnsEnabled($postnlShipment->getStoreId())
|
209 |
) {
|
210 |
$printShippingLabelUrl = $this->getPrintReturnLabelUrl($shipment->getId());
|
211 |
|
247 |
*/
|
248 |
if ($sendReturnLabelAllowed
|
249 |
&& $postnlShipment->canSendReturnLabelEmail()
|
250 |
+
&& $helper->isReturnsEnabled($postnlShipment->getStoreId())
|
251 |
) {
|
252 |
$sendReturnLabelEmailUrl = $this->getSendReturnLabelEmailUrl($shipment->getId());
|
253 |
|
393 |
*/
|
394 |
public function getPrintShippingLabelUrl($shipmentId)
|
395 |
{
|
396 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
397 |
+
$helper = Mage::helper('adminhtml');
|
398 |
+
$url = $helper->getUrl(
|
399 |
'adminhtml/postnlAdminhtml_shipment/printLabel',
|
400 |
array('shipment_id' => $shipmentId)
|
401 |
);
|
412 |
*/
|
413 |
public function getPrintReturnLabelUrl($shipmentId)
|
414 |
{
|
415 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
416 |
+
$helper = Mage::helper('adminhtml');
|
417 |
+
$url = $helper->getUrl(
|
418 |
'adminhtml/postnlAdminhtml_shipment/printReturnLabel',
|
419 |
array('shipment_id' => $shipmentId)
|
420 |
);
|
431 |
*/
|
432 |
public function getPrintPackingSlipUrl($shipmentId)
|
433 |
{
|
434 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
435 |
+
$helper = Mage::helper('adminhtml');
|
436 |
+
$url = $helper->getUrl(
|
437 |
'adminhtml/postnlAdminhtml_shipment/printPackingSlip',
|
438 |
array('shipment_id' => $shipmentId)
|
439 |
);
|
450 |
*/
|
451 |
public function getResetConfirmationUrl($shipmentId)
|
452 |
{
|
453 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
454 |
+
$helper = Mage::helper('adminhtml');
|
455 |
+
$url = $helper->getUrl(
|
456 |
'adminhtml/postnlAdminhtml_shipment/resetConfirmation',
|
457 |
array('shipment_id' => $shipmentId)
|
458 |
);
|
469 |
*/
|
470 |
public function getRemoveLabelsUrl($shipmentId)
|
471 |
{
|
472 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
473 |
+
$helper = Mage::helper('adminhtml');
|
474 |
+
$url = $helper->getUrl(
|
475 |
'adminhtml/postnlAdminhtml_shipment/removeLabels',
|
476 |
array('shipment_id' => $shipmentId)
|
477 |
);
|
488 |
*/
|
489 |
public function getResendTrackAndTraceUrl($shipmentId)
|
490 |
{
|
491 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
492 |
+
$helper = Mage::helper('adminhtml');
|
493 |
+
$url = $helper->getUrl(
|
494 |
'adminhtml/postnlAdminhtml_shipment/sendTrackAndTrace',
|
495 |
array('shipment_id' => $shipmentId)
|
496 |
);
|
507 |
*/
|
508 |
public function getConfirmUrl($shipmentId)
|
509 |
{
|
510 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
511 |
+
$helper = Mage::helper('adminhtml');
|
512 |
+
$url = $helper->getUrl(
|
513 |
'adminhtml/postnlAdminhtml_shipment/confirm',
|
514 |
array(
|
515 |
'shipment_id' => $shipmentId,
|
529 |
*/
|
530 |
public function getConvertToBuspakjeUrl($shipmentId)
|
531 |
{
|
532 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
533 |
+
$helper = Mage::helper('adminhtml');
|
534 |
+
$url = $helper->getUrl(
|
535 |
'adminhtml/postnlAdminhtml_shipment/convertToBuspakje',
|
536 |
array(
|
537 |
'shipment_id' => $shipmentId,
|
551 |
*/
|
552 |
public function getConvertToPackageUrl($shipmentId)
|
553 |
{
|
554 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
555 |
+
$helper = Mage::helper('adminhtml');
|
556 |
+
$url = $helper->getUrl(
|
557 |
'adminhtml/postnlAdminhtml_shipment/convertToPackage',
|
558 |
array(
|
559 |
'shipment_id' => $shipmentId,
|
573 |
*/
|
574 |
public function getSendReturnLabelEmailUrl($shipmentId)
|
575 |
{
|
576 |
+
/** @var Mage_Adminhtml_Helper_Data $helper */
|
577 |
+
$helper = Mage::helper('adminhtml');
|
578 |
+
$url = $helper->getUrl(
|
579 |
'adminhtml/postnlAdminhtml_shipment/sendReturnLabelEmail',
|
580 |
array(
|
581 |
'shipment_id' => $shipmentId,
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_Observer_SystemConfig
|
@@ -56,7 +56,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_SystemConfig
|
|
56 |
}
|
57 |
|
58 |
$configEditBlock = false;
|
59 |
-
|
|
|
|
|
60 |
|
61 |
/**
|
62 |
* @var Mage_Core_Block_Abstract $block
|
@@ -73,6 +75,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_SystemConfig
|
|
73 |
return $this;
|
74 |
}
|
75 |
|
|
|
76 |
$helper = Mage::helper('postnl');
|
77 |
|
78 |
if (!$helper->checkIsPostnlActionAllowed('download_logs')) {
|
@@ -99,4 +102,4 @@ class TIG_PostNL_Model_Adminhtml_Observer_SystemConfig
|
|
99 |
|
100 |
return $this;
|
101 |
}
|
102 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_Observer_SystemConfig
|
56 |
}
|
57 |
|
58 |
$configEditBlock = false;
|
59 |
+
/** @var Mage_Core_Model_Layout $layout */
|
60 |
+
$layout = Mage::getSingleton('core/layout');
|
61 |
+
$contentBlocks = $layout->getBlock('content')->getChild();
|
62 |
|
63 |
/**
|
64 |
* @var Mage_Core_Block_Abstract $block
|
75 |
return $this;
|
76 |
}
|
77 |
|
78 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
79 |
$helper = Mage::helper('postnl');
|
80 |
|
81 |
if (!$helper->checkIsPostnlActionAllowed('download_logs')) {
|
102 |
|
103 |
return $this;
|
104 |
}
|
105 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_Support_Logs
|
@@ -53,6 +53,7 @@ class TIG_PostNL_Model_Adminhtml_Support_Logs
|
|
53 |
*/
|
54 |
public function downloadLogs()
|
55 |
{
|
|
|
56 |
$helper = Mage::helper('postnl');
|
57 |
|
58 |
/**
|
@@ -70,7 +71,7 @@ class TIG_PostNL_Model_Adminhtml_Support_Logs
|
|
70 |
* Get all log files in the log folder and a list of all logs that are allowed for this download.
|
71 |
*/
|
72 |
$logs = glob($logFolder . DS . '*.log');
|
73 |
-
$allowedLogs =
|
74 |
|
75 |
/**
|
76 |
* Make sure each log is valid and put the valid logs in an array with the log's filename as the key. We need
|
@@ -150,9 +151,11 @@ class TIG_PostNL_Model_Adminhtml_Support_Logs
|
|
150 |
/**
|
151 |
* Get the path to the final zip file.
|
152 |
*/
|
|
|
|
|
153 |
$zipPath = $logFolder
|
154 |
. 'TIG_PostNL-logs-'
|
155 |
-
. date('Ymd-His',
|
156 |
. '.zip';
|
157 |
|
158 |
/**
|
@@ -175,4 +178,4 @@ class TIG_PostNL_Model_Adminhtml_Support_Logs
|
|
175 |
|
176 |
return $zipPath;
|
177 |
}
|
178 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_Support_Logs
|
53 |
*/
|
54 |
public function downloadLogs()
|
55 |
{
|
56 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
57 |
$helper = Mage::helper('postnl');
|
58 |
|
59 |
/**
|
71 |
* Get all log files in the log folder and a list of all logs that are allowed for this download.
|
72 |
*/
|
73 |
$logs = glob($logFolder . DS . '*.log');
|
74 |
+
$allowedLogs = $helper->getLogFiles();
|
75 |
|
76 |
/**
|
77 |
* Make sure each log is valid and put the valid logs in an array with the log's filename as the key. We need
|
151 |
/**
|
152 |
* Get the path to the final zip file.
|
153 |
*/
|
154 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
155 |
+
$dateModel = Mage::getSingleton('core/date');
|
156 |
$zipPath = $logFolder
|
157 |
. 'TIG_PostNL-logs-'
|
158 |
+
. date('Ymd-His', $dateModel->timestamp())
|
159 |
. '.zip';
|
160 |
|
161 |
/**
|
178 |
|
179 |
return $zipPath;
|
180 |
}
|
181 |
+
}
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Model_Adminhtml_System_Config_Form_FoodWarnings extends Mage_Core_Model_Config_Data
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Country code for the Netherlands.
|
43 |
+
*/
|
44 |
+
const COUNTRY_CODE_NL = 'NL';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* String values for the different warnings.
|
48 |
+
*/
|
49 |
+
const WARNING_DOMESTIC_COUNTRY = 'The domestic country is not set to NL. Please keep in mind that Food Delivery is only available in the Netherlands.';
|
50 |
+
const WARNING_AVAIALBLE_PRODUCT_CODES = 'You have enabled food delivery, but have not yet enabled a Food product code. Please enable a Food product code in Advanced -> User Settings.';
|
51 |
+
const WARNING_ALLOW_SPECIFIC_COUNTRIES = 'You currently selected the options to ship to multiple countries. It seems that these countries also include non-domestic countries. Please keep in mind that Food deliveries can only be shipped to the Netherlands.';
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Xpaths to allow specific/all countries for both PostNL specific config and general config.
|
55 |
+
*/
|
56 |
+
const XPATH_ALLOW_SPECIFIC_COUNTRIES = 'carriers/postnl/sallowspecific';
|
57 |
+
const XPATH_SELECT_SPECIFIC_COUNTRIES = 'carriers/postnl/specificcountry';
|
58 |
+
const XPATH_GENERAL_ALLOWED_COUNTRIES = 'general/country/allow';
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Empty array to insert warnings into.
|
62 |
+
* @var array
|
63 |
+
*/
|
64 |
+
protected $_warnings = array();
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Empty array to insert food product options into.
|
68 |
+
* @var array
|
69 |
+
*/
|
70 |
+
protected $_foodProductOptions = array();
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Empty array to insert available product options into.
|
74 |
+
* @var array
|
75 |
+
*/
|
76 |
+
protected $_availableProductOptions = array();
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Default set scope level.
|
80 |
+
* @var int
|
81 |
+
*/
|
82 |
+
protected $_scope = 0;
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @var TIG_PostNL_Helper_Data
|
86 |
+
*/
|
87 |
+
protected $_helper;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @var TIG_PostNL_Helper_CIF
|
91 |
+
*/
|
92 |
+
protected $_cifHelper;
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @var TIG_PostNL_Helper_Adminhtml
|
96 |
+
*/
|
97 |
+
protected $_adminHelper;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Constructor function which will set some values which will be needed later.
|
101 |
+
*/
|
102 |
+
protected function _construct()
|
103 |
+
{
|
104 |
+
$this->_helper = Mage::helper('postnl');
|
105 |
+
$this->_cifHelper = Mage::helper('postnl/cif');
|
106 |
+
$this->_adminHelper = Mage::helper('postnl/adminhtml');
|
107 |
+
|
108 |
+
$this->_scope = $this->_adminHelper->getCurrentScope();
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Function which will direct to the different checks which need to be executed.
|
113 |
+
*/
|
114 |
+
protected function _afterLoad()
|
115 |
+
{
|
116 |
+
parent::_afterLoad();
|
117 |
+
|
118 |
+
$this->_checkForDomesticCountry();
|
119 |
+
$this->_checkForFoodProductOptions();
|
120 |
+
$this->_checkForShippingCountries();
|
121 |
+
|
122 |
+
$this->setValue($this->_warnings);
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Adds the given warning to the _warning array property.
|
127 |
+
*
|
128 |
+
* @param string $warning
|
129 |
+
*
|
130 |
+
* @return $this
|
131 |
+
*/
|
132 |
+
protected function _addWarning($warning)
|
133 |
+
{
|
134 |
+
$this->_warnings[] = $warning;
|
135 |
+
|
136 |
+
return $this;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Checks if the current domestic country is indeed the Netherlands,
|
141 |
+
* since it is impossible to ship food outside the Netherlands.
|
142 |
+
*
|
143 |
+
* @return $this
|
144 |
+
*/
|
145 |
+
protected function _checkForDomesticCountry()
|
146 |
+
{
|
147 |
+
$domesticCountry = $this->getDomesticCountry();
|
148 |
+
|
149 |
+
if ($domesticCountry != self::COUNTRY_CODE_NL) {
|
150 |
+
$this->_addWarning(self::WARNING_DOMESTIC_COUNTRY);
|
151 |
+
}
|
152 |
+
|
153 |
+
return $this;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Checks if at least 1 food product code is available.
|
158 |
+
* If this is not the case, the PostNL shipping method cannot be shown in the checkout.
|
159 |
+
*
|
160 |
+
* @return $this
|
161 |
+
*/
|
162 |
+
protected function _checkForFoodProductOptions()
|
163 |
+
{
|
164 |
+
$foodProductOptions = $this->getFoodProductOptions();
|
165 |
+
$availableProductOptions = $this->getAvailableProductOptions();
|
166 |
+
|
167 |
+
$available = false;
|
168 |
+
|
169 |
+
foreach ($foodProductOptions as $productCode => $foodProductOption) {
|
170 |
+
if (!empty($availableProductOptions[$productCode])) {
|
171 |
+
$available = true;
|
172 |
+
break;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
if (!$available) {
|
177 |
+
$this->_addWarning(self::WARNING_AVAIALBLE_PRODUCT_CODES);
|
178 |
+
}
|
179 |
+
|
180 |
+
return $this;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Checks for the current scope if the Netherlands is the only country that can be shipped to.
|
185 |
+
* Since it is impossible to ship food deliveries outside the Netherlands, this check is built to prevent problems
|
186 |
+
* for the merchant.
|
187 |
+
*
|
188 |
+
* @return $this
|
189 |
+
*/
|
190 |
+
protected function _checkForShippingCountries()
|
191 |
+
{
|
192 |
+
$availableCountries = $this->getAllAvailableCountries();
|
193 |
+
|
194 |
+
if ($availableCountries != array(self::COUNTRY_CODE_NL)) {
|
195 |
+
$this->_addWarning(self::WARNING_ALLOW_SPECIFIC_COUNTRIES);
|
196 |
+
}
|
197 |
+
|
198 |
+
return $this;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Returns the current set Domestic country.
|
203 |
+
*
|
204 |
+
* @return string
|
205 |
+
*/
|
206 |
+
public function getDomesticCountry()
|
207 |
+
{
|
208 |
+
if (!isset($this->_domesticCountry)) {
|
209 |
+
$this->_domesticCountry = $this->_helper->getDomesticCountry();
|
210 |
+
}
|
211 |
+
|
212 |
+
return $this->_domesticCountry;
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Returns all options which are associated with food delivery.
|
217 |
+
*
|
218 |
+
* @return array
|
219 |
+
*/
|
220 |
+
public function getFoodProductOptions()
|
221 |
+
{
|
222 |
+
if (!$this->_foodProductOptions) {
|
223 |
+
$dryProductCodes = $this->_cifHelper->getFoodProductCodes();
|
224 |
+
$cooledProductCodes = $this->_cifHelper->getCooledProductCodes();
|
225 |
+
$this->_foodProductOptions = $dryProductCodes + $cooledProductCodes;
|
226 |
+
}
|
227 |
+
|
228 |
+
return $this->_foodProductOptions;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Returns all currently active product options.
|
233 |
+
*
|
234 |
+
* @return array
|
235 |
+
*/
|
236 |
+
public function getAvailableProductOptions()
|
237 |
+
{
|
238 |
+
if (!$this->_availableProductOptions) {
|
239 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $allProductOptionsModel */
|
240 |
+
$allProductOptionsModel = Mage::getModel('postnl_core/system_config_source_allProductOptions');
|
241 |
+
$this->_availableProductOptions = $allProductOptionsModel->getOptions(array(), true, true);
|
242 |
+
}
|
243 |
+
|
244 |
+
return $this->_availableProductOptions;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Returns all countries where the current scope can ship to.
|
249 |
+
*/
|
250 |
+
public function getAllAvailableCountries()
|
251 |
+
{
|
252 |
+
$postnlAllowSpecific = Mage::getStoreConfig(self::XPATH_ALLOW_SPECIFIC_COUNTRIES, $this->_scope);
|
253 |
+
if ($postnlAllowSpecific) {
|
254 |
+
$availableCountries = Mage::getStoreConfig(self::XPATH_SELECT_SPECIFIC_COUNTRIES, $this->_scope);
|
255 |
+
} else {
|
256 |
+
$availableCountries = Mage::getStoreConfig(self::XPATH_GENERAL_ALLOWED_COUNTRIES, $this->_scope);
|
257 |
+
}
|
258 |
+
|
259 |
+
return explode(',', $availableCountries);
|
260 |
+
}
|
261 |
+
|
262 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_System_Config_Source_OrderGridColumns
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_System_Config_Source_OrderGridColumns
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_System_Config_Source_OrderGridMassaction
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_System_Config_Source_OrderGridMassaction
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridColumns
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridColumns
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridMassAction
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridMassAction
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* This is a dummy class for the matrixrate export/import functionality.
|
@@ -54,4 +54,4 @@ class TIG_PostNL_Model_Carrier_Matrixrate extends Mage_Core_Model_Abstract
|
|
54 |
{
|
55 |
$this->_init('postnl_carrier/matrixrate');
|
56 |
}
|
57 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* This is a dummy class for the matrixrate export/import functionality.
|
54 |
{
|
55 |
$this->_init('postnl_carrier/matrixrate');
|
56 |
}
|
57 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* PostNL shipping method model
|
@@ -44,6 +44,8 @@
|
|
44 |
* @method TIG_PostNL_Model_Carrier_Postnl setPostnlOrder(TIG_PostNL_Model_Core_Order $value)
|
45 |
* @method boolean hasHelper()
|
46 |
* @method TIG_PostNL_Model_Carrier_Postnl setHelper(TIG_PostNL_Helper_Carrier $value)
|
|
|
|
|
47 |
*/
|
48 |
class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstract
|
49 |
implements Mage_Shipping_Model_Carrier_Interface
|
@@ -58,6 +60,21 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
58 |
*/
|
59 |
const XPATH_RATE_SOURCE = 'carriers/postnl/rate_source';
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
/**
|
62 |
* PostNL carrier code
|
63 |
*
|
@@ -82,6 +99,30 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
82 |
*/
|
83 |
protected $_conditionNames = array();
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
/**
|
86 |
* Class constructor.
|
87 |
*/
|
@@ -91,6 +132,7 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
91 |
foreach (array_keys($this->getCode('condition_name')) as $k) {
|
92 |
$this->_conditionNames[] = $k;
|
93 |
}
|
|
|
94 |
}
|
95 |
|
96 |
/**
|
@@ -104,6 +146,7 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
104 |
return $this->getData('helper');
|
105 |
}
|
106 |
|
|
|
107 |
$helper = Mage::helper('postnl/carrier');
|
108 |
|
109 |
$this->setHelper($helper);
|
@@ -134,15 +177,90 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
134 |
return false;
|
135 |
}
|
136 |
|
|
|
|
|
137 |
/**
|
138 |
* Several checks to see if shipping to the selected country is allowed based on the supported PostNL shipping
|
139 |
* products
|
140 |
*/
|
141 |
-
$countryId = $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
$helper = $this->getHelper();
|
|
|
143 |
if ($countryId) {
|
144 |
$domesticCountry = $helper->getDomesticCountry();
|
145 |
-
$
|
|
|
|
|
146 |
|
147 |
if ($countryId == $domesticCountry
|
148 |
&& !$helper->canUseStandard()
|
@@ -163,46 +281,56 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
163 |
}
|
164 |
}
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
if ($rateType == 'flat') {
|
169 |
-
$result = $this->_getFlatRate($request);
|
170 |
-
}
|
171 |
-
|
172 |
-
if ($rateType == 'table') {
|
173 |
-
$result = $this->_getTableRate($request);
|
174 |
-
}
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
}
|
186 |
-
|
187 |
-
return $result;
|
188 |
}
|
189 |
|
190 |
/**
|
191 |
-
*
|
192 |
-
*
|
193 |
-
* @return Mage_Shipping_Model_Rate_Result
|
194 |
*/
|
195 |
-
protected function
|
196 |
{
|
197 |
$freeBoxes = 0;
|
198 |
-
if ($
|
199 |
-
foreach ($
|
200 |
|
201 |
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
|
202 |
continue;
|
203 |
}
|
204 |
|
|
|
205 |
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
|
|
206 |
foreach ($item->getChildren() as $child) {
|
207 |
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
|
208 |
$freeBoxes += $item->getQty() * $child->getQty();
|
@@ -215,11 +343,10 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
215 |
}
|
216 |
$this->setFreeBoxes($freeBoxes);
|
217 |
|
218 |
-
$result = Mage::getModel('shipping/rate_result');
|
219 |
if ($this->getConfigData('type') == 'O') { // per order
|
220 |
$shippingPrice = $this->getConfigData('price');
|
221 |
} elseif ($this->getConfigData('type') == 'I') { // per item
|
222 |
-
$shippingPrice = ($
|
223 |
- ($this->getFreeBoxes() * $this->getConfigData('price'));
|
224 |
} else {
|
225 |
$shippingPrice = false;
|
@@ -228,102 +355,60 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
228 |
$shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
|
229 |
|
230 |
if ($shippingPrice !== false) {
|
|
|
231 |
$method = Mage::getModel('shipping/rate_result_method');
|
232 |
|
|
|
233 |
$method->setCarrier('postnl');
|
|
|
234 |
$method->setCarrierTitle($this->getConfigData('title'));
|
235 |
|
|
|
236 |
$method->setMethod('flatrate');
|
|
|
237 |
$method->setMethodTitle($this->getConfigData('name'));
|
238 |
|
239 |
-
if ($
|
|
|
|
|
240 |
$shippingPrice = '0.00';
|
241 |
}
|
242 |
|
243 |
$method->setPrice($shippingPrice);
|
|
|
244 |
$method->setCost($shippingPrice);
|
245 |
|
246 |
-
$result->append($method);
|
247 |
}
|
248 |
-
|
249 |
-
return $result;
|
250 |
}
|
251 |
|
252 |
/**
|
253 |
-
* @
|
254 |
-
*
|
255 |
-
* @return Mage_Shipping_Model_Rate_Result
|
256 |
*/
|
257 |
-
protected function
|
258 |
{
|
259 |
-
|
260 |
-
if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
|
261 |
-
foreach ($request->getAllItems() as $item) {
|
262 |
-
if ($item->getParentItem()) {
|
263 |
-
continue;
|
264 |
-
}
|
265 |
-
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
266 |
-
foreach ($item->getChildren() as $child) {
|
267 |
-
if ($child->getProduct()->isVirtual()) {
|
268 |
-
$request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
|
269 |
-
}
|
270 |
-
}
|
271 |
-
} elseif ($item->getProduct()->isVirtual()) {
|
272 |
-
$request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
|
273 |
-
}
|
274 |
-
}
|
275 |
-
}
|
276 |
-
|
277 |
-
// Free shipping by qty
|
278 |
-
$freeQty = 0;
|
279 |
-
$freePackageValue = false;
|
280 |
-
if ($request->getAllItems()) {
|
281 |
-
$freePackageValue = 0;
|
282 |
-
foreach ($request->getAllItems() as $item) {
|
283 |
-
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
|
284 |
-
continue;
|
285 |
-
}
|
286 |
-
|
287 |
-
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
288 |
-
foreach ($item->getChildren() as $child) {
|
289 |
-
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
|
290 |
-
$freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
|
291 |
-
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
|
292 |
-
}
|
293 |
-
}
|
294 |
-
} elseif ($item->getFreeShipping()) {
|
295 |
-
$freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
|
296 |
-
$freeQty += $item->getQty() - $freeShipping;
|
297 |
-
$freePackageValue += $item->getBaseRowTotal();
|
298 |
-
}
|
299 |
-
}
|
300 |
-
$oldValue = $request->getPackageValue();
|
301 |
-
$request->setPackageValue($oldValue - $freePackageValue);
|
302 |
-
}
|
303 |
-
|
304 |
-
if ($freePackageValue) {
|
305 |
-
$request->setPackageValue($request->getPackageValue() - $freePackageValue);
|
306 |
-
}
|
307 |
|
308 |
$conditionName = $this->getConfigData('condition_name');
|
309 |
-
$
|
310 |
|
311 |
-
|
312 |
-
$oldWeight = $
|
313 |
-
$oldQty = $
|
314 |
|
315 |
-
$
|
316 |
-
$
|
317 |
|
318 |
-
$result = Mage::getModel('shipping/rate_result');
|
319 |
-
$rate = $this->
|
320 |
|
321 |
-
$
|
322 |
-
$
|
323 |
|
|
|
324 |
$method = Mage::getModel('shipping/rate_result_method');
|
325 |
if (!empty($rate) && $rate['price'] >= 0) {
|
326 |
-
if ($
|
327 |
$shippingPrice = 0;
|
328 |
} else {
|
329 |
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
|
@@ -331,16 +416,16 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
331 |
|
332 |
$price = $shippingPrice;
|
333 |
$cost = $rate['cost'];
|
334 |
-
} elseif (empty($rate) && $
|
335 |
/**
|
336 |
* was applied promotion rule for whole cart
|
337 |
* other shipping methods could be switched off at all
|
338 |
* we must show table rate method with 0$ price, if grand_total more, than min table condition_value
|
339 |
* free setPackageWeight() has already was taken into account
|
340 |
*/
|
341 |
-
$
|
342 |
-
$
|
343 |
-
$rate = $this->getRate(
|
344 |
if (!empty($rate) && $rate['price'] >= 0) {
|
345 |
$method = Mage::getModel('shipping/rate_result_method');
|
346 |
}
|
@@ -348,206 +433,187 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
348 |
$price = 0;
|
349 |
$cost = 0;
|
350 |
} else {
|
351 |
-
$
|
352 |
-
|
353 |
-
$error->setCarrierTitle($this->getConfigData('title'));
|
354 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
355 |
-
$result->append($error);
|
356 |
-
|
357 |
-
return $result;
|
358 |
}
|
359 |
|
|
|
360 |
$method->setCarrier('postnl');
|
|
|
361 |
$method->setCarrierTitle($this->getConfigData('title'));
|
362 |
|
363 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
$method->setMethodTitle($this->getConfigData('name'));
|
365 |
|
366 |
$method->setPrice($price);
|
|
|
367 |
$method->setCost($cost);
|
368 |
|
369 |
-
$result->append($method);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
|
371 |
-
|
|
|
|
|
|
|
372 |
}
|
373 |
|
374 |
/**
|
375 |
-
*
|
376 |
-
*
|
377 |
-
* @return Mage_Shipping_Model_Rate_Result
|
378 |
*/
|
379 |
-
protected function
|
380 |
{
|
381 |
// exclude Virtual products price from Package value if pre-configured
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
if ($item->getParentItem()) {
|
388 |
-
continue;
|
389 |
-
}
|
390 |
-
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
391 |
-
foreach ($item->getChildren() as $child) {
|
392 |
-
/**
|
393 |
-
* @var Mage_Sales_Model_Quote_Item $child
|
394 |
-
*/
|
395 |
-
if ($child->getProduct()->isVirtual()) {
|
396 |
-
$request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
|
397 |
-
}
|
398 |
-
}
|
399 |
-
} elseif ($item->getProduct()->isVirtual()) {
|
400 |
-
$request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
|
401 |
-
}
|
402 |
-
}
|
403 |
}
|
404 |
|
405 |
-
|
406 |
-
|
407 |
-
$freePackageValue = false;
|
408 |
-
if ($request->getAllItems()) {
|
409 |
-
$freePackageValue = 0;
|
410 |
-
/**
|
411 |
-
* @var Mage_Sales_Model_Quote_Item $item
|
412 |
-
*/
|
413 |
-
foreach ($request->getAllItems() as $item) {
|
414 |
-
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
|
415 |
-
continue;
|
416 |
-
}
|
417 |
|
418 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
/**
|
420 |
* @var Mage_Sales_Model_Quote_Item $child
|
421 |
*/
|
422 |
-
|
423 |
-
|
424 |
-
$freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
|
425 |
-
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
|
426 |
-
}
|
427 |
}
|
428 |
-
} elseif ($item->getFreeShipping()) {
|
429 |
-
$freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
|
430 |
-
$freeQty += $item->getQty() - $freeShipping;
|
431 |
-
$freePackageValue += $item->getBaseRowTotal();
|
432 |
}
|
|
|
|
|
433 |
}
|
434 |
-
$oldValue = $request->getPackageValue();
|
435 |
-
$request->setPackageValue($oldValue - $freePackageValue);
|
436 |
-
}
|
437 |
-
|
438 |
-
if ($freePackageValue) {
|
439 |
-
$request->setPackageValue($request->getPackageValue() - $freePackageValue);
|
440 |
}
|
|
|
441 |
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
|
449 |
-
$
|
450 |
-
$
|
451 |
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
if ($request->getAllItems()) {
|
456 |
-
$item = current($request->getAllItems());
|
457 |
-
$quote = $item->getQuote();
|
458 |
|
459 |
-
|
460 |
-
|
461 |
-
$request->setParcelType('regular');
|
462 |
-
} elseif (Mage::helper('postnl')->quoteIsBuspakje($quote)) {
|
463 |
-
$request->setParcelType('letter_box');
|
464 |
-
}
|
465 |
}
|
|
|
466 |
|
467 |
-
|
468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
|
470 |
-
$
|
471 |
-
$
|
472 |
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
}
|
480 |
|
481 |
-
|
482 |
-
$
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
$
|
|
|
495 |
}
|
496 |
-
|
497 |
-
$price = 0;
|
498 |
-
$cost = 0;
|
499 |
-
} else {
|
500 |
-
$error = Mage::getModel('shipping/rate_result_error');
|
501 |
-
$error->setCarrier('postnl');
|
502 |
-
$error->setCarrierTitle($this->getConfigData('title'));
|
503 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
504 |
-
$result->append($error);
|
505 |
-
|
506 |
-
return $result;
|
507 |
}
|
508 |
|
509 |
-
$
|
510 |
-
$
|
511 |
|
512 |
-
$
|
513 |
-
$method->setMethodTitle($this->getConfigData('name'));
|
514 |
-
|
515 |
-
$method->setPrice($price);
|
516 |
-
$method->setCost($cost);
|
517 |
-
|
518 |
-
$result->append($method);
|
519 |
-
|
520 |
-
return $result;
|
521 |
}
|
522 |
|
523 |
/**
|
524 |
-
* @param Mage_Shipping_Model_Rate_Request $request
|
525 |
-
*
|
526 |
* @return array|bool
|
527 |
*/
|
528 |
-
public function getRate(
|
529 |
{
|
530 |
-
$websiteId = $
|
|
|
531 |
$website = Mage::getModel('core/website')->load($websiteId);
|
532 |
|
533 |
$rateSource = $website->getConfig(self::XPATH_RATE_SOURCE);
|
534 |
if ($rateSource == 'shipping_tablerate') {
|
535 |
-
$rate = Mage::getResourceModel('shipping/carrier_tablerate')->getRate($
|
536 |
} else {
|
537 |
-
$rate = Mage::getResourceModel('postnl_carrier/tablerate')->getRate($
|
538 |
}
|
539 |
|
540 |
return $rate;
|
541 |
}
|
542 |
|
543 |
/**
|
544 |
-
* @param Mage_Shipping_Model_Rate_Request $request
|
545 |
-
*
|
546 |
* @return array|bool
|
547 |
*/
|
548 |
-
public function getMatrixRate(
|
549 |
{
|
550 |
-
$rate = Mage::getResourceModel('postnl_carrier/matrixrate')->getRate($
|
551 |
|
552 |
return $rate;
|
553 |
}
|
@@ -625,18 +691,21 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
625 |
*/
|
626 |
public function getTrackingInfo($tracking)
|
627 |
{
|
|
|
628 |
$statusModel = Mage::getModel('shipping/tracking_result_status');
|
629 |
$track = $this->_getTrackByNumber($tracking);
|
630 |
$shipment = $track->getShipment();
|
631 |
|
632 |
$shippingAddress = $shipment->getShippingAddress();
|
633 |
-
|
|
|
634 |
$track->getTrackNumber(),
|
635 |
$shippingAddress,
|
636 |
false,
|
637 |
false
|
638 |
);
|
639 |
|
|
|
640 |
$statusModel->setCarrier($track->getCarrierCode())
|
641 |
->setCarrierTitle($this->getConfigData('name'))
|
642 |
->setTracking($track->getTrackNumber())
|
@@ -655,6 +724,7 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
655 |
*/
|
656 |
protected function _getTrackByNumber($number)
|
657 |
{
|
|
|
658 |
$coreResource = Mage::getSingleton('core/resource');
|
659 |
$readConn = $coreResource->getConnection('core_read');
|
660 |
|
@@ -668,4 +738,66 @@ class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstra
|
|
668 |
|
669 |
return $track;
|
670 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
671 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* PostNL shipping method model
|
44 |
* @method TIG_PostNL_Model_Carrier_Postnl setPostnlOrder(TIG_PostNL_Model_Core_Order $value)
|
45 |
* @method boolean hasHelper()
|
46 |
* @method TIG_PostNL_Model_Carrier_Postnl setHelper(TIG_PostNL_Helper_Carrier $value)
|
47 |
+
* @method TIG_PostNL_Model_Carrier_Postnl setFreeBoxes($freeBoxes)
|
48 |
+
* @method int getFreeBoxes()
|
49 |
*/
|
50 |
class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstract
|
51 |
implements Mage_Shipping_Model_Carrier_Interface
|
60 |
*/
|
61 |
const XPATH_RATE_SOURCE = 'carriers/postnl/rate_source';
|
62 |
|
63 |
+
/**
|
64 |
+
* String values for parcel types.
|
65 |
+
*/
|
66 |
+
const PARCEL_TYPE_REGULAR = 'regular';
|
67 |
+
const PARCEL_TYPE_LETTERBOX = 'letter_box';
|
68 |
+
const PARCEL_TYPE_FOOD = 'food';
|
69 |
+
const PARCEL_TYPE_PAKJE_GEMAK = 'pakje_gemak';
|
70 |
+
|
71 |
+
/**
|
72 |
+
* String values for different rate types.
|
73 |
+
*/
|
74 |
+
const RATE_TYPE_FLAT = 'flat';
|
75 |
+
const RATE_TYPE_TABLE = 'table';
|
76 |
+
const RATE_TYPE_MATRIX = 'matrix';
|
77 |
+
|
78 |
/**
|
79 |
* PostNL carrier code
|
80 |
*
|
99 |
*/
|
100 |
protected $_conditionNames = array();
|
101 |
|
102 |
+
/**
|
103 |
+
* @var
|
104 |
+
*/
|
105 |
+
protected $_requestItems;
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @var Mage_Shipping_Model_Rate_Request
|
109 |
+
*/
|
110 |
+
protected $_request;
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @var
|
114 |
+
*/
|
115 |
+
protected $_freePackageValue;
|
116 |
+
|
117 |
+
protected $_freeQty = 0;
|
118 |
+
|
119 |
+
protected $_rateType;
|
120 |
+
|
121 |
+
/**
|
122 |
+
* @var Mage_Shipping_Model_Rate_Result
|
123 |
+
*/
|
124 |
+
public $result;
|
125 |
+
|
126 |
/**
|
127 |
* Class constructor.
|
128 |
*/
|
132 |
foreach (array_keys($this->getCode('condition_name')) as $k) {
|
133 |
$this->_conditionNames[] = $k;
|
134 |
}
|
135 |
+
$this->result = Mage::getModel('shipping/rate_result');
|
136 |
}
|
137 |
|
138 |
/**
|
146 |
return $this->getData('helper');
|
147 |
}
|
148 |
|
149 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
150 |
$helper = Mage::helper('postnl/carrier');
|
151 |
|
152 |
$this->setHelper($helper);
|
177 |
return false;
|
178 |
}
|
179 |
|
180 |
+
$this->_request = $request;
|
181 |
+
|
182 |
/**
|
183 |
* Several checks to see if shipping to the selected country is allowed based on the supported PostNL shipping
|
184 |
* products
|
185 |
*/
|
186 |
+
$countryId = $this->_request->getDestCountryId();
|
187 |
+
|
188 |
+
if (!$this->_isShippingAllowed()) {
|
189 |
+
return false;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Find the parcel type and set this on the request object.
|
194 |
+
*/
|
195 |
+
$this->_findParcelType();
|
196 |
+
|
197 |
+
/**
|
198 |
+
* If parcel_type is food, there can be no rate shown for non-domestic shipments.
|
199 |
+
*/
|
200 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
201 |
+
if ($this->_request->getParcelType() == self::PARCEL_TYPE_FOOD && $countryId != 'NL') {
|
202 |
+
return $this->_addShippingRateNotFoundError();
|
203 |
+
}
|
204 |
+
|
205 |
+
$this->_collectRate();
|
206 |
+
|
207 |
+
return $this->result;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Collect rate based on configured rate type
|
212 |
+
*
|
213 |
+
* @throws TIG_PostNL_Exception
|
214 |
+
*/
|
215 |
+
protected function _collectRate()
|
216 |
+
{
|
217 |
+
$helper = $this->getHelper();
|
218 |
+
|
219 |
+
switch ($this->getRateType()) {
|
220 |
+
case self::RATE_TYPE_FLAT:
|
221 |
+
$this->_collectFlatRate();
|
222 |
+
break;
|
223 |
+
case self::RATE_TYPE_TABLE:
|
224 |
+
case self::RATE_TYPE_MATRIX:
|
225 |
+
$this->_collectDynamicRate();
|
226 |
+
break;
|
227 |
+
default:
|
228 |
+
throw new TIG_PostNL_Exception(
|
229 |
+
$helper->__('Invalid rate type requested: %s', $this->_rateType),
|
230 |
+
'POSTNL-0036'
|
231 |
+
);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* @return mixed
|
237 |
+
*/
|
238 |
+
public function getRateType()
|
239 |
+
{
|
240 |
+
if (isset($this->_rateType)) {
|
241 |
+
return $this->_rateType;
|
242 |
+
}
|
243 |
+
|
244 |
+
$this->_rateType = Mage::getStoreConfig(self::XPATH_RATE_TYPE, Mage::app()->getStore()->getId());
|
245 |
+
return $this->_rateType;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Several checks to see if shipping to the selected country is allowed based on the supported PostNL shipping
|
250 |
+
* products
|
251 |
+
*
|
252 |
+
* @return bool
|
253 |
+
*/
|
254 |
+
protected function _isShippingAllowed()
|
255 |
+
{
|
256 |
+
$countryId = $this->_request->getDestCountryId();
|
257 |
$helper = $this->getHelper();
|
258 |
+
|
259 |
if ($countryId) {
|
260 |
$domesticCountry = $helper->getDomesticCountry();
|
261 |
+
/** @var TIG_PostNL_Helper_Cif $cifHelper */
|
262 |
+
$cifHelper = Mage::helper('postnl/cif');
|
263 |
+
$euCountries = $cifHelper->getEuCountries();
|
264 |
|
265 |
if ($countryId == $domesticCountry
|
266 |
&& !$helper->canUseStandard()
|
281 |
}
|
282 |
}
|
283 |
|
284 |
+
return true;
|
285 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
|
287 |
+
/**
|
288 |
+
* Find the parcel type and set this on the request object.
|
289 |
+
*/
|
290 |
+
protected function _findParcelType()
|
291 |
+
{
|
292 |
+
/**
|
293 |
+
* Determine the parcel type.
|
294 |
+
*/
|
295 |
+
if ($this->getRequestItems()) {
|
296 |
+
$item = current($this->getRequestItems());
|
297 |
+
$quote = $item->getQuote();
|
298 |
|
299 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
300 |
+
$postnlOrder = Mage::getModel('postnl_core/order');
|
301 |
+
$postnlOrder = $postnlOrder->loadByQuote($quote);
|
302 |
+
if ($postnlOrder && $postnlOrder->getId() && $postnlOrder->getIsPakjeGemak()) {
|
303 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
304 |
+
$this->_request->setParcelType(self::PARCEL_TYPE_PAKJE_GEMAK);
|
305 |
+
} elseif ($this->getHelper()->quoteIsBuspakje($quote)) {
|
306 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
307 |
+
$this->_request->setParcelType(self::PARCEL_TYPE_LETTERBOX);
|
308 |
+
} elseif ($this->getHelper()->quoteIsFood()) {
|
309 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
310 |
+
$this->_request->setParcelType(self::PARCEL_TYPE_FOOD);
|
311 |
+
} else {
|
312 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
313 |
+
$this->_request->setParcelType(self::PARCEL_TYPE_REGULAR);
|
314 |
+
}
|
315 |
}
|
|
|
|
|
316 |
}
|
317 |
|
318 |
/**
|
319 |
+
* Collect shipping rates for the flat rate method.
|
|
|
|
|
320 |
*/
|
321 |
+
protected function _collectFlatRate()
|
322 |
{
|
323 |
$freeBoxes = 0;
|
324 |
+
if ($this->getRequestItems()) {
|
325 |
+
foreach ($this->getRequestItems() as $item) {
|
326 |
|
327 |
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
|
328 |
continue;
|
329 |
}
|
330 |
|
331 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
332 |
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
333 |
+
/** @var Mage_Sales_Model_Quote_Item $child */
|
334 |
foreach ($item->getChildren() as $child) {
|
335 |
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
|
336 |
$freeBoxes += $item->getQty() * $child->getQty();
|
343 |
}
|
344 |
$this->setFreeBoxes($freeBoxes);
|
345 |
|
|
|
346 |
if ($this->getConfigData('type') == 'O') { // per order
|
347 |
$shippingPrice = $this->getConfigData('price');
|
348 |
} elseif ($this->getConfigData('type') == 'I') { // per item
|
349 |
+
$shippingPrice = ($this->_request->getPackageQty() * $this->getConfigData('price'))
|
350 |
- ($this->getFreeBoxes() * $this->getConfigData('price'));
|
351 |
} else {
|
352 |
$shippingPrice = false;
|
355 |
$shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
|
356 |
|
357 |
if ($shippingPrice !== false) {
|
358 |
+
/** @var Mage_Shipping_Model_Rate_Result_Method $method */
|
359 |
$method = Mage::getModel('shipping/rate_result_method');
|
360 |
|
361 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
362 |
$method->setCarrier('postnl');
|
363 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
364 |
$method->setCarrierTitle($this->getConfigData('title'));
|
365 |
|
366 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
367 |
$method->setMethod('flatrate');
|
368 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
369 |
$method->setMethodTitle($this->getConfigData('name'));
|
370 |
|
371 |
+
if ($this->_request->getFreeShipping() === true
|
372 |
+
|| $this->_request->getPackageQty() == $this->getFreeBoxes())
|
373 |
+
{
|
374 |
$shippingPrice = '0.00';
|
375 |
}
|
376 |
|
377 |
$method->setPrice($shippingPrice);
|
378 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
379 |
$method->setCost($shippingPrice);
|
380 |
|
381 |
+
$this->result->append($method);
|
382 |
}
|
|
|
|
|
383 |
}
|
384 |
|
385 |
/**
|
386 |
+
* @throws TIG_PostNL_Exception
|
|
|
|
|
387 |
*/
|
388 |
+
protected function _collectDynamicRate()
|
389 |
{
|
390 |
+
$this->_calculatePackageValue();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
$conditionName = $this->getConfigData('condition_name');
|
393 |
+
$this->_request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
|
394 |
|
395 |
+
// Package weight and qty free shipping
|
396 |
+
$oldWeight = $this->_request->getPackageWeight();
|
397 |
+
$oldQty = $this->_request->getPackageQty();
|
398 |
|
399 |
+
$this->_request->setPackageWeight($this->_request->getFreeMethodWeight());
|
400 |
+
$this->_request->setPackageQty($oldQty - $this->_freeQty);
|
401 |
|
402 |
+
$this->result = Mage::getModel('shipping/rate_result');
|
403 |
+
$rate = $this->_getDynamicRate();
|
404 |
|
405 |
+
$this->_request->setPackageWeight($oldWeight);
|
406 |
+
$this->_request->setPackageQty($oldQty);
|
407 |
|
408 |
+
/** @var Mage_Shipping_Model_Rate_Result_Method $method */
|
409 |
$method = Mage::getModel('shipping/rate_result_method');
|
410 |
if (!empty($rate) && $rate['price'] >= 0) {
|
411 |
+
if ($this->_request->getFreeShipping() === true || ($this->_request->getPackageQty() == $this->_freeQty)) {
|
412 |
$shippingPrice = 0;
|
413 |
} else {
|
414 |
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
|
416 |
|
417 |
$price = $shippingPrice;
|
418 |
$cost = $rate['cost'];
|
419 |
+
} elseif (empty($rate) && $this->_request->getFreeShipping() === true) {
|
420 |
/**
|
421 |
* was applied promotion rule for whole cart
|
422 |
* other shipping methods could be switched off at all
|
423 |
* we must show table rate method with 0$ price, if grand_total more, than min table condition_value
|
424 |
* free setPackageWeight() has already was taken into account
|
425 |
*/
|
426 |
+
$this->_request->setPackageValue($this->_freePackageValue);
|
427 |
+
$this->_request->setPackageQty($this->_freeQty);
|
428 |
+
$rate = $this->getRate();
|
429 |
if (!empty($rate) && $rate['price'] >= 0) {
|
430 |
$method = Mage::getModel('shipping/rate_result_method');
|
431 |
}
|
433 |
$price = 0;
|
434 |
$cost = 0;
|
435 |
} else {
|
436 |
+
$this->_addShippingRateNotFoundError();
|
437 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
438 |
}
|
439 |
|
440 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
441 |
$method->setCarrier('postnl');
|
442 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
443 |
$method->setCarrierTitle($this->getConfigData('title'));
|
444 |
|
445 |
+
$carrierMethod = '';
|
446 |
+
switch ($this->getRateType()) {
|
447 |
+
case self::RATE_TYPE_MATRIX:
|
448 |
+
$carrierMethod = 'matrixrate';
|
449 |
+
break;
|
450 |
+
case self::RATE_TYPE_TABLE:
|
451 |
+
$carrierMethod = 'tablerate';
|
452 |
+
break;
|
453 |
+
}
|
454 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
455 |
+
$method->setMethod($carrierMethod);
|
456 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
457 |
$method->setMethodTitle($this->getConfigData('name'));
|
458 |
|
459 |
$method->setPrice($price);
|
460 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
461 |
$method->setCost($cost);
|
462 |
|
463 |
+
$this->result->append($method);
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* @return array|bool
|
468 |
+
* @throws TIG_PostNL_Exception
|
469 |
+
*/
|
470 |
+
protected function _getDynamicRate()
|
471 |
+
{
|
472 |
+
switch ($this->_rateType) {
|
473 |
+
case self::RATE_TYPE_TABLE:
|
474 |
+
return $this->getRate();
|
475 |
+
case self::RATE_TYPE_MATRIX:
|
476 |
+
return $this->getMatrixRate();
|
477 |
+
}
|
478 |
|
479 |
+
throw new TIG_PostNL_Exception(
|
480 |
+
$this->getHelper()->__('Invalid rate type requested: %s', $this->_rateType),
|
481 |
+
'POSTNL-0036'
|
482 |
+
);
|
483 |
}
|
484 |
|
485 |
/**
|
486 |
+
* Calculate the entire value of the package. Taking virtual items and free package value into consideration.
|
|
|
|
|
487 |
*/
|
488 |
+
protected function _calculatePackageValue()
|
489 |
{
|
490 |
// exclude Virtual products price from Package value if pre-configured
|
491 |
+
/**
|
492 |
+
*
|
493 |
+
*/
|
494 |
+
if (!$this->getConfigFlag('include_virtual_price') && $this->getRequestItems()) {
|
495 |
+
$this->_excludeVirtualItems();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
}
|
497 |
|
498 |
+
$this->_excludeFreePackageValue();
|
499 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
|
501 |
+
/**
|
502 |
+
* Virtual items should not be considered when calculating package value.
|
503 |
+
*/
|
504 |
+
protected function _excludeVirtualItems()
|
505 |
+
{
|
506 |
+
/**
|
507 |
+
* @var Mage_Sales_Model_Quote_Item $item
|
508 |
+
*/
|
509 |
+
foreach ($this->getRequestItems() as $item) {
|
510 |
+
if ($item->getParentItem()) {
|
511 |
+
continue;
|
512 |
+
}
|
513 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
514 |
+
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
515 |
+
foreach ($item->getChildren() as $child) {
|
516 |
/**
|
517 |
* @var Mage_Sales_Model_Quote_Item $child
|
518 |
*/
|
519 |
+
if ($child->getProduct()->isVirtual()) {
|
520 |
+
$this->_request->setPackageValue($this->_request->getPackageValue() - $child->getBaseRowTotal());
|
|
|
|
|
|
|
521 |
}
|
|
|
|
|
|
|
|
|
522 |
}
|
523 |
+
} elseif ($item->getProduct()->isVirtual()) {
|
524 |
+
$this->_request->setPackageValue($this->_request->getPackageValue() - $item->getBaseRowTotal());
|
525 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
526 |
}
|
527 |
+
}
|
528 |
|
529 |
+
/**
|
530 |
+
* If the request items contain free package value, substract this from the previously set package value.
|
531 |
+
*/
|
532 |
+
protected function _excludeFreePackageValue()
|
533 |
+
{
|
534 |
+
// Free shipping by qty
|
535 |
|
536 |
+
$freePackageValue = 0;
|
537 |
+
if ($this->getRequestItems()) {
|
538 |
|
539 |
+
$oldValue = $this->_request->getPackageValue();
|
540 |
+
$this->_request->setPackageValue($oldValue - $freePackageValue);
|
541 |
+
}
|
|
|
|
|
|
|
542 |
|
543 |
+
if ($freePackageValue) {
|
544 |
+
$this->_request->setPackageValue($this->_request->getPackageValue() - $freePackageValue);
|
|
|
|
|
|
|
|
|
545 |
}
|
546 |
+
}
|
547 |
|
548 |
+
/**
|
549 |
+
* @return float|int
|
550 |
+
*/
|
551 |
+
protected function _getFreePackageValue()
|
552 |
+
{
|
553 |
+
if (isset($this->_freePackageValue)) {
|
554 |
+
return $this->_freePackageValue;
|
555 |
+
}
|
556 |
|
557 |
+
$freeQty = 0;
|
558 |
+
$freePackageValue = 0;
|
559 |
|
560 |
+
/**
|
561 |
+
* @var Mage_Sales_Model_Quote_Item $item
|
562 |
+
*/
|
563 |
+
foreach ($this->getRequestItems() as $item) {
|
564 |
+
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
|
565 |
+
continue;
|
566 |
}
|
567 |
|
568 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
569 |
+
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
570 |
+
/**
|
571 |
+
* @var Mage_Sales_Model_Quote_Item $child
|
572 |
+
*/
|
573 |
+
foreach ($item->getChildren() as $child) {
|
574 |
+
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
|
575 |
+
$freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
|
576 |
+
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
|
577 |
+
}
|
578 |
+
}
|
579 |
+
} elseif ($item->getFreeShipping()) {
|
580 |
+
$freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
|
581 |
+
$freeQty += $item->getQty() - $freeShipping;
|
582 |
+
$freePackageValue += $item->getBaseRowTotal();
|
583 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
584 |
}
|
585 |
|
586 |
+
$this->_freeQty = $freeQty;
|
587 |
+
$this->_freePackageValue = $freePackageValue;
|
588 |
|
589 |
+
return $this->_freePackageValue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
590 |
}
|
591 |
|
592 |
/**
|
|
|
|
|
593 |
* @return array|bool
|
594 |
*/
|
595 |
+
public function getRate()
|
596 |
{
|
597 |
+
$websiteId = $this->_request->getWebsiteId();
|
598 |
+
/** @var Mage_Core_Model_Website $website */
|
599 |
$website = Mage::getModel('core/website')->load($websiteId);
|
600 |
|
601 |
$rateSource = $website->getConfig(self::XPATH_RATE_SOURCE);
|
602 |
if ($rateSource == 'shipping_tablerate') {
|
603 |
+
$rate = Mage::getResourceModel('shipping/carrier_tablerate')->getRate($this->_request);
|
604 |
} else {
|
605 |
+
$rate = Mage::getResourceModel('postnl_carrier/tablerate')->getRate($this->_request);
|
606 |
}
|
607 |
|
608 |
return $rate;
|
609 |
}
|
610 |
|
611 |
/**
|
|
|
|
|
612 |
* @return array|bool
|
613 |
*/
|
614 |
+
public function getMatrixRate()
|
615 |
{
|
616 |
+
$rate = Mage::getResourceModel('postnl_carrier/matrixrate')->getRate($this->_request);
|
617 |
|
618 |
return $rate;
|
619 |
}
|
691 |
*/
|
692 |
public function getTrackingInfo($tracking)
|
693 |
{
|
694 |
+
/** @var Mage_Shipping_Model_Tracking_Result_Status $statusModel */
|
695 |
$statusModel = Mage::getModel('shipping/tracking_result_status');
|
696 |
$track = $this->_getTrackByNumber($tracking);
|
697 |
$shipment = $track->getShipment();
|
698 |
|
699 |
$shippingAddress = $shipment->getShippingAddress();
|
700 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
701 |
+
$barcodeUrl = $this->getHelper()->getBarcodeUrl(
|
702 |
$track->getTrackNumber(),
|
703 |
$shippingAddress,
|
704 |
false,
|
705 |
false
|
706 |
);
|
707 |
|
708 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
709 |
$statusModel->setCarrier($track->getCarrierCode())
|
710 |
->setCarrierTitle($this->getConfigData('name'))
|
711 |
->setTracking($track->getTrackNumber())
|
724 |
*/
|
725 |
protected function _getTrackByNumber($number)
|
726 |
{
|
727 |
+
/** @var Mage_Core_Model_Resource $coreResource */
|
728 |
$coreResource = Mage::getSingleton('core/resource');
|
729 |
$readConn = $coreResource->getConnection('core_read');
|
730 |
|
738 |
|
739 |
return $track;
|
740 |
}
|
741 |
+
|
742 |
+
/**
|
743 |
+
* Adds shipping rate not found error to the given result, or instantiate empty result with error if necessary.
|
744 |
+
*
|
745 |
+
* @return false|Mage_Core_Model_Abstract|null
|
746 |
+
*/
|
747 |
+
protected function _addShippingRateNotFoundError()
|
748 |
+
{
|
749 |
+
/**
|
750 |
+
* Initiate empty result model if not already set.
|
751 |
+
*/
|
752 |
+
if (!$this->result) {
|
753 |
+
$this->result = Mage::getModel('shipping/rate_result');
|
754 |
+
}
|
755 |
+
|
756 |
+
/** @var Mage_Shipping_Model_Rate_Result_Error $error */
|
757 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
758 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
759 |
+
$error->setCarrier('postnl');
|
760 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
761 |
+
$error->setCarrierTitle($this->getConfigData('title'));
|
762 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
763 |
+
$error->setErrorMessage($this->getHelper()->__($this->_getShippingRateNotFoundErrorMessage()));
|
764 |
+
$this->result->append($error);
|
765 |
+
|
766 |
+
return $this->result;
|
767 |
+
}
|
768 |
+
|
769 |
+
/**
|
770 |
+
* @return string
|
771 |
+
*/
|
772 |
+
protected function _getShippingRateNotFoundErrorMessage()
|
773 |
+
{
|
774 |
+
if (!$this->_request) {
|
775 |
+
return $this->getConfigData('specificerrmsg');
|
776 |
+
}
|
777 |
+
|
778 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
779 |
+
$parcelType = $this->_request->getParcelType();
|
780 |
+
|
781 |
+
switch ($parcelType) {
|
782 |
+
case self::PARCEL_TYPE_FOOD:
|
783 |
+
return $this->getConfigData('foodspecificerrmsg');
|
784 |
+
default:
|
785 |
+
return $this->getConfigData('specificerrmsg');
|
786 |
+
}
|
787 |
+
}
|
788 |
+
|
789 |
+
/**
|
790 |
+
* @return Mage_Sales_Model_Quote_Item[]
|
791 |
+
*/
|
792 |
+
public function getRequestItems()
|
793 |
+
{
|
794 |
+
if ($this->_requestItems) {
|
795 |
+
return $this->_requestItems;
|
796 |
+
}
|
797 |
+
|
798 |
+
$this->_requestItems = $this->_request->getAllItems();
|
799 |
+
|
800 |
+
return $this->_requestItems;
|
801 |
+
}
|
802 |
+
|
803 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Quote_Address_Total_Shipping
|
@@ -50,6 +50,7 @@ class TIG_PostNL_Model_Carrier_Quote_Address_Total_Shipping
|
|
50 |
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
51 |
|
52 |
$address->setWeight(0);
|
|
|
53 |
$address->setFreeMethodWeight(0);
|
54 |
$this->_setAmount(0)
|
55 |
->_setBaseAmount(0);
|
@@ -66,20 +67,24 @@ class TIG_PostNL_Model_Carrier_Quote_Address_Total_Shipping
|
|
66 |
* just return the parent, because another extension might rewrite the regular total model. This way the rewrite
|
67 |
* is only ignored for PostNL shipments at a slight cost to performance (roughly 0.0005s).
|
68 |
*/
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
|
73 |
$freeAddress= $address->getFreeShipping();
|
74 |
|
75 |
$addressWeight = $address->getWeight();
|
|
|
76 |
$freeMethodWeight = $address->getFreeMethodWeight();
|
77 |
|
78 |
$addressQty = 0;
|
79 |
|
80 |
/**
|
81 |
* @var Mage_Sales_Model_Quote_Item $item
|
82 |
-
* @var Mage_Sales_Model_Quote_Item $child
|
83 |
*/
|
84 |
foreach ($items as $item) {
|
85 |
/**
|
@@ -96,13 +101,16 @@ class TIG_PostNL_Model_Carrier_Quote_Address_Total_Shipping
|
|
96 |
continue;
|
97 |
}
|
98 |
|
|
|
99 |
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
|
|
100 |
foreach ($item->getChildren() as $child) {
|
101 |
if ($child->getProduct()->isVirtual()) {
|
102 |
continue;
|
103 |
}
|
104 |
$addressQty += $child->getTotalQty();
|
105 |
|
|
|
106 |
if (!$item->getProduct()->getWeightType()) {
|
107 |
$itemWeight = $child->getWeight();
|
108 |
$itemQty = $child->getTotalQty();
|
@@ -123,6 +131,7 @@ class TIG_PostNL_Model_Carrier_Quote_Address_Total_Shipping
|
|
123 |
$item->setRowWeight($rowWeight);
|
124 |
}
|
125 |
}
|
|
|
126 |
if ($item->getProduct()->getWeightType()) {
|
127 |
$itemWeight = $item->getWeight();
|
128 |
$rowWeight = $itemWeight*$item->getQty();
|
@@ -166,10 +175,12 @@ class TIG_PostNL_Model_Carrier_Quote_Address_Total_Shipping
|
|
166 |
}
|
167 |
|
168 |
if (isset($addressQty)) {
|
|
|
169 |
$address->setItemQty($addressQty);
|
170 |
}
|
171 |
|
172 |
$address->setWeight($addressWeight);
|
|
|
173 |
$address->setFreeMethodWeight($freeMethodWeight);
|
174 |
|
175 |
$address->collectShippingRates();
|
@@ -201,7 +212,9 @@ class TIG_PostNL_Model_Carrier_Quote_Address_Total_Shipping
|
|
201 |
$price = $rate->getPrice();
|
202 |
|
203 |
$includingTax = false;
|
204 |
-
|
|
|
|
|
205 |
$includingTax = true;
|
206 |
}
|
207 |
|
@@ -213,8 +226,10 @@ class TIG_PostNL_Model_Carrier_Quote_Address_Total_Shipping
|
|
213 |
$fee = $helper->getExpressFee(false, $includingTax, false);
|
214 |
} elseif ($type == 'Avond' ) {
|
215 |
$fee = $helper->getEveningFee(false, $includingTax, false);
|
216 |
-
} elseif ($type ==
|
217 |
$fee = $helper->getSundayFee(false, $includingTax, false);
|
|
|
|
|
218 |
}
|
219 |
|
220 |
$fee += $helper->getOptionsFee($postnlOrder, false, $includingTax, false);
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Quote_Address_Total_Shipping
|
50 |
Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
|
51 |
|
52 |
$address->setWeight(0);
|
53 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
54 |
$address->setFreeMethodWeight(0);
|
55 |
$this->_setAmount(0)
|
56 |
->_setBaseAmount(0);
|
67 |
* just return the parent, because another extension might rewrite the regular total model. This way the rewrite
|
68 |
* is only ignored for PostNL shipments at a slight cost to performance (roughly 0.0005s).
|
69 |
*/
|
70 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
71 |
+
$helper = Mage::helper('postnl/carrier');
|
72 |
+
if (!$helper->isPostnlShippingMethod($method)) {
|
73 |
+
/** @var Mage_Sales_Model_Quote_Address_Total_Shipping $totalModel */
|
74 |
+
$totalModel = Mage::getModel('sales/quote_address_total_shipping');
|
75 |
+
return $totalModel->collect($address);
|
76 |
}
|
77 |
|
78 |
$freeAddress= $address->getFreeShipping();
|
79 |
|
80 |
$addressWeight = $address->getWeight();
|
81 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
82 |
$freeMethodWeight = $address->getFreeMethodWeight();
|
83 |
|
84 |
$addressQty = 0;
|
85 |
|
86 |
/**
|
87 |
* @var Mage_Sales_Model_Quote_Item $item
|
|
|
88 |
*/
|
89 |
foreach ($items as $item) {
|
90 |
/**
|
101 |
continue;
|
102 |
}
|
103 |
|
104 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
105 |
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
106 |
+
/** @var Mage_Sales_Model_Quote_Item $child */
|
107 |
foreach ($item->getChildren() as $child) {
|
108 |
if ($child->getProduct()->isVirtual()) {
|
109 |
continue;
|
110 |
}
|
111 |
$addressQty += $child->getTotalQty();
|
112 |
|
113 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
114 |
if (!$item->getProduct()->getWeightType()) {
|
115 |
$itemWeight = $child->getWeight();
|
116 |
$itemQty = $child->getTotalQty();
|
131 |
$item->setRowWeight($rowWeight);
|
132 |
}
|
133 |
}
|
134 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
135 |
if ($item->getProduct()->getWeightType()) {
|
136 |
$itemWeight = $item->getWeight();
|
137 |
$rowWeight = $itemWeight*$item->getQty();
|
175 |
}
|
176 |
|
177 |
if (isset($addressQty)) {
|
178 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
179 |
$address->setItemQty($addressQty);
|
180 |
}
|
181 |
|
182 |
$address->setWeight($addressWeight);
|
183 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
184 |
$address->setFreeMethodWeight($freeMethodWeight);
|
185 |
|
186 |
$address->collectShippingRates();
|
212 |
$price = $rate->getPrice();
|
213 |
|
214 |
$includingTax = false;
|
215 |
+
/** @var Mage_Tax_Model_Config $taxConfig */
|
216 |
+
$taxConfig = Mage::getSingleton('tax/config');
|
217 |
+
if ($taxConfig->shippingPriceIncludesTax()) {
|
218 |
$includingTax = true;
|
219 |
}
|
220 |
|
226 |
$fee = $helper->getExpressFee(false, $includingTax, false);
|
227 |
} elseif ($type == 'Avond' ) {
|
228 |
$fee = $helper->getEveningFee(false, $includingTax, false);
|
229 |
+
} elseif ($type == $helper::FEE_TYPE_SUNDAY ) {
|
230 |
$fee = $helper->getSundayFee(false, $includingTax, false);
|
231 |
+
} elseif ($type == $helper::FEE_TYPE_SAMEDAY ) {
|
232 |
+
$fee = $helper->getSameDayFee(false, $includingTax, false);
|
233 |
}
|
234 |
|
235 |
$fee += $helper->getOptionsFee($postnlOrder, false, $includingTax, false);
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_Resource_Carrier_Tablerate
|
@@ -62,11 +62,12 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_R
|
|
62 |
/**
|
63 |
* Get the bound values for the select conditions.
|
64 |
*/
|
|
|
65 |
$bind = array(
|
66 |
':website_id' => (int) $request->getWebsiteId(),
|
67 |
':country_id' => "%{$request->getDestCountryId()}%",
|
68 |
':region_id' => (int) $request->getDestRegionId(),
|
69 |
-
':postcode' => $request->getDestPostcode(),
|
70 |
':weight' => $request->getPackageWeight(),
|
71 |
':subtotal' => $request->getBaseSubtotalInclTax(),
|
72 |
':qty' => $request->getPackageQty(),
|
@@ -94,6 +95,16 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_R
|
|
94 |
->order(
|
95 |
array(
|
96 |
'website_id DESC',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
'parcel_type DESC',
|
98 |
'dest_country_id DESC',
|
99 |
'dest_region_id DESC',
|
@@ -136,7 +147,17 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_R
|
|
136 |
$select->where('weight <= :weight');
|
137 |
$select->where('subtotal <= :subtotal');
|
138 |
$select->where('qty <= :qty');
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
$result = $adapter->fetchRow($select, $bind);
|
142 |
|
@@ -172,6 +193,7 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_R
|
|
172 |
}
|
173 |
|
174 |
$csvFile = $_FILES['groups']['tmp_name']['postnl']['fields']['matrix_import']['value'];
|
|
|
175 |
$website = Mage::app()->getWebsite($object->getScopeId());
|
176 |
|
177 |
$this->_importWebsiteId = (int)$website->getId();
|
@@ -237,9 +259,11 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_R
|
|
237 |
$adapter->rollback();
|
238 |
$io->streamClose();
|
239 |
|
240 |
-
|
|
|
|
|
241 |
throw new TIG_PostNL_Exception(
|
242 |
-
|
243 |
'POSTNL-0195'
|
244 |
);
|
245 |
}
|
@@ -310,9 +334,11 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_R
|
|
310 |
} catch (Exception $e) {
|
311 |
$adapter->rollback();
|
312 |
|
313 |
-
|
|
|
|
|
314 |
throw new TIG_PostNL_Exception(
|
315 |
-
|
316 |
'POSTNL-0195'
|
317 |
);
|
318 |
}
|
@@ -439,7 +465,9 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_R
|
|
439 |
$allowedParcelTypes = array(
|
440 |
'*',
|
441 |
'letter_box',
|
442 |
-
'regular'
|
|
|
|
|
443 |
);
|
444 |
|
445 |
$this->_importErrors[] = Mage::helper('postnl')->__(
|
@@ -562,14 +590,14 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_R
|
|
562 |
case '*':
|
563 |
$formattedType = '*';
|
564 |
break;
|
565 |
-
case 'letter_box':
|
566 |
-
case 'letterbox':
|
567 |
-
case 'buspakje':
|
568 |
-
case 'bus_pakje':
|
569 |
-
case 'brievenbuspakje':
|
570 |
-
case 'brievenbus pakje':
|
571 |
-
case 'letterboxparcel':
|
572 |
-
case 'letter box parcel':
|
573 |
$formattedType = 'letter_box';
|
574 |
break;
|
575 |
case 'regular': //no break
|
@@ -580,9 +608,24 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_R
|
|
580 |
case 'package':
|
581 |
$formattedType = 'regular';
|
582 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
583 |
//no default
|
584 |
}
|
585 |
|
586 |
return $formattedType;
|
587 |
}
|
588 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Resource_Matrixrate extends Mage_Shipping_Model_Resource_Carrier_Tablerate
|
62 |
/**
|
63 |
* Get the bound values for the select conditions.
|
64 |
*/
|
65 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
66 |
$bind = array(
|
67 |
':website_id' => (int) $request->getWebsiteId(),
|
68 |
':country_id' => "%{$request->getDestCountryId()}%",
|
69 |
':region_id' => (int) $request->getDestRegionId(),
|
70 |
+
':postcode' => str_replace(' ', '', $request->getDestPostcode()),
|
71 |
':weight' => $request->getPackageWeight(),
|
72 |
':subtotal' => $request->getBaseSubtotalInclTax(),
|
73 |
':qty' => $request->getPackageQty(),
|
95 |
->order(
|
96 |
array(
|
97 |
'website_id DESC',
|
98 |
+
new Zend_Db_Expr(
|
99 |
+
"(CASE parcel_type" .
|
100 |
+
" WHEN 'letter_box' THEN 1" .
|
101 |
+
" WHEN 'pakje_gemak' THEN 2" .
|
102 |
+
" WHEN 'food' THEN 3" .
|
103 |
+
" WHEN 'regular' THEN 4" .
|
104 |
+
" WHEN '*' THEN 5" .
|
105 |
+
" ELSE 100" .
|
106 |
+
" END) ASC"
|
107 |
+
),
|
108 |
'parcel_type DESC',
|
109 |
'dest_country_id DESC',
|
110 |
'dest_region_id DESC',
|
147 |
$select->where('weight <= :weight');
|
148 |
$select->where('subtotal <= :subtotal');
|
149 |
$select->where('qty <= :qty');
|
150 |
+
|
151 |
+
$parcelTypeWhereClause = "(parcel_type = :parcel_type)";
|
152 |
+
if ($parcelType == 'pakje_gemak') {
|
153 |
+
$parcelTypeWhereClause .= " OR (parcel_type = 'regular')";
|
154 |
+
}
|
155 |
+
|
156 |
+
if ($parcelType != 'food') {
|
157 |
+
$parcelTypeWhereClause .= " OR (parcel_type = '*')";
|
158 |
+
}
|
159 |
+
|
160 |
+
$select->where($parcelTypeWhereClause);
|
161 |
|
162 |
$result = $adapter->fetchRow($select, $bind);
|
163 |
|
193 |
}
|
194 |
|
195 |
$csvFile = $_FILES['groups']['tmp_name']['postnl']['fields']['matrix_import']['value'];
|
196 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
197 |
$website = Mage::app()->getWebsite($object->getScopeId());
|
198 |
|
199 |
$this->_importWebsiteId = (int)$website->getId();
|
259 |
$adapter->rollback();
|
260 |
$io->streamClose();
|
261 |
|
262 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
263 |
+
$helper = Mage::helper('postnl');
|
264 |
+
$helper->logException($e);
|
265 |
throw new TIG_PostNL_Exception(
|
266 |
+
$helper->__('An error occurred while importing the matrix rates.'),
|
267 |
'POSTNL-0195'
|
268 |
);
|
269 |
}
|
334 |
} catch (Exception $e) {
|
335 |
$adapter->rollback();
|
336 |
|
337 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
338 |
+
$helper = Mage::helper('postnl');
|
339 |
+
$helper->logException($e);
|
340 |
throw new TIG_PostNL_Exception(
|
341 |
+
$helper->__('An error occurred while importing the matrix rates.'),
|
342 |
'POSTNL-0195'
|
343 |
);
|
344 |
}
|
465 |
$allowedParcelTypes = array(
|
466 |
'*',
|
467 |
'letter_box',
|
468 |
+
'regular',
|
469 |
+
'pakje_gemak',
|
470 |
+
'food',
|
471 |
);
|
472 |
|
473 |
$this->_importErrors[] = Mage::helper('postnl')->__(
|
590 |
case '*':
|
591 |
$formattedType = '*';
|
592 |
break;
|
593 |
+
case 'letter_box': //no break
|
594 |
+
case 'letterbox': //no break
|
595 |
+
case 'buspakje': //no break
|
596 |
+
case 'bus_pakje': //no break
|
597 |
+
case 'brievenbuspakje': //no break
|
598 |
+
case 'brievenbus pakje': //no break
|
599 |
+
case 'letterboxparcel': //no break
|
600 |
+
case 'letter box parcel': //no break
|
601 |
$formattedType = 'letter_box';
|
602 |
break;
|
603 |
case 'regular': //no break
|
608 |
case 'package':
|
609 |
$formattedType = 'regular';
|
610 |
break;
|
611 |
+
case 'pakje_gemak': //no break
|
612 |
+
case 'pakje gemak': //no break
|
613 |
+
case 'PakjeGemak': //no break
|
614 |
+
case 'postkantoor': //no break
|
615 |
+
case 'post office': //no break
|
616 |
+
$formattedType = 'pakje_gemak';
|
617 |
+
break;
|
618 |
+
case 'food': //no break
|
619 |
+
case 'voedsel': //no break
|
620 |
+
case 'eten': //no break
|
621 |
+
case 'coolfood': //no break
|
622 |
+
case 'cooledfood': //no break
|
623 |
+
case 'gekoeld': //no break
|
624 |
+
$formattedType = 'food';
|
625 |
+
break;
|
626 |
//no default
|
627 |
}
|
628 |
|
629 |
return $formattedType;
|
630 |
}
|
631 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Resource_Matrixrate_Collection
|
@@ -45,6 +45,7 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate_Collection
|
|
45 |
protected function _construct()
|
46 |
{
|
47 |
$this->_init('postnl_carrier/matrixrate');
|
|
|
48 |
$this->_shipTable = $this->getMainTable();
|
49 |
$this->_countryTable = $this->getTable('directory/country');
|
50 |
$this->_regionTable = $this->getTable('directory/country_region');
|
@@ -70,4 +71,4 @@ class TIG_PostNL_Model_Carrier_Resource_Matrixrate_Collection
|
|
70 |
$this->addOrder('subtotal', self::SORT_ORDER_ASC);
|
71 |
$this->addOrder('qty', self::SORT_ORDER_ASC);
|
72 |
}
|
73 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Resource_Matrixrate_Collection
|
45 |
protected function _construct()
|
46 |
{
|
47 |
$this->_init('postnl_carrier/matrixrate');
|
48 |
+
/** @noinspection PhpDeprecationInspection */
|
49 |
$this->_shipTable = $this->getMainTable();
|
50 |
$this->_countryTable = $this->getTable('directory/country');
|
51 |
$this->_regionTable = $this->getTable('directory/country_region');
|
71 |
$this->addOrder('subtotal', self::SORT_ORDER_ASC);
|
72 |
$this->addOrder('qty', self::SORT_ORDER_ASC);
|
73 |
}
|
74 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Resource_Tablerate extends Mage_Shipping_Model_Resource_Carrier_Tablerate
|
@@ -64,6 +64,7 @@ class TIG_PostNL_Model_Carrier_Resource_Tablerate extends Mage_Shipping_Model_Re
|
|
64 |
}
|
65 |
|
66 |
$csvFile = $_FILES['groups']['tmp_name']['postnl']['fields']['import']['value'];
|
|
|
67 |
$website = Mage::app()->getWebsite($object->getScopeId());
|
68 |
|
69 |
$this->_importWebsiteId = (int)$website->getId();
|
@@ -149,4 +150,4 @@ class TIG_PostNL_Model_Carrier_Resource_Tablerate extends Mage_Shipping_Model_Re
|
|
149 |
|
150 |
return $this;
|
151 |
}
|
152 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Resource_Tablerate extends Mage_Shipping_Model_Resource_Carrier_Tablerate
|
64 |
}
|
65 |
|
66 |
$csvFile = $_FILES['groups']['tmp_name']['postnl']['fields']['import']['value'];
|
67 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
68 |
$website = Mage::app()->getWebsite($object->getScopeId());
|
69 |
|
70 |
$this->_importWebsiteId = (int)$website->getId();
|
150 |
|
151 |
return $this;
|
152 |
}
|
153 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Resource_Tablerate_Collection
|
@@ -46,8 +46,9 @@ class TIG_PostNL_Model_Carrier_Resource_Tablerate_Collection
|
|
46 |
protected function _construct()
|
47 |
{
|
48 |
$this->_init('postnl_carrier/tablerate');
|
|
|
49 |
$this->_shipTable = $this->getMainTable();
|
50 |
$this->_countryTable = $this->getTable('directory/country');
|
51 |
$this->_regionTable = $this->getTable('directory/country_region');
|
52 |
}
|
53 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_Resource_Tablerate_Collection
|
46 |
protected function _construct()
|
47 |
{
|
48 |
$this->_init('postnl_carrier/tablerate');
|
49 |
+
/** @noinspection PhpDeprecationInspection */
|
50 |
$this->_shipTable = $this->getMainTable();
|
51 |
$this->_countryTable = $this->getTable('directory/country');
|
52 |
$this->_regionTable = $this->getTable('directory/country_region');
|
53 |
}
|
54 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_System_Config_Backend_Matrixrate extends Mage_Core_Model_Config_Data
|
@@ -45,4 +45,4 @@ class TIG_PostNL_Model_Carrier_System_Config_Backend_Matrixrate extends Mage_Cor
|
|
45 |
{
|
46 |
Mage::getResourceModel('postnl_carrier/matrixrate')->uploadAndImport($this);
|
47 |
}
|
48 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_System_Config_Backend_Matrixrate extends Mage_Core_Model_Config_Data
|
45 |
{
|
46 |
Mage::getResourceModel('postnl_carrier/matrixrate')->uploadAndImport($this);
|
47 |
}
|
48 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_System_Config_Backend_Tablerate extends Mage_Core_Model_Config_Data
|
@@ -47,4 +47,4 @@ class TIG_PostNL_Model_Carrier_System_Config_Backend_Tablerate extends Mage_Core
|
|
47 |
{
|
48 |
Mage::getResourceModel('postnl_carrier/tablerate')->uploadAndImport($this);
|
49 |
}
|
50 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_System_Config_Backend_Tablerate extends Mage_Core_Model_Config_Data
|
47 |
{
|
48 |
Mage::getResourceModel('postnl_carrier/tablerate')->uploadAndImport($this);
|
49 |
}
|
50 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_System_Config_Source_RateType
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_System_Config_Source_RateType
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_System_Config_Source_TablerateSource
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Carrier_System_Config_Source_TablerateSource
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* This is a dummy class for the tablerate export/import functionality.
|
@@ -51,4 +51,4 @@ class TIG_PostNL_Model_Carrier_Tablerate extends Mage_Core_Model_Abstract
|
|
51 |
{
|
52 |
$this->_init('postnl_carrier/tablerate');
|
53 |
}
|
54 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* This is a dummy class for the tablerate export/import functionality.
|
51 |
{
|
52 |
$this->_init('postnl_carrier/tablerate');
|
53 |
}
|
54 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Checkout_Cif setStoreId(int $value)
|
@@ -86,7 +86,9 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
86 |
$storeId = $this->getStoreId();
|
87 |
}
|
88 |
|
89 |
-
|
|
|
|
|
90 |
|
91 |
return $testMode;
|
92 |
}
|
@@ -146,7 +148,9 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
146 |
public function prepareOrder($quote = null)
|
147 |
{
|
148 |
if (is_null($quote)) {
|
149 |
-
|
|
|
|
|
150 |
}
|
151 |
|
152 |
if (!$quote) {
|
@@ -239,7 +243,9 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
239 |
public function readOrder($quote = null)
|
240 |
{
|
241 |
if (is_null($quote)) {
|
242 |
-
|
|
|
|
|
243 |
}
|
244 |
|
245 |
if (!$quote) {
|
@@ -372,7 +378,9 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
372 |
* Get all payment method configuration options as well as an array of all payment method supported by PostNL
|
373 |
*/
|
374 |
$paymentMethods = Mage::getStoreConfig(self::XPATH_CHECKOUT_PAYMENT_METHODS, $storeId);
|
375 |
-
|
|
|
|
|
376 |
|
377 |
$allowedMethods = array();
|
378 |
foreach ($paymentMethods as $method => $value) {
|
@@ -428,6 +436,7 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
428 |
*/
|
429 |
protected function _getCustomer()
|
430 |
{
|
|
|
431 |
$session = Mage::getSingleton('customer/session');
|
432 |
if (!$session->isLoggedIn()) {
|
433 |
return false;
|
@@ -517,7 +526,9 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
517 |
}
|
518 |
|
519 |
$extRef = $quote->getId();
|
520 |
-
|
|
|
|
|
521 |
$subtotal = round($baseSubtotalIncltax, 2);
|
522 |
$shippingDate = $orderDate;
|
523 |
$shippingCosts = round($baseShippingAmount, 2);
|
@@ -657,6 +668,7 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
657 |
$reference = str_replace('{{var shipment_increment_id}}', $shipment->getIncrementId(), $reference);
|
658 |
$reference = str_replace('{{var order_increment_id}}', $shipment->getOrder()->getIncrementId(), $reference);
|
659 |
|
|
|
660 |
$store = Mage::getModel('core/store')->load($storeId);
|
661 |
$reference = str_replace('{{var store_frontend_name}}', $store->getFrontendName(), $reference);
|
662 |
}
|
@@ -707,11 +719,14 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
707 |
$priceOverview = Mage::getStoreConfigFlag(self::XPATH_ALLOW_PRICE_OVERVIEW, $storeId);
|
708 |
$agreeConditions = Mage::getStoreConfigFlag(self::XPATH_AGREE_CONDITIONS, $storeId);
|
709 |
|
|
|
|
|
|
|
710 |
/**
|
711 |
* If the module cannot use PakjeGemak, retail locations are not allowed in PostNL Checkout
|
712 |
*/
|
713 |
if (!$retailLocation
|
714 |
-
||
|
715 |
) {
|
716 |
$restrictions['NoRetailLocation'] = 'true';
|
717 |
} else {
|
@@ -722,7 +737,7 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
722 |
* If the module cannot use EPS, foreign addresses are not allowed in PostNL Checkout
|
723 |
*/
|
724 |
if (!$foreignAddress
|
725 |
-
||
|
726 |
) {
|
727 |
$restrictions['NoForeignAddress'] = 'true';
|
728 |
} else {
|
@@ -811,8 +826,11 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
811 |
{
|
812 |
$storeId = $this->getStoreId();
|
813 |
|
|
|
|
|
|
|
814 |
$webshopId = Mage::getStoreConfig(self::XPATH_WEBSHOP_ID, $storeId);
|
815 |
-
$webshopId =
|
816 |
|
817 |
$webshop = array(
|
818 |
'IntRef' => $webshopId,
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Checkout_Cif setStoreId(int $value)
|
86 |
$storeId = $this->getStoreId();
|
87 |
}
|
88 |
|
89 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
90 |
+
$helper = Mage::helper('postnl/checkout');
|
91 |
+
$testMode = $helper->isTestMode($storeId);
|
92 |
|
93 |
return $testMode;
|
94 |
}
|
148 |
public function prepareOrder($quote = null)
|
149 |
{
|
150 |
if (is_null($quote)) {
|
151 |
+
/** @var Mage_Checkout_Model_Session $session */
|
152 |
+
$session = Mage::getSingleton('checkout/session');
|
153 |
+
$quote = $session->getQuote();
|
154 |
}
|
155 |
|
156 |
if (!$quote) {
|
243 |
public function readOrder($quote = null)
|
244 |
{
|
245 |
if (is_null($quote)) {
|
246 |
+
/** @var Mage_Checkout_Model_Session $session */
|
247 |
+
$session = Mage::getSingleton('checkout/session');
|
248 |
+
$quote = $session->getQuote();
|
249 |
}
|
250 |
|
251 |
if (!$quote) {
|
378 |
* Get all payment method configuration options as well as an array of all payment method supported by PostNL
|
379 |
*/
|
380 |
$paymentMethods = Mage::getStoreConfig(self::XPATH_CHECKOUT_PAYMENT_METHODS, $storeId);
|
381 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
382 |
+
$helper = Mage::helper('postnl/checkout');
|
383 |
+
$postnlPaymentMethods = $helper->getCheckoutPaymentMethods();
|
384 |
|
385 |
$allowedMethods = array();
|
386 |
foreach ($paymentMethods as $method => $value) {
|
436 |
*/
|
437 |
protected function _getCustomer()
|
438 |
{
|
439 |
+
/** @var Mage_Customer_Model_Session $session */
|
440 |
$session = Mage::getSingleton('customer/session');
|
441 |
if (!$session->isLoggedIn()) {
|
442 |
return false;
|
526 |
}
|
527 |
|
528 |
$extRef = $quote->getId();
|
529 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
530 |
+
$dateModel = Mage::getModel('core/date');
|
531 |
+
$orderDate = date('d-m-Y H:i:s', $dateModel->timestamp());
|
532 |
$subtotal = round($baseSubtotalIncltax, 2);
|
533 |
$shippingDate = $orderDate;
|
534 |
$shippingCosts = round($baseShippingAmount, 2);
|
668 |
$reference = str_replace('{{var shipment_increment_id}}', $shipment->getIncrementId(), $reference);
|
669 |
$reference = str_replace('{{var order_increment_id}}', $shipment->getOrder()->getIncrementId(), $reference);
|
670 |
|
671 |
+
/** @var Mage_Core_Model_Store $store */
|
672 |
$store = Mage::getModel('core/store')->load($storeId);
|
673 |
$reference = str_replace('{{var store_frontend_name}}', $store->getFrontendName(), $reference);
|
674 |
}
|
719 |
$priceOverview = Mage::getStoreConfigFlag(self::XPATH_ALLOW_PRICE_OVERVIEW, $storeId);
|
720 |
$agreeConditions = Mage::getStoreConfigFlag(self::XPATH_AGREE_CONDITIONS, $storeId);
|
721 |
|
722 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
723 |
+
$helper = Mage::helper('postnl');
|
724 |
+
|
725 |
/**
|
726 |
* If the module cannot use PakjeGemak, retail locations are not allowed in PostNL Checkout
|
727 |
*/
|
728 |
if (!$retailLocation
|
729 |
+
|| !$helper->canUsePakjeGemak()
|
730 |
) {
|
731 |
$restrictions['NoRetailLocation'] = 'true';
|
732 |
} else {
|
737 |
* If the module cannot use EPS, foreign addresses are not allowed in PostNL Checkout
|
738 |
*/
|
739 |
if (!$foreignAddress
|
740 |
+
|| !$helper->canUseEps()
|
741 |
) {
|
742 |
$restrictions['NoForeignAddress'] = 'true';
|
743 |
} else {
|
826 |
{
|
827 |
$storeId = $this->getStoreId();
|
828 |
|
829 |
+
/** @var Mage_Core_Helper_Data $helper */
|
830 |
+
$helper = Mage::helper('core');
|
831 |
+
|
832 |
$webshopId = Mage::getStoreConfig(self::XPATH_WEBSHOP_ID, $storeId);
|
833 |
+
$webshopId = $helper->decrypt($webshopId);
|
834 |
|
835 |
$webshop = array(
|
836 |
'IntRef' => $webshopId,
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Checkout_Observer_Order
|
@@ -55,6 +55,7 @@ class TIG_PostNL_Model_Checkout_Observer_Order
|
|
55 |
* @var Mage_Sales_Model_Order $order
|
56 |
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
57 |
*/
|
|
|
58 |
$order = $observer->getOrder();
|
59 |
$postnlOrder = Mage::getModel('postnl_core/order')->load($order->getId(), 'order_id');
|
60 |
|
@@ -66,7 +67,9 @@ class TIG_PostNL_Model_Checkout_Observer_Order
|
|
66 |
$postnlOrder->cancel()
|
67 |
->save();
|
68 |
} catch (Exception $e) {
|
69 |
-
|
|
|
|
|
70 |
}
|
71 |
|
72 |
return $this;
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Checkout_Observer_Order
|
55 |
* @var Mage_Sales_Model_Order $order
|
56 |
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
57 |
*/
|
58 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
59 |
$order = $observer->getOrder();
|
60 |
$postnlOrder = Mage::getModel('postnl_core/order')->load($order->getId(), 'order_id');
|
61 |
|
67 |
$postnlOrder->cancel()
|
68 |
->save();
|
69 |
} catch (Exception $e) {
|
70 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
71 |
+
$helper = Mage::helper('postnl/checkout');
|
72 |
+
$helper->logException($e);
|
73 |
}
|
74 |
|
75 |
return $this;
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Checkout_Observer_Shipment
|
@@ -58,9 +58,12 @@ class TIG_PostNL_Model_Checkout_Observer_Shipment
|
|
58 |
/**
|
59 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
60 |
*/
|
|
|
61 |
$postnlShipment = $observer->getShipment();
|
62 |
|
63 |
$orderId = $postnlShipment->getOrderId();
|
|
|
|
|
64 |
$postnlOrder = Mage::getModel('postnl_core/order');
|
65 |
$postnlOrder->load($orderId, 'order_id');
|
66 |
if (!$postnlOrder->getId() || !$postnlOrder->getToken()) {
|
@@ -68,6 +71,7 @@ class TIG_PostNL_Model_Checkout_Observer_Shipment
|
|
68 |
}
|
69 |
|
70 |
try {
|
|
|
71 |
$cif = Mage::getModel('postnl_checkout/cif');
|
72 |
$result = $cif->updateOrder($postnlOrder);
|
73 |
|
@@ -78,6 +82,7 @@ class TIG_PostNL_Model_Checkout_Observer_Shipment
|
|
78 |
);
|
79 |
}
|
80 |
} catch (TIG_PostNL_Exception $e) {
|
|
|
81 |
$helper = Mage::helper('postnl');
|
82 |
$helper->addSessionMessage(
|
83 |
'adminhtml/session',
|
@@ -87,6 +92,7 @@ class TIG_PostNL_Model_Checkout_Observer_Shipment
|
|
87 |
);
|
88 |
return $this;
|
89 |
} catch (Exception $e) {
|
|
|
90 |
$helper = Mage::helper('postnl');
|
91 |
$helper->addSessionMessage(
|
92 |
'adminhtml/session',
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Checkout_Observer_Shipment
|
58 |
/**
|
59 |
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
60 |
*/
|
61 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
62 |
$postnlShipment = $observer->getShipment();
|
63 |
|
64 |
$orderId = $postnlShipment->getOrderId();
|
65 |
+
|
66 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
67 |
$postnlOrder = Mage::getModel('postnl_core/order');
|
68 |
$postnlOrder->load($orderId, 'order_id');
|
69 |
if (!$postnlOrder->getId() || !$postnlOrder->getToken()) {
|
71 |
}
|
72 |
|
73 |
try {
|
74 |
+
/** @var TIG_PostNL_Model_Checkout_Cif $cif */
|
75 |
$cif = Mage::getModel('postnl_checkout/cif');
|
76 |
$result = $cif->updateOrder($postnlOrder);
|
77 |
|
82 |
);
|
83 |
}
|
84 |
} catch (TIG_PostNL_Exception $e) {
|
85 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
86 |
$helper = Mage::helper('postnl');
|
87 |
$helper->addSessionMessage(
|
88 |
'adminhtml/session',
|
92 |
);
|
93 |
return $this;
|
94 |
} catch (Exception $e) {
|
95 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
96 |
$helper = Mage::helper('postnl');
|
97 |
$helper->addSessionMessage(
|
98 |
'adminhtml/session',
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated 1.2.0 This class has been moved to TIG_PostNL_Model_Core_Order. A dummy class has been left behind to
|
@@ -42,4 +42,4 @@
|
|
42 |
class TIG_PostNL_Model_Checkout_Order extends TIG_PostNL_Model_Core_Order
|
43 |
{
|
44 |
|
45 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated 1.2.0 This class has been moved to TIG_PostNL_Model_Core_Order. A dummy class has been left behind to
|
42 |
class TIG_PostNL_Model_Checkout_Order extends TIG_PostNL_Model_Core_Order
|
43 |
{
|
44 |
|
45 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Checkout_Service setQuote(Mage_Sales_Model_Quote $value)
|
@@ -84,7 +84,9 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
84 |
return $this->getData('quote');
|
85 |
}
|
86 |
|
87 |
-
|
|
|
|
|
88 |
|
89 |
$this->setQuote($quote);
|
90 |
return $quote;
|
@@ -137,6 +139,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
137 |
$delivery = $data->Bezorging;
|
138 |
$shippingAddressData = $delivery->Geadresseerde;
|
139 |
|
|
|
140 |
$shippingAddress = Mage::getModel('sales/quote_address');
|
141 |
$shippingAddress->setAddressType($shippingAddress::TYPE_SHIPPING)
|
142 |
->setEmail($email)
|
@@ -144,7 +147,9 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
144 |
|
145 |
$shippingAddress = $this->_parseAddress($shippingAddress, $shippingAddressData);
|
146 |
|
147 |
-
|
|
|
|
|
148 |
if (!$shippingAddress->getShippingMethod()) {
|
149 |
$shippingAddress->setCollectShippingRates(true)
|
150 |
->setShippingMethod($shippingMethod);
|
@@ -154,6 +159,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
154 |
* Parse the billing address
|
155 |
*/
|
156 |
$billingAddressData = $data->Facturatie->Adres;
|
|
|
157 |
$billingAddress = Mage::getModel('sales/quote_address');
|
158 |
$billingAddress->setAddressType($billingAddress::TYPE_BILLING)
|
159 |
->setEmail($email)
|
@@ -166,6 +172,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
166 |
*/
|
167 |
if (isset($delivery->ServicePunt)) {
|
168 |
$serviceLocationData = $delivery->ServicePunt;
|
|
|
169 |
$pakjeGemakAddress = Mage::getModel('sales/quote_address');
|
170 |
$pakjeGemakAddress->setAddressType(self::ADDRESS_TYPE_PAKJEGEMAK)
|
171 |
->setEmail($email)
|
@@ -229,8 +236,10 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
229 |
* Otherwise, we need to process the data as we would with a regular checkout procedure
|
230 |
*/
|
231 |
if ($quote->isVirtual()) {
|
|
|
232 |
$quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
233 |
} else {
|
|
|
234 |
$quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
235 |
}
|
236 |
|
@@ -248,6 +257,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
248 |
*
|
249 |
* @since Magento v1.13
|
250 |
*/
|
|
|
251 |
$paymentMethodAbstractClass = Mage::getConfig()->getModelClassName('payment/method_abstract');
|
252 |
if (defined($paymentMethodAbstractClass . '::CHECK_USE_CHECKOUT')
|
253 |
&& defined($paymentMethodAbstractClass . '::CHECK_USE_FOR_COUNTRY')
|
@@ -263,6 +273,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
263 |
}
|
264 |
|
265 |
$paymentDataObject = new Varien_Object();
|
|
|
266 |
$paymentDataObject->setPaymentData($data);
|
267 |
|
268 |
Mage::dispatchEvent(
|
@@ -274,6 +285,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
274 |
)
|
275 |
);
|
276 |
|
|
|
277 |
$paymentData = $paymentDataObject->getPaymentData();
|
278 |
|
279 |
$quote->getPayment()->setMethod($data['method'])->importData($paymentData);
|
@@ -313,7 +325,9 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
313 |
/**
|
314 |
* Check if the plugin supports the chosen payment method
|
315 |
*/
|
316 |
-
|
|
|
|
|
317 |
$methodName = array_search($postnlPaymentData->Code, $postnlPaymentMethods);
|
318 |
|
319 |
/**
|
@@ -321,7 +335,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
321 |
*/
|
322 |
if (!Mage::getStoreConfigFlag(self::XPATH_PAYMENT_METHODS . '/' . $methodName, $quote->getStoreId())) {
|
323 |
throw new TIG_PostNL_Exception(
|
324 |
-
|
325 |
'POSTNL-0048'
|
326 |
);
|
327 |
}
|
@@ -400,6 +414,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
400 |
*
|
401 |
* @var $paymentMethodAbstractClass Mage_Payment_Model_Method_Abstract
|
402 |
*/
|
|
|
403 |
$paymentMethodAbstractClass = Mage::getConfig()->getModelClassName('payment/method_abstract');
|
404 |
if (defined($paymentMethodAbstractClass . '::CHECK_USE_CHECKOUT')
|
405 |
&& defined($paymentMethodAbstractClass . '::CHECK_USE_FOR_COUNTRY')
|
@@ -415,8 +430,10 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
415 |
}
|
416 |
|
417 |
if ($quote->isVirtual()) {
|
|
|
418 |
$quote->getBillingAddress()->setPaymentMethod($methodCode);
|
419 |
} else {
|
|
|
420 |
$quote->getShippingAddress()->setPaymentMethod($methodCode);
|
421 |
$quote->getShippingAddress()->setCollectShippingRates(true);
|
422 |
}
|
@@ -444,6 +461,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
444 |
}
|
445 |
|
446 |
$paymentDataObject = new Varien_Object();
|
|
|
447 |
$paymentDataObject->setPaymentData($paymentData);
|
448 |
|
449 |
Mage::dispatchEvent(
|
@@ -455,6 +473,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
455 |
)
|
456 |
);
|
457 |
|
|
|
458 |
$paymentData = $paymentDataObject->getPaymentData();
|
459 |
|
460 |
/**
|
@@ -495,7 +514,9 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
495 |
/**
|
496 |
* Load the current customer if the user is logged in
|
497 |
*/
|
498 |
-
|
|
|
|
|
499 |
$customerId = $customer->getId();
|
500 |
|
501 |
/**
|
@@ -515,6 +536,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
515 |
/**
|
516 |
* If the customer already has a DOB we're finished
|
517 |
*/
|
|
|
518 |
if ($customer->getDob()) {
|
519 |
return $this;
|
520 |
}
|
@@ -539,6 +561,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
539 |
/**
|
540 |
* Update the customer with the DOB and save
|
541 |
*/
|
|
|
542 |
$customer->setDob($dob->getTimestamp())
|
543 |
->save();
|
544 |
|
@@ -566,6 +589,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
566 |
|
567 |
$this->_verifyData($data, $quote);
|
568 |
|
|
|
569 |
$postnlOrder = Mage::getModel('postnl_core/order');
|
570 |
$postnlOrder->load($quote->getId(), 'quote_id');
|
571 |
|
@@ -641,6 +665,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
641 |
)
|
642 |
);
|
643 |
|
|
|
644 |
$quoteService = Mage::getModel('sales/service_quote', $quote);
|
645 |
$quoteService->submitAll();
|
646 |
$order = $quoteService->getOrder();
|
@@ -664,7 +689,9 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
664 |
}
|
665 |
|
666 |
$address->load($address->getId());
|
667 |
-
|
|
|
|
|
668 |
|
669 |
$order->addAddress($orderAddress);
|
670 |
|
@@ -705,7 +732,9 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
705 |
->setIsActive(false)
|
706 |
->save();
|
707 |
|
|
|
708 |
$checkoutSession = Mage::getSingleton('checkout/session');
|
|
|
709 |
$checkoutSession->setLastSuccessQuoteId($order->getQuoteId())
|
710 |
->setLastRealOrderId($order->getRealOrderId())
|
711 |
->setLastQuoteId($order->getQuoteId())
|
@@ -745,6 +774,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
745 |
$postnlOrder = Mage::getModel('postnl_core/order')
|
746 |
->load($quote->getId(), 'quote_id');
|
747 |
|
|
|
748 |
$cif = Mage::getModel('postnl_checkout/cif');
|
749 |
$cif->confirmOrder($postnlOrder);
|
750 |
|
@@ -818,6 +848,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
818 |
$address->setCountryId('NL');
|
819 |
}
|
820 |
|
|
|
821 |
$address->setShouldIgnoreValidation(true);
|
822 |
|
823 |
return $address;
|
@@ -871,6 +902,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
871 |
. PHP_EOL
|
872 |
. $addressData->HuisnummerExt;
|
873 |
|
|
|
874 |
$address->setStreet($streetData);
|
875 |
return $address;
|
876 |
}
|
@@ -905,6 +937,7 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
905 |
* Sort the street data according to the field numbers and set it
|
906 |
*/
|
907 |
ksort($streetData);
|
|
|
908 |
$address->setStreet($streetData);
|
909 |
|
910 |
return $address;
|
@@ -938,7 +971,10 @@ class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
|
938 |
*/
|
939 |
$dataWebshopId = $data->Webshop->IntRef;
|
940 |
$webshopId = Mage::getStoreConfig(self::XPATH_WEBSHOP_ID, $this->getStoreId());
|
941 |
-
|
|
|
|
|
|
|
942 |
|
943 |
if ($webshopId != $dataWebshopId) {
|
944 |
throw new TIG_PostNL_Exception(
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Checkout_Service setQuote(Mage_Sales_Model_Quote $value)
|
84 |
return $this->getData('quote');
|
85 |
}
|
86 |
|
87 |
+
/** @var Mage_Checkout_Model_Session $session */
|
88 |
+
$session = Mage::getSingleton('checkout/session');
|
89 |
+
$quote = $session->getQuote();
|
90 |
|
91 |
$this->setQuote($quote);
|
92 |
return $quote;
|
139 |
$delivery = $data->Bezorging;
|
140 |
$shippingAddressData = $delivery->Geadresseerde;
|
141 |
|
142 |
+
/** @var Mage_Sales_Model_Quote_Address $shippingAddress */
|
143 |
$shippingAddress = Mage::getModel('sales/quote_address');
|
144 |
$shippingAddress->setAddressType($shippingAddress::TYPE_SHIPPING)
|
145 |
->setEmail($email)
|
147 |
|
148 |
$shippingAddress = $this->_parseAddress($shippingAddress, $shippingAddressData);
|
149 |
|
150 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
151 |
+
$helper = Mage::helper('postnl/carrier');
|
152 |
+
$shippingMethod = $helper->getCurrentPostnlShippingMethod();
|
153 |
if (!$shippingAddress->getShippingMethod()) {
|
154 |
$shippingAddress->setCollectShippingRates(true)
|
155 |
->setShippingMethod($shippingMethod);
|
159 |
* Parse the billing address
|
160 |
*/
|
161 |
$billingAddressData = $data->Facturatie->Adres;
|
162 |
+
/** @var Mage_Sales_Model_Quote_Address $billingAddress */
|
163 |
$billingAddress = Mage::getModel('sales/quote_address');
|
164 |
$billingAddress->setAddressType($billingAddress::TYPE_BILLING)
|
165 |
->setEmail($email)
|
172 |
*/
|
173 |
if (isset($delivery->ServicePunt)) {
|
174 |
$serviceLocationData = $delivery->ServicePunt;
|
175 |
+
/** @var Mage_Sales_Model_Quote_Address $pakjeGemakAddress */
|
176 |
$pakjeGemakAddress = Mage::getModel('sales/quote_address');
|
177 |
$pakjeGemakAddress->setAddressType(self::ADDRESS_TYPE_PAKJEGEMAK)
|
178 |
->setEmail($email)
|
236 |
* Otherwise, we need to process the data as we would with a regular checkout procedure
|
237 |
*/
|
238 |
if ($quote->isVirtual()) {
|
239 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
240 |
$quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
241 |
} else {
|
242 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
243 |
$quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
244 |
}
|
245 |
|
257 |
*
|
258 |
* @since Magento v1.13
|
259 |
*/
|
260 |
+
/** @noinspection PhpParamsInspection */
|
261 |
$paymentMethodAbstractClass = Mage::getConfig()->getModelClassName('payment/method_abstract');
|
262 |
if (defined($paymentMethodAbstractClass . '::CHECK_USE_CHECKOUT')
|
263 |
&& defined($paymentMethodAbstractClass . '::CHECK_USE_FOR_COUNTRY')
|
273 |
}
|
274 |
|
275 |
$paymentDataObject = new Varien_Object();
|
276 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
277 |
$paymentDataObject->setPaymentData($data);
|
278 |
|
279 |
Mage::dispatchEvent(
|
285 |
)
|
286 |
);
|
287 |
|
288 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
289 |
$paymentData = $paymentDataObject->getPaymentData();
|
290 |
|
291 |
$quote->getPayment()->setMethod($data['method'])->importData($paymentData);
|
325 |
/**
|
326 |
* Check if the plugin supports the chosen payment method
|
327 |
*/
|
328 |
+
/** @var TIG_PostNL_Helper_Checkout $helper */
|
329 |
+
$helper = Mage::helper('postnl/checkout');
|
330 |
+
$postnlPaymentMethods = $helper->getCheckoutPaymentMethods();
|
331 |
$methodName = array_search($postnlPaymentData->Code, $postnlPaymentMethods);
|
332 |
|
333 |
/**
|
335 |
*/
|
336 |
if (!Mage::getStoreConfigFlag(self::XPATH_PAYMENT_METHODS . '/' . $methodName, $quote->getStoreId())) {
|
337 |
throw new TIG_PostNL_Exception(
|
338 |
+
$helper->__('Selected payment method %s is not available.', $methodName),
|
339 |
'POSTNL-0048'
|
340 |
);
|
341 |
}
|
414 |
*
|
415 |
* @var $paymentMethodAbstractClass Mage_Payment_Model_Method_Abstract
|
416 |
*/
|
417 |
+
/** @noinspection PhpParamsInspection */
|
418 |
$paymentMethodAbstractClass = Mage::getConfig()->getModelClassName('payment/method_abstract');
|
419 |
if (defined($paymentMethodAbstractClass . '::CHECK_USE_CHECKOUT')
|
420 |
&& defined($paymentMethodAbstractClass . '::CHECK_USE_FOR_COUNTRY')
|
430 |
}
|
431 |
|
432 |
if ($quote->isVirtual()) {
|
433 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
434 |
$quote->getBillingAddress()->setPaymentMethod($methodCode);
|
435 |
} else {
|
436 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
437 |
$quote->getShippingAddress()->setPaymentMethod($methodCode);
|
438 |
$quote->getShippingAddress()->setCollectShippingRates(true);
|
439 |
}
|
461 |
}
|
462 |
|
463 |
$paymentDataObject = new Varien_Object();
|
464 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
465 |
$paymentDataObject->setPaymentData($paymentData);
|
466 |
|
467 |
Mage::dispatchEvent(
|
473 |
)
|
474 |
);
|
475 |
|
476 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
477 |
$paymentData = $paymentDataObject->getPaymentData();
|
478 |
|
479 |
/**
|
514 |
/**
|
515 |
* Load the current customer if the user is logged in
|
516 |
*/
|
517 |
+
/** @var Mage_Customer_Model_Session $session */
|
518 |
+
$session = Mage::getSingleton('customer/session');
|
519 |
+
$customer = $session->getCustomer();
|
520 |
$customerId = $customer->getId();
|
521 |
|
522 |
/**
|
536 |
/**
|
537 |
* If the customer already has a DOB we're finished
|
538 |
*/
|
539 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
540 |
if ($customer->getDob()) {
|
541 |
return $this;
|
542 |
}
|
561 |
/**
|
562 |
* Update the customer with the DOB and save
|
563 |
*/
|
564 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
565 |
$customer->setDob($dob->getTimestamp())
|
566 |
->save();
|
567 |
|
589 |
|
590 |
$this->_verifyData($data, $quote);
|
591 |
|
592 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
593 |
$postnlOrder = Mage::getModel('postnl_core/order');
|
594 |
$postnlOrder->load($quote->getId(), 'quote_id');
|
595 |
|
665 |
)
|
666 |
);
|
667 |
|
668 |
+
/** @var Mage_Sales_Model_Service_Quote $quoteService */
|
669 |
$quoteService = Mage::getModel('sales/service_quote', $quote);
|
670 |
$quoteService->submitAll();
|
671 |
$order = $quoteService->getOrder();
|
689 |
}
|
690 |
|
691 |
$address->load($address->getId());
|
692 |
+
/** @var Mage_Sales_Model_Convert_Quote $converter */
|
693 |
+
$converter = Mage::getModel('sales/convert_quote');
|
694 |
+
$orderAddress = $converter->addressToOrderAddress($address);
|
695 |
|
696 |
$order->addAddress($orderAddress);
|
697 |
|
732 |
->setIsActive(false)
|
733 |
->save();
|
734 |
|
735 |
+
/** @var Mage_Checkout_Model_Session $checkoutSession */
|
736 |
$checkoutSession = Mage::getSingleton('checkout/session');
|
737 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
738 |
$checkoutSession->setLastSuccessQuoteId($order->getQuoteId())
|
739 |
->setLastRealOrderId($order->getRealOrderId())
|
740 |
->setLastQuoteId($order->getQuoteId())
|
774 |
$postnlOrder = Mage::getModel('postnl_core/order')
|
775 |
->load($quote->getId(), 'quote_id');
|
776 |
|
777 |
+
/** @var TIG_PostNL_Model_Checkout_Cif $cif */
|
778 |
$cif = Mage::getModel('postnl_checkout/cif');
|
779 |
$cif->confirmOrder($postnlOrder);
|
780 |
|
848 |
$address->setCountryId('NL');
|
849 |
}
|
850 |
|
851 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
852 |
$address->setShouldIgnoreValidation(true);
|
853 |
|
854 |
return $address;
|
902 |
. PHP_EOL
|
903 |
. $addressData->HuisnummerExt;
|
904 |
|
905 |
+
/** @noinspection PhpParamsInspection */
|
906 |
$address->setStreet($streetData);
|
907 |
return $address;
|
908 |
}
|
937 |
* Sort the street data according to the field numbers and set it
|
938 |
*/
|
939 |
ksort($streetData);
|
940 |
+
/** @noinspection PhpParamsInspection */
|
941 |
$address->setStreet($streetData);
|
942 |
|
943 |
return $address;
|
971 |
*/
|
972 |
$dataWebshopId = $data->Webshop->IntRef;
|
973 |
$webshopId = Mage::getStoreConfig(self::XPATH_WEBSHOP_ID, $this->getStoreId());
|
974 |
+
|
975 |
+
/** @var Mage_Core_Helper_Data $helper */
|
976 |
+
$helper = Mage::helper('core');
|
977 |
+
$webshopId = $helper->decrypt($webshopId);
|
978 |
|
979 |
if ($webshopId != $dataWebshopId) {
|
980 |
throw new TIG_PostNL_Exception(
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Checkout_System_Config_Source_ActivePaymentMethods
|
@@ -45,7 +45,9 @@ class TIG_PostNL_Model_Checkout_System_Config_Source_ActivePaymentMethods
|
|
45 |
*/
|
46 |
public function toOptionArray()
|
47 |
{
|
48 |
-
|
|
|
|
|
49 |
|
50 |
$storeId = Mage::app()->getStore()->getId();
|
51 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Checkout_System_Config_Source_ActivePaymentMethods
|
45 |
*/
|
46 |
public function toOptionArray()
|
47 |
{
|
48 |
+
/** @var Mage_Payment_Model_Config $config */
|
49 |
+
$config = Mage::getSingleton('payment/config');
|
50 |
+
$paymentMethods = $config->getActiveMethods();
|
51 |
|
52 |
$storeId = Mage::app()->getStore()->getId();
|
53 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Checkout_System_Config_Source_CmsPage
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Checkout_System_Config_Source_CmsPage
|
@@ -33,10 +33,10 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Api extends Mage_Api_Model_Resource_Abstract
|
40 |
{
|
41 |
|
42 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Api extends Mage_Api_Model_Resource_Abstract
|
40 |
{
|
41 |
|
42 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
@@ -52,6 +52,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
52 |
/**
|
53 |
* Get service model used for processing this request.
|
54 |
*/
|
|
|
55 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
56 |
|
57 |
$resultArray = array();
|
@@ -116,6 +117,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
116 |
/**
|
117 |
* Get service model used for processing this request.
|
118 |
*/
|
|
|
119 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
120 |
|
121 |
$response = array();
|
@@ -190,6 +192,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
190 |
/**
|
191 |
* Get service model used for processing this request.
|
192 |
*/
|
|
|
193 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
194 |
|
195 |
/**
|
@@ -256,6 +259,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
256 |
/**
|
257 |
* Get service model used for processing this request.
|
258 |
*/
|
|
|
259 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
260 |
|
261 |
/**
|
@@ -322,6 +326,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
322 |
/**
|
323 |
* Get service model used for processing this request.
|
324 |
*/
|
|
|
325 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
326 |
|
327 |
/**
|
@@ -358,6 +363,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
358 |
/**
|
359 |
* Get service model used for processing this request.
|
360 |
*/
|
|
|
361 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
362 |
|
363 |
/**
|
@@ -396,6 +402,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
396 |
/**
|
397 |
* Get service model used for processing this request.
|
398 |
*/
|
|
|
399 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
400 |
|
401 |
/**
|
@@ -469,6 +476,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
469 |
*/
|
470 |
protected function _confirmShipment(TIG_PostNL_Model_Core_Service_Shipment $serviceModel, $shipmentId)
|
471 |
{
|
|
|
472 |
$helper = Mage::helper('postnl');
|
473 |
|
474 |
/**
|
@@ -565,6 +573,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
565 |
protected function _getLabels(TIG_PostNL_Model_Core_Service_Shipment $serviceModel, $shipmentId, $confirm = false,
|
566 |
$labelSize = false, $labelStartPosition = 0)
|
567 |
{
|
|
|
568 |
$helper = Mage::helper('postnl');
|
569 |
|
570 |
/**
|
@@ -607,7 +616,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
607 |
/**
|
608 |
* Check whether we should also get the return labels based on the shop's configuration.
|
609 |
*/
|
610 |
-
$printReturnLabels =
|
611 |
$postnlShipment->getStoreId()
|
612 |
);
|
613 |
|
@@ -619,9 +628,10 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
619 |
/**
|
620 |
* Get the label model which will convert the base64_encoded pdf strings to a single, merged pdf.
|
621 |
*/
|
622 |
-
$labelModel
|
623 |
-
|
624 |
-
|
|
|
625 |
|
626 |
/**
|
627 |
* Create the merged pdf.
|
@@ -681,7 +691,9 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
681 |
*/
|
682 |
protected function _createShipment(TIG_PostNL_Model_Core_Service_Shipment $serviceModel, $orderId)
|
683 |
{
|
|
|
684 |
$helper = Mage::helper('postnl');
|
|
|
685 |
/**
|
686 |
* Set return values to default to null.
|
687 |
*/
|
@@ -845,6 +857,7 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
845 |
*/
|
846 |
protected function _getStatusInfo(TIG_PostNL_Model_Core_Service_Shipment $serviceModel, $shipmentId)
|
847 |
{
|
|
|
848 |
$helper = Mage::helper('postnl');
|
849 |
|
850 |
/**
|
@@ -943,4 +956,4 @@ class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
|
943 |
|
944 |
return $response;
|
945 |
}
|
946 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Api_V2 extends TIG_PostNL_Model_Core_Api
|
52 |
/**
|
53 |
* Get service model used for processing this request.
|
54 |
*/
|
55 |
+
/** @var TIG_PostNL_Model_Core_Service_Shipment $serviceModel */
|
56 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
57 |
|
58 |
$resultArray = array();
|
117 |
/**
|
118 |
* Get service model used for processing this request.
|
119 |
*/
|
120 |
+
/** @var TIG_PostNL_Model_Core_Service_Shipment $serviceModel */
|
121 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
122 |
|
123 |
$response = array();
|
192 |
/**
|
193 |
* Get service model used for processing this request.
|
194 |
*/
|
195 |
+
/** @var TIG_PostNL_Model_Core_Service_Shipment $serviceModel */
|
196 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
197 |
|
198 |
/**
|
259 |
/**
|
260 |
* Get service model used for processing this request.
|
261 |
*/
|
262 |
+
/** @var TIG_PostNL_Model_Core_Service_Shipment $serviceModel */
|
263 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
264 |
|
265 |
/**
|
326 |
/**
|
327 |
* Get service model used for processing this request.
|
328 |
*/
|
329 |
+
/** @var TIG_PostNL_Model_Core_Service_Shipment $serviceModel */
|
330 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
331 |
|
332 |
/**
|
363 |
/**
|
364 |
* Get service model used for processing this request.
|
365 |
*/
|
366 |
+
/** @var TIG_PostNL_Model_Core_Service_Shipment $serviceModel */
|
367 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
368 |
|
369 |
/**
|
402 |
/**
|
403 |
* Get service model used for processing this request.
|
404 |
*/
|
405 |
+
/** @var TIG_PostNL_Model_Core_Service_Shipment $serviceModel */
|
406 |
$serviceModel = Mage::getModel('postnl_core/service_shipment');
|
407 |
|
408 |
/**
|
476 |
*/
|
477 |
protected function _confirmShipment(TIG_PostNL_Model_Core_Service_Shipment $serviceModel, $shipmentId)
|
478 |
{
|
479 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
480 |
$helper = Mage::helper('postnl');
|
481 |
|
482 |
/**
|
573 |
protected function _getLabels(TIG_PostNL_Model_Core_Service_Shipment $serviceModel, $shipmentId, $confirm = false,
|
574 |
$labelSize = false, $labelStartPosition = 0)
|
575 |
{
|
576 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
577 |
$helper = Mage::helper('postnl');
|
578 |
|
579 |
/**
|
616 |
/**
|
617 |
* Check whether we should also get the return labels based on the shop's configuration.
|
618 |
*/
|
619 |
+
$printReturnLabels = $helper->canPrintReturnLabelsWithShippingLabels(
|
620 |
$postnlShipment->getStoreId()
|
621 |
);
|
622 |
|
628 |
/**
|
629 |
* Get the label model which will convert the base64_encoded pdf strings to a single, merged pdf.
|
630 |
*/
|
631 |
+
/** @var TIG_PostNL_Model_Core_Label $labelModel */
|
632 |
+
$labelModel = Mage::getModel('postnl_core/label');
|
633 |
+
$labelModel->setLabelSize($labelSize)
|
634 |
+
->setLabelCounter($labelStartPosition);
|
635 |
|
636 |
/**
|
637 |
* Create the merged pdf.
|
691 |
*/
|
692 |
protected function _createShipment(TIG_PostNL_Model_Core_Service_Shipment $serviceModel, $orderId)
|
693 |
{
|
694 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
695 |
$helper = Mage::helper('postnl');
|
696 |
+
|
697 |
/**
|
698 |
* Set return values to default to null.
|
699 |
*/
|
857 |
*/
|
858 |
protected function _getStatusInfo(TIG_PostNL_Model_Core_Service_Shipment $serviceModel, $shipmentId)
|
859 |
{
|
860 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
861 |
$helper = Mage::helper('postnl');
|
862 |
|
863 |
/**
|
956 |
|
957 |
return $response;
|
958 |
}
|
959 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlCoreIsEnabled()
|
@@ -53,6 +53,8 @@
|
|
53 |
* @method boolean hasPostnlDeliveryOptionsCanUseTimeframes()
|
54 |
* @method boolean hasPostnlDeliveryOptionsCanUseEveningTimeframes()
|
55 |
* @method boolean hasPostnlDeliveryOptionsCanUseSundaySorting()
|
|
|
|
|
56 |
* @method boolean hasPostnlMijnpakketIsActive()
|
57 |
* @method boolean hasPostnlMijnpakketCanShowNotification()
|
58 |
* @method boolean hasPostnlCoreCanUseBuspakje()
|
@@ -82,6 +84,8 @@
|
|
82 |
* @method boolean getPostnlDeliveryOptionsCanUseTimeframes()
|
83 |
* @method boolean getPostnlDeliveryOptionsCanUseEveningTimeframes()
|
84 |
* @method boolean getPostnlDeliveryOptionsCanUseSundaySorting()
|
|
|
|
|
85 |
* @method boolean getPostnlMijnpakketIsActive()
|
86 |
* @method boolean getPostnlMijnpakketCanShowNotification()
|
87 |
* @method boolean getPostnlCoreCanUseBuspakje()
|
@@ -111,6 +115,8 @@
|
|
111 |
* @method TIG_PostNL_Model_Core_Cache setPostnlDeliveryOptionsCanUseTimeframes(boolean $value)
|
112 |
* @method TIG_PostNL_Model_Core_Cache setPostnlDeliveryOptionsCanUseEveningTimeframes(boolean $value)
|
113 |
* @method TIG_PostNL_Model_Core_Cache setPostnlDeliveryOptionsCanUseSundaySorting(boolean $value)
|
|
|
|
|
114 |
* @method TIG_PostNL_Model_Core_Cache setPostnlMijnpakketIsActive(boolean $value)
|
115 |
* @method TIG_PostNL_Model_Core_Cache setPostnlMijnpakketCanShowNotification(boolean $value)
|
116 |
* @method TIG_PostNL_Model_Core_Cache setPostnlCoreCanUseBuspakje(boolean $value)
|
@@ -341,4 +347,4 @@ class TIG_PostNL_Model_Core_Cache extends Varien_Object
|
|
341 |
|
342 |
return $cacheId;
|
343 |
}
|
344 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasPostnlCoreIsEnabled()
|
53 |
* @method boolean hasPostnlDeliveryOptionsCanUseTimeframes()
|
54 |
* @method boolean hasPostnlDeliveryOptionsCanUseEveningTimeframes()
|
55 |
* @method boolean hasPostnlDeliveryOptionsCanUseSundaySorting()
|
56 |
+
* @method boolean hasPostnlDeliveryOptionsCanUseSameDayDelivery()
|
57 |
+
* @method boolean hasPostnlDeliveryOptionsCanUseFoodDelivery()
|
58 |
* @method boolean hasPostnlMijnpakketIsActive()
|
59 |
* @method boolean hasPostnlMijnpakketCanShowNotification()
|
60 |
* @method boolean hasPostnlCoreCanUseBuspakje()
|
84 |
* @method boolean getPostnlDeliveryOptionsCanUseTimeframes()
|
85 |
* @method boolean getPostnlDeliveryOptionsCanUseEveningTimeframes()
|
86 |
* @method boolean getPostnlDeliveryOptionsCanUseSundaySorting()
|
87 |
+
* @method boolean getPostnlDeliveryOptionsCanUseSameDayDelivery()
|
88 |
+
* @method boolean getPostnlDeliveryOptionsCanUseFoodDelivery()
|
89 |
* @method boolean getPostnlMijnpakketIsActive()
|
90 |
* @method boolean getPostnlMijnpakketCanShowNotification()
|
91 |
* @method boolean getPostnlCoreCanUseBuspakje()
|
115 |
* @method TIG_PostNL_Model_Core_Cache setPostnlDeliveryOptionsCanUseTimeframes(boolean $value)
|
116 |
* @method TIG_PostNL_Model_Core_Cache setPostnlDeliveryOptionsCanUseEveningTimeframes(boolean $value)
|
117 |
* @method TIG_PostNL_Model_Core_Cache setPostnlDeliveryOptionsCanUseSundaySorting(boolean $value)
|
118 |
+
* @method TIG_PostNL_Model_Core_Cache setPostnlDeliveryOptionsCanUseSameDayDelivery(boolean $value)
|
119 |
+
* @method TIG_PostNL_Model_Core_Cache setPostnlDeliveryOptionsCanUseFoodDelivery(boolean $value)
|
120 |
* @method TIG_PostNL_Model_Core_Cache setPostnlMijnpakketIsActive(boolean $value)
|
121 |
* @method TIG_PostNL_Model_Core_Cache setPostnlMijnpakketCanShowNotification(boolean $value)
|
122 |
* @method TIG_PostNL_Model_Core_Cache setPostnlCoreCanUseBuspakje(boolean $value)
|
347 |
|
348 |
return $cacheId;
|
349 |
}
|
350 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class containing all default methods used for CIF communication by this extension.
|
@@ -63,7 +63,9 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
63 |
* Constants containing xpaths to cif configuration options.
|
64 |
*/
|
65 |
const XPATH_CUSTOMER_CODE = 'postnl/cif/customer_code';
|
|
|
66 |
const XPATH_CUSTOMER_NUMBER = 'postnl/cif/customer_number';
|
|
|
67 |
const XPATH_COLLECTION_LOCATION = 'postnl/cif/collection_location';
|
68 |
const XPATH_GLOBAL_BARCODE_TYPE = 'postnl/cif_globalpack_settings/global_barcode_type';
|
69 |
const XPATH_GLOBAL_BARCODE_RANGE = 'postnl/cif_globalpack_settings/global_barcode_range';
|
@@ -155,6 +157,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
155 |
'Collection' => '04',
|
156 |
'Return' => '08',
|
157 |
'Delivery' => '09', // Post office address. For use with PakjeGemak.
|
|
|
158 |
);
|
159 |
|
160 |
/**
|
@@ -251,6 +254,36 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
251 |
'Characteristic' => '101',
|
252 |
'Option' => '008',
|
253 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
);
|
255 |
|
256 |
/**
|
@@ -572,7 +605,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
572 |
);
|
573 |
} else {
|
574 |
$cifShipment = array(
|
575 |
-
'Shipment' => $this->_getShipment($postnlShipment, $barcode, $mainBarcode
|
576 |
);
|
577 |
}
|
578 |
|
@@ -808,17 +841,21 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
808 |
*/
|
809 |
protected function _getMessage($barcode, $extra = array())
|
810 |
{
|
|
|
|
|
811 |
$messageIdString = uniqid(
|
812 |
'postnl_'
|
813 |
-
. ip2long(
|
814 |
)
|
815 |
. $this->_getCustomerNumber()
|
816 |
. $barcode
|
817 |
. microtime();
|
818 |
|
|
|
|
|
819 |
$message = array(
|
820 |
'MessageID' => md5($messageIdString),
|
821 |
-
'MessageTimeStamp' => date('d-m-Y H:i:s',
|
822 |
);
|
823 |
|
824 |
if ($extra) {
|
@@ -849,6 +886,23 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
849 |
);
|
850 |
|
851 |
$customer = array_merge($customer, $additionalCustomerData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
852 |
}
|
853 |
|
854 |
return $customer;
|
@@ -884,8 +938,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
884 |
/**
|
885 |
* Get the parcel weight and then convert it to grams.
|
886 |
*/
|
|
|
|
|
887 |
$parcelWeight = Mage::getStoreConfig(self::XPATH_WEIGHT_PER_PARCEL, $postnlShipment->getStoreId());
|
888 |
-
$parcelWeight =
|
889 |
|
890 |
/**
|
891 |
* All parcels except for the last one weigh a configured amount. The last parcel weighs the remainder
|
@@ -908,7 +964,9 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
908 |
* Get and format this shipment's delivery date if available.
|
909 |
*/
|
910 |
$deliveryDate = null;
|
911 |
-
|
|
|
|
|
912 |
$deliveryDate = $postnlShipment->getDeliveryDate();
|
913 |
if ($deliveryDate) {
|
914 |
$deliveryTime = new DateTime($deliveryDate, new DateTimeZone('UTC'));
|
@@ -924,8 +982,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
924 |
'Barcode' => $barcode,
|
925 |
'CollectionTimeStampEnd' => '',
|
926 |
'CollectionTimeStampStart' => '',
|
927 |
-
'DownPartnerBarcode' =>
|
928 |
-
'DownPartnerID' =>
|
929 |
'ProductCodeDelivery' => $postnlShipment->getProductCode(),
|
930 |
'Contacts' => array(
|
931 |
'Contact' => $this->_getContact($shippingAddress, $postnlShipment, $order),
|
@@ -980,11 +1038,23 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
980 |
$shipmentData['Customs'] = $this->_getCustoms($postnlShipment);
|
981 |
}
|
982 |
|
|
|
|
|
|
|
983 |
$productOptions = $this->_getProductOptions($postnlShipment);
|
984 |
if ($productOptions) {
|
985 |
$shipmentData['ProductOptions'] = $productOptions;
|
986 |
}
|
987 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
988 |
return $shipmentData;
|
989 |
}
|
990 |
|
@@ -1043,16 +1113,38 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1043 |
|
1044 |
$type = $postnlOrder->getType();
|
1045 |
$availableProductOptions = $this->getAvailableProductOptions();
|
1046 |
-
if (!
|
1047 |
return false;
|
1048 |
}
|
1049 |
|
1050 |
$productOptions = array(
|
1051 |
'ProductOption' => $availableProductOptions[$type]
|
1052 |
);
|
|
|
1053 |
return $productOptions;
|
1054 |
}
|
1055 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1056 |
/**
|
1057 |
* Gets an array containing required address data.
|
1058 |
*
|
@@ -1073,7 +1165,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1073 |
}
|
1074 |
|
1075 |
/**
|
1076 |
-
* Determine which address to use. Currently only 'Sender', 'Alternative', 'PakjeGemak' and '
|
1077 |
* supported.
|
1078 |
*/
|
1079 |
$streetData = false;
|
@@ -1154,6 +1246,37 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1154 |
|
1155 |
$address = new Varien_Object($returnAddressData);
|
1156 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1157 |
case 'PakjeGemak': //no break
|
1158 |
case 'Receiver': //no break
|
1159 |
default:
|
@@ -1184,7 +1307,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1184 |
|
1185 |
$addressArray = array(
|
1186 |
'FirstName' => $address->getFirstname(),
|
1187 |
-
'Name' => $address->getLastname(),
|
1188 |
'CompanyName' => $address->getCompany(),
|
1189 |
'Street' => $streetData['streetname'],
|
1190 |
'HouseNr' => $streetData['housenumber'],
|
@@ -1415,14 +1538,25 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1415 |
* @param Mage_Sales_Model_Order_Address $address
|
1416 |
*
|
1417 |
* @return array
|
|
|
1418 |
*/
|
1419 |
protected function _getStreetData($address)
|
1420 |
{
|
|
|
1421 |
$helper = Mage::helper('postnl/cif');
|
1422 |
$storeId = $this->getStoreId();
|
1423 |
|
1424 |
$streetData = $helper->getStreetData($storeId, $address, false);
|
1425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1426 |
return $streetData;
|
1427 |
}
|
1428 |
|
@@ -1493,10 +1627,9 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1493 |
$itemCount = 0;
|
1494 |
$content = array();
|
1495 |
|
1496 |
-
/**
|
1497 |
-
* @var Mage_Sales_Model_Order_Shipment_Item $item
|
1498 |
-
*/
|
1499 |
$items = $shipment->getItemsCollection();
|
|
|
1500 |
foreach ($items as $key => $item) {
|
1501 |
if ($item->isDeleted() || $item->getOrderItem()->getProductType() == 'bundle') {
|
1502 |
$items->removeItemByKey($key);
|
@@ -1505,6 +1638,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1505 |
|
1506 |
$items = $this->_sortCustomsItems($items);
|
1507 |
|
|
|
1508 |
$helper = Mage::helper('postnl');
|
1509 |
|
1510 |
/**
|
@@ -1591,6 +1725,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1591 |
* Get all products linked to the requested items.
|
1592 |
*/
|
1593 |
$productIds = $items->getColumnValues('product_id');
|
|
|
1594 |
$products = Mage::getResourceModel('catalog/product_collection')
|
1595 |
->setStoreId($this->getStoreId())
|
1596 |
->addFieldToFilter('entity_id', array('in' => $productIds))
|
@@ -1603,6 +1738,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1603 |
* Get the attribute values of the requested sorting attribute.
|
1604 |
*/
|
1605 |
$attributeValues = array();
|
|
|
1606 |
foreach ($products as $product) {
|
1607 |
$attributeValues[$product->getId()] = $product->getDataUsingMethod($sortingAttribute);
|
1608 |
}
|
@@ -1729,12 +1865,14 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1729 |
$customsValue = $product->getDataUsingMethod($customsValueAttribute);
|
1730 |
|
1731 |
if (empty($customsValue)) {
|
|
|
|
|
1732 |
$productId = $shipmentItem->getProductId();
|
1733 |
/** @noinspection HtmlUnknownTarget */
|
1734 |
throw new TIG_PostNL_Exception(
|
1735 |
Mage::helper('postnl')->__(
|
1736 |
'Missing customs value for product <a href="%s" target="_blank">#%s</a>.',
|
1737 |
-
|
1738 |
$productId
|
1739 |
),
|
1740 |
'POSTNL-0092'
|
@@ -1767,12 +1905,14 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1767 |
$description = $product->getDataUsingMethod($descriptionAttribute);
|
1768 |
|
1769 |
if (empty($description)) {
|
|
|
|
|
1770 |
$productId = $shipmentItem->getProductId();
|
1771 |
/** @noinspection HtmlUnknownTarget */
|
1772 |
throw new TIG_PostNL_Exception(
|
1773 |
Mage::helper('postnl')->__(
|
1774 |
'Missing customs description for product <a href="%s" target="_blank">#%s</a>.',
|
1775 |
-
|
1776 |
$productId
|
1777 |
),
|
1778 |
'POSTNL-0092'
|
@@ -1795,6 +1935,19 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1795 |
return $customerCode;
|
1796 |
}
|
1797 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1798 |
/**
|
1799 |
* Gets the customer number from system/config
|
1800 |
*
|
@@ -1808,6 +1961,19 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1808 |
return $customerNumber;
|
1809 |
}
|
1810 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1811 |
/**
|
1812 |
* Gets the collection location from system/config
|
1813 |
*
|
@@ -2082,6 +2248,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
2082 |
* For custom references we need to replace several optional variables
|
2083 |
*/
|
2084 |
if ($referenceType == 'custom') {
|
|
|
2085 |
$store = Mage::getModel('core/store')->load($storeId);
|
2086 |
|
2087 |
$reference = str_replace('{{var shipment_increment_id}}', $shipment->getIncrementId(), $reference);
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class containing all default methods used for CIF communication by this extension.
|
63 |
* Constants containing xpaths to cif configuration options.
|
64 |
*/
|
65 |
const XPATH_CUSTOMER_CODE = 'postnl/cif/customer_code';
|
66 |
+
const XPATH_DUTCH_CUSTOMER_CODE = 'postnl/cif/dutch_customer_code';
|
67 |
const XPATH_CUSTOMER_NUMBER = 'postnl/cif/customer_number';
|
68 |
+
const XPATH_DUTCH_CUSTOMER_NUMBER = 'postnl/cif/dutch_customer_number';
|
69 |
const XPATH_COLLECTION_LOCATION = 'postnl/cif/collection_location';
|
70 |
const XPATH_GLOBAL_BARCODE_TYPE = 'postnl/cif_globalpack_settings/global_barcode_type';
|
71 |
const XPATH_GLOBAL_BARCODE_RANGE = 'postnl/cif_globalpack_settings/global_barcode_range';
|
157 |
'Collection' => '04',
|
158 |
'Return' => '08',
|
159 |
'Delivery' => '09', // Post office address. For use with PakjeGemak.
|
160 |
+
'Dutch' => '02',
|
161 |
);
|
162 |
|
163 |
/**
|
254 |
'Characteristic' => '101',
|
255 |
'Option' => '008',
|
256 |
),
|
257 |
+
'Sameday' => array(
|
258 |
+
array (
|
259 |
+
'Characteristic' => '118',
|
260 |
+
'Option' => '015',
|
261 |
+
),
|
262 |
+
array (
|
263 |
+
'Characteristic' => '118',
|
264 |
+
'Option' => '006',
|
265 |
+
),
|
266 |
+
),
|
267 |
+
'Food' => array(
|
268 |
+
array (
|
269 |
+
'Characteristic' => '118',
|
270 |
+
'Option' => '015',
|
271 |
+
),
|
272 |
+
array (
|
273 |
+
'Characteristic' => '118',
|
274 |
+
'Option' => '006',
|
275 |
+
),
|
276 |
+
),
|
277 |
+
'Cooledfood' => array(
|
278 |
+
array (
|
279 |
+
'Characteristic' => '118',
|
280 |
+
'Option' => '015',
|
281 |
+
),
|
282 |
+
array (
|
283 |
+
'Characteristic' => '118',
|
284 |
+
'Option' => '006',
|
285 |
+
),
|
286 |
+
),
|
287 |
);
|
288 |
|
289 |
/**
|
605 |
);
|
606 |
} else {
|
607 |
$cifShipment = array(
|
608 |
+
'Shipment' => $this->_getShipment($postnlShipment, $barcode, $mainBarcode, $shipmentNumber)
|
609 |
);
|
610 |
}
|
611 |
|
841 |
*/
|
842 |
protected function _getMessage($barcode, $extra = array())
|
843 |
{
|
844 |
+
/** @var Mage_Core_Helper_Http $helper */
|
845 |
+
$helper = Mage::helper('core/http');
|
846 |
$messageIdString = uniqid(
|
847 |
'postnl_'
|
848 |
+
. ip2long($helper->getServerAddr())
|
849 |
)
|
850 |
. $this->_getCustomerNumber()
|
851 |
. $barcode
|
852 |
. microtime();
|
853 |
|
854 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
855 |
+
$dateModel = Mage::getModel('core/date');
|
856 |
$message = array(
|
857 |
'MessageID' => md5($messageIdString),
|
858 |
+
'MessageTimeStamp' => date('d-m-Y H:i:s', $dateModel->gmtTimestamp()),
|
859 |
);
|
860 |
|
861 |
if ($extra) {
|
886 |
);
|
887 |
|
888 |
$customer = array_merge($customer, $additionalCustomerData);
|
889 |
+
|
890 |
+
/**
|
891 |
+
* This is an edge case:
|
892 |
+
*
|
893 |
+
* If the domestic country is BE, the shipment is being sent to Netherlands and the
|
894 |
+
* option "Use Dutch products" is enabled, we must fool CIF and return the alternative customer id,
|
895 |
+
* customer code and the Dutch alternative address.
|
896 |
+
*/
|
897 |
+
if (
|
898 |
+
$this->getHelper()->getDomesticCountry() == 'BE' &&
|
899 |
+
$shipment->getShippingAddress()->getCountryId() == 'NL' &&
|
900 |
+
Mage::helper('postnl/deliveryoptions')->canUseDutchProducts()
|
901 |
+
) {
|
902 |
+
$customer['CustomerCode'] = $this->_getDutchCustomerCode();
|
903 |
+
$customer['CustomerNumber'] = $this->_getDutchCustomerNumber();
|
904 |
+
$customer['Address'] = $this->_getAddress('Dutch');
|
905 |
+
}
|
906 |
}
|
907 |
|
908 |
return $customer;
|
938 |
/**
|
939 |
* Get the parcel weight and then convert it to grams.
|
940 |
*/
|
941 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
942 |
+
$helper = Mage::helper('postnl');
|
943 |
$parcelWeight = Mage::getStoreConfig(self::XPATH_WEIGHT_PER_PARCEL, $postnlShipment->getStoreId());
|
944 |
+
$parcelWeight = $helper->standardizeWeight($parcelWeight, $shipment->getStoreId(), true);
|
945 |
|
946 |
/**
|
947 |
* All parcels except for the last one weigh a configured amount. The last parcel weighs the remainder
|
964 |
* Get and format this shipment's delivery date if available.
|
965 |
*/
|
966 |
$deliveryDate = null;
|
967 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $deliveryOptionsHelper */
|
968 |
+
$deliveryOptionsHelper = Mage::helper('postnl/deliveryOptions');
|
969 |
+
if ($deliveryOptionsHelper->canUseDeliveryDays(false)) {
|
970 |
$deliveryDate = $postnlShipment->getDeliveryDate();
|
971 |
if ($deliveryDate) {
|
972 |
$deliveryTime = new DateTime($deliveryDate, new DateTimeZone('UTC'));
|
982 |
'Barcode' => $barcode,
|
983 |
'CollectionTimeStampEnd' => '',
|
984 |
'CollectionTimeStampStart' => '',
|
985 |
+
'DownPartnerBarcode' => $postnlShipment->getDownPartnerBarcode(),
|
986 |
+
'DownPartnerID' => $postnlShipment->getDownPartnerId(),
|
987 |
'ProductCodeDelivery' => $postnlShipment->getProductCode(),
|
988 |
'Contacts' => array(
|
989 |
'Contact' => $this->_getContact($shippingAddress, $postnlShipment, $order),
|
1038 |
$shipmentData['Customs'] = $this->_getCustoms($postnlShipment);
|
1039 |
}
|
1040 |
|
1041 |
+
/**
|
1042 |
+
* Add product options.
|
1043 |
+
*/
|
1044 |
$productOptions = $this->_getProductOptions($postnlShipment);
|
1045 |
if ($productOptions) {
|
1046 |
$shipmentData['ProductOptions'] = $productOptions;
|
1047 |
}
|
1048 |
|
1049 |
+
/**
|
1050 |
+
* Add 'DownPartner' data.
|
1051 |
+
*/
|
1052 |
+
$downPartnerData = $this->_getDownPartnerData($postnlShipment);
|
1053 |
+
if ($downPartnerData) {
|
1054 |
+
$shipmentData['DownPartnerID'] = $downPartnerData['id'];
|
1055 |
+
$shipmentData['DownPartnerLocation'] = $downPartnerData['location'];
|
1056 |
+
}
|
1057 |
+
|
1058 |
return $shipmentData;
|
1059 |
}
|
1060 |
|
1113 |
|
1114 |
$type = $postnlOrder->getType();
|
1115 |
$availableProductOptions = $this->getAvailableProductOptions();
|
1116 |
+
if (!isset($availableProductOptions[$type])) {
|
1117 |
return false;
|
1118 |
}
|
1119 |
|
1120 |
$productOptions = array(
|
1121 |
'ProductOption' => $availableProductOptions[$type]
|
1122 |
);
|
1123 |
+
|
1124 |
return $productOptions;
|
1125 |
}
|
1126 |
|
1127 |
+
/**
|
1128 |
+
* Get 'DownPartner' data from the specified PostNL shipment if available.
|
1129 |
+
*
|
1130 |
+
* @param TIG_PostnL_Model_Core_Shipment $postnlShipment
|
1131 |
+
*
|
1132 |
+
* @return array|bool
|
1133 |
+
*/
|
1134 |
+
protected function _getDownPartnerData(TIG_PostnL_Model_Core_Shipment $postnlShipment)
|
1135 |
+
{
|
1136 |
+
if (!$postnlShipment->hasPgLocationCode() || !$postnlShipment->hasPgRetailNetworkId()) {
|
1137 |
+
return false;
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
$downPartnerData = array(
|
1141 |
+
'id' => $postnlShipment->getPgRetailNetworkId(),
|
1142 |
+
'location' => $postnlShipment->getPgLocationCode(),
|
1143 |
+
);
|
1144 |
+
|
1145 |
+
return $downPartnerData;
|
1146 |
+
}
|
1147 |
+
|
1148 |
/**
|
1149 |
* Gets an array containing required address data.
|
1150 |
*
|
1165 |
}
|
1166 |
|
1167 |
/**
|
1168 |
+
* Determine which address to use. Currently only 'Sender', 'Alternative', 'PakjeGemak', 'Receiver' and 'Dutch' are fully
|
1169 |
* supported.
|
1170 |
*/
|
1171 |
$streetData = false;
|
1246 |
|
1247 |
$address = new Varien_Object($returnAddressData);
|
1248 |
break;
|
1249 |
+
case 'Dutch':
|
1250 |
+
/**
|
1251 |
+
* Get all cif_address fields with the 'dutch_address_' prefix as an array and convert that to a
|
1252 |
+
* Varien_Object. This allows the _prepareAddress method to access this data in the same way as a
|
1253 |
+
* conventional Mage_Sales_Model_Order_Address object.
|
1254 |
+
*/
|
1255 |
+
$dutchAddress = Mage::getStoreConfig(self::XPATH_SENDER_ADDRESS, $this->getStoreId());
|
1256 |
+
|
1257 |
+
$streetData = array(
|
1258 |
+
'streetname' => $dutchAddress['dutch_address_streetname'],
|
1259 |
+
'housenumber' => $dutchAddress['dutch_address_housenumber'],
|
1260 |
+
'housenumberExtension' => $dutchAddress['dutch_address_housenumber_extension'],
|
1261 |
+
'fullStreet' => '',
|
1262 |
+
);
|
1263 |
+
|
1264 |
+
$dutchAddressData = array();
|
1265 |
+
foreach($dutchAddress as $field => $value) {
|
1266 |
+
if (strpos($field, 'dutch_address_') === false) {
|
1267 |
+
continue;
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
$dutchAddressData[substr($field, 14)] = $value;
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
/**
|
1274 |
+
* Dutch is mandatory.
|
1275 |
+
*/
|
1276 |
+
$dutchAddressData['country'] = 'NL';
|
1277 |
+
|
1278 |
+
$address = new Varien_Object($dutchAddressData);
|
1279 |
+
break;
|
1280 |
case 'PakjeGemak': //no break
|
1281 |
case 'Receiver': //no break
|
1282 |
default:
|
1307 |
|
1308 |
$addressArray = array(
|
1309 |
'FirstName' => $address->getFirstname(),
|
1310 |
+
'Name' => $address->getMiddlename() . ' ' . $address->getLastname(),
|
1311 |
'CompanyName' => $address->getCompany(),
|
1312 |
'Street' => $streetData['streetname'],
|
1313 |
'HouseNr' => $streetData['housenumber'],
|
1538 |
* @param Mage_Sales_Model_Order_Address $address
|
1539 |
*
|
1540 |
* @return array
|
1541 |
+
* @throws TIG_PostNL_Exception
|
1542 |
*/
|
1543 |
protected function _getStreetData($address)
|
1544 |
{
|
1545 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
1546 |
$helper = Mage::helper('postnl/cif');
|
1547 |
$storeId = $this->getStoreId();
|
1548 |
|
1549 |
$streetData = $helper->getStreetData($storeId, $address, false);
|
1550 |
|
1551 |
+
$houseNumberRequiredCountries = $helper->getHouseNumberRequiredCountries($storeId);
|
1552 |
+
|
1553 |
+
if (in_array($address->getCountryId(), $houseNumberRequiredCountries) && empty($streetData['housenumber'])) {
|
1554 |
+
throw new TIG_PostNL_Exception(
|
1555 |
+
$helper->__("House number is required for the destination country (%s).", $address->getCountryId()),
|
1556 |
+
'POSTNL-0239'
|
1557 |
+
);
|
1558 |
+
}
|
1559 |
+
|
1560 |
return $streetData;
|
1561 |
}
|
1562 |
|
1627 |
$itemCount = 0;
|
1628 |
$content = array();
|
1629 |
|
1630 |
+
/** @var Mage_Sales_Model_Resource_Order_Shipment_Item_Collection $items */
|
|
|
|
|
1631 |
$items = $shipment->getItemsCollection();
|
1632 |
+
/** @var Mage_Sales_Model_Order_Shipment_Item $item */
|
1633 |
foreach ($items as $key => $item) {
|
1634 |
if ($item->isDeleted() || $item->getOrderItem()->getProductType() == 'bundle') {
|
1635 |
$items->removeItemByKey($key);
|
1638 |
|
1639 |
$items = $this->_sortCustomsItems($items);
|
1640 |
|
1641 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1642 |
$helper = Mage::helper('postnl');
|
1643 |
|
1644 |
/**
|
1725 |
* Get all products linked to the requested items.
|
1726 |
*/
|
1727 |
$productIds = $items->getColumnValues('product_id');
|
1728 |
+
/** @var Mage_Catalog_Model_Resource_Product_Collection $products */
|
1729 |
$products = Mage::getResourceModel('catalog/product_collection')
|
1730 |
->setStoreId($this->getStoreId())
|
1731 |
->addFieldToFilter('entity_id', array('in' => $productIds))
|
1738 |
* Get the attribute values of the requested sorting attribute.
|
1739 |
*/
|
1740 |
$attributeValues = array();
|
1741 |
+
/** @var Mage_Catalog_Model_Product $product */
|
1742 |
foreach ($products as $product) {
|
1743 |
$attributeValues[$product->getId()] = $product->getDataUsingMethod($sortingAttribute);
|
1744 |
}
|
1865 |
$customsValue = $product->getDataUsingMethod($customsValueAttribute);
|
1866 |
|
1867 |
if (empty($customsValue)) {
|
1868 |
+
/** @var Mage_Adminhtml_Helper_Data $adminhtmlhelper */
|
1869 |
+
$adminhtmlhelper = Mage::helper('adminhtml');
|
1870 |
$productId = $shipmentItem->getProductId();
|
1871 |
/** @noinspection HtmlUnknownTarget */
|
1872 |
throw new TIG_PostNL_Exception(
|
1873 |
Mage::helper('postnl')->__(
|
1874 |
'Missing customs value for product <a href="%s" target="_blank">#%s</a>.',
|
1875 |
+
$adminhtmlhelper->getUrl('adminhtml/catalog_product/edit', array('id' => $productId)),
|
1876 |
$productId
|
1877 |
),
|
1878 |
'POSTNL-0092'
|
1905 |
$description = $product->getDataUsingMethod($descriptionAttribute);
|
1906 |
|
1907 |
if (empty($description)) {
|
1908 |
+
/** @var Mage_Adminhtml_Helper_Data $adminhtmlhelper */
|
1909 |
+
$adminhtmlhelper = Mage::helper('adminhtml');
|
1910 |
$productId = $shipmentItem->getProductId();
|
1911 |
/** @noinspection HtmlUnknownTarget */
|
1912 |
throw new TIG_PostNL_Exception(
|
1913 |
Mage::helper('postnl')->__(
|
1914 |
'Missing customs description for product <a href="%s" target="_blank">#%s</a>.',
|
1915 |
+
$adminhtmlhelper->getUrl('adminhtml/catalog_product/edit', array('id' => $productId)),
|
1916 |
$productId
|
1917 |
),
|
1918 |
'POSTNL-0092'
|
1935 |
return $customerCode;
|
1936 |
}
|
1937 |
|
1938 |
+
/**
|
1939 |
+
* Gets the dutch customer code from system/config
|
1940 |
+
*
|
1941 |
+
* @return string
|
1942 |
+
*/
|
1943 |
+
protected function _getDutchCustomerCode()
|
1944 |
+
{
|
1945 |
+
$storeId = $this->getStoreId();
|
1946 |
+
$customerCode = (string) Mage::getStoreConfig(self::XPATH_DUTCH_CUSTOMER_CODE, $storeId);
|
1947 |
+
|
1948 |
+
return $customerCode;
|
1949 |
+
}
|
1950 |
+
|
1951 |
/**
|
1952 |
* Gets the customer number from system/config
|
1953 |
*
|
1961 |
return $customerNumber;
|
1962 |
}
|
1963 |
|
1964 |
+
/**
|
1965 |
+
* Gets the dutch customer number from system/config
|
1966 |
+
*
|
1967 |
+
* @return string
|
1968 |
+
*/
|
1969 |
+
protected function _getDutchCustomerNumber()
|
1970 |
+
{
|
1971 |
+
$storeId = $this->getStoreId();
|
1972 |
+
$customerNumber = (string) Mage::getStoreConfig(self::XPATH_DUTCH_CUSTOMER_NUMBER, $storeId);
|
1973 |
+
|
1974 |
+
return $customerNumber;
|
1975 |
+
}
|
1976 |
+
|
1977 |
/**
|
1978 |
* Gets the collection location from system/config
|
1979 |
*
|
2248 |
* For custom references we need to replace several optional variables
|
2249 |
*/
|
2250 |
if ($referenceType == 'custom') {
|
2251 |
+
/** @var Mage_Core_Model_Store $store */
|
2252 |
$store = Mage::getModel('core/store')->load($storeId);
|
2253 |
|
2254 |
$reference = str_replace('{{var shipment_increment_id}}', $shipment->getIncrementId(), $reference);
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Base CIF model. Contains general code for communicating with the CIF API
|
@@ -264,7 +264,9 @@ abstract class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
264 |
}
|
265 |
|
266 |
$configPassword = trim($configPassword);
|
267 |
-
|
|
|
|
|
268 |
$password = sha1($decryptedPassword);
|
269 |
|
270 |
return $password;
|
@@ -554,6 +556,10 @@ abstract class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
554 |
$n = 0;
|
555 |
$responseWarnings = array();
|
556 |
foreach ($warnings as $warning) {
|
|
|
|
|
|
|
|
|
557 |
foreach ($warning->getElementsByTagName('Code') as $code) {
|
558 |
$responseWarnings[$n]['code'] = $code->nodeValue;
|
559 |
}
|
@@ -584,6 +590,21 @@ abstract class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
584 |
return $this;
|
585 |
}
|
586 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
587 |
/**
|
588 |
* Handle a SoapFault thrown by CIF.
|
589 |
*
|
@@ -599,6 +620,7 @@ abstract class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
599 |
{
|
600 |
$logException = true;
|
601 |
|
|
|
602 |
$cifHelper = Mage::helper('postnl/cif');
|
603 |
$exception = new TIG_PostNL_Model_Core_Cif_Exception($e->getMessage(), null, $e);
|
604 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Base CIF model. Contains general code for communicating with the CIF API
|
264 |
}
|
265 |
|
266 |
$configPassword = trim($configPassword);
|
267 |
+
/** @var Mage_Core_Helper_Data $coreHelper */
|
268 |
+
$coreHelper = Mage::helper('core');
|
269 |
+
$decryptedPassword = $coreHelper->decrypt($configPassword);
|
270 |
$password = sha1($decryptedPassword);
|
271 |
|
272 |
return $password;
|
556 |
$n = 0;
|
557 |
$responseWarnings = array();
|
558 |
foreach ($warnings as $warning) {
|
559 |
+
if ($this->hasEpsCombiLabelWarning($warning)) {
|
560 |
+
continue;
|
561 |
+
}
|
562 |
+
|
563 |
foreach ($warning->getElementsByTagName('Code') as $code) {
|
564 |
$responseWarnings[$n]['code'] = $code->nodeValue;
|
565 |
}
|
590 |
return $this;
|
591 |
}
|
592 |
|
593 |
+
/**
|
594 |
+
* Check if the supplied warning has an EPS Combi Label warning. We don't want to show it so skip it.
|
595 |
+
*
|
596 |
+
* @param $warning
|
597 |
+
*
|
598 |
+
* @return bool
|
599 |
+
*/
|
600 |
+
protected function hasEpsCombiLabelWarning($warning) {
|
601 |
+
foreach ($warning->getElementsByTagName('Code') as $code) {
|
602 |
+
if ($code->nodeValue == TIG_PostNL_Model_Core_Shipment::EPS_COMBI_LABEL_WARNING_CODE) {
|
603 |
+
return true;
|
604 |
+
}
|
605 |
+
}
|
606 |
+
}
|
607 |
+
|
608 |
/**
|
609 |
* Handle a SoapFault thrown by CIF.
|
610 |
*
|
620 |
{
|
621 |
$logException = true;
|
622 |
|
623 |
+
/** @var TIG_PostNL_Helper_Cif $cifHelper */
|
624 |
$cifHelper = Mage::helper('postnl/cif');
|
625 |
$exception = new TIG_PostNL_Model_Core_Cif_Exception($e->getMessage(), null, $e);
|
626 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Core_Label setLabelSize(string $value)
|
@@ -487,9 +487,13 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
487 |
* Open a new pdf object and assign some basic values.
|
488 |
*/
|
489 |
$pdf = new TIG_PostNL_Fpdi(); //lib/TIG/PostNL/Fpdi
|
|
|
490 |
$pdf->open();
|
|
|
491 |
$pdf->SetTitle('PostNL Shipping Labels');
|
|
|
492 |
$pdf->SetAuthor('PostNL');
|
|
|
493 |
$pdf->SetCreator('PostNL');
|
494 |
|
495 |
if (!is_array($labels)
|
@@ -536,9 +540,13 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
536 |
* Open a new pdf object and assign some basic values.
|
537 |
*/
|
538 |
$pdf = new TIG_PostNL_Fpdi(); //lib/TIG/PostNL/Fpdi
|
|
|
539 |
$pdf->open();
|
|
|
540 |
$pdf->SetTitle('PostNL Packingslip');
|
|
|
541 |
$pdf->SetAuthor('PostNL');
|
|
|
542 |
$pdf->SetCreator('PostNL');
|
543 |
|
544 |
$pdf->addOrientedPage('P', 'A4');
|
@@ -591,6 +599,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
591 |
return $label;
|
592 |
}
|
593 |
|
|
|
594 |
/**
|
595 |
* Adds multiple labels to the pdf
|
596 |
*
|
@@ -611,7 +620,9 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
611 |
* However, for safety reasons a limit of 200 is used. By default you shouldn't be able to select more than 200
|
612 |
* in the shipment grid.
|
613 |
*/
|
614 |
-
|
|
|
|
|
615 |
throw new TIG_PostNL_Exception(
|
616 |
Mage::helper('postnl')->__(
|
617 |
'Maximum amount of labels exceeded. Maximum allowed: 200. Requested: %s',
|
@@ -631,6 +642,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
631 |
return $pdf;
|
632 |
}
|
633 |
|
|
|
634 |
/**
|
635 |
* Adds a label to the pdf by storing it in a temporary pdf file and then adding it to the master pdf object. Each
|
636 |
* label type has it's own properties and size. For some we need to add another A4-size page first, for others we
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Core_Label setLabelSize(string $value)
|
487 |
* Open a new pdf object and assign some basic values.
|
488 |
*/
|
489 |
$pdf = new TIG_PostNL_Fpdi(); //lib/TIG/PostNL/Fpdi
|
490 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
491 |
$pdf->open();
|
492 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
493 |
$pdf->SetTitle('PostNL Shipping Labels');
|
494 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
495 |
$pdf->SetAuthor('PostNL');
|
496 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
497 |
$pdf->SetCreator('PostNL');
|
498 |
|
499 |
if (!is_array($labels)
|
540 |
* Open a new pdf object and assign some basic values.
|
541 |
*/
|
542 |
$pdf = new TIG_PostNL_Fpdi(); //lib/TIG/PostNL/Fpdi
|
543 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
544 |
$pdf->open();
|
545 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
546 |
$pdf->SetTitle('PostNL Packingslip');
|
547 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
548 |
$pdf->SetAuthor('PostNL');
|
549 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
550 |
$pdf->SetCreator('PostNL');
|
551 |
|
552 |
$pdf->addOrientedPage('P', 'A4');
|
599 |
return $label;
|
600 |
}
|
601 |
|
602 |
+
/** @noinspection PhpUndefinedClassInspection */
|
603 |
/**
|
604 |
* Adds multiple labels to the pdf
|
605 |
*
|
620 |
* However, for safety reasons a limit of 200 is used. By default you shouldn't be able to select more than 200
|
621 |
* in the shipment grid.
|
622 |
*/
|
623 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
624 |
+
$helper = Mage::helper('postnl/cif');
|
625 |
+
if(count($labels) > self::MAX_LABEL_COUNT && !$helper->allowInfinitePrinting()) {
|
626 |
throw new TIG_PostNL_Exception(
|
627 |
Mage::helper('postnl')->__(
|
628 |
'Maximum amount of labels exceeded. Maximum allowed: 200. Requested: %s',
|
642 |
return $pdf;
|
643 |
}
|
644 |
|
645 |
+
/** @noinspection PhpUndefinedClassInspection */
|
646 |
/**
|
647 |
* Adds a label to the pdf by storing it in a temporary pdf file and then adding it to the master pdf object. Each
|
648 |
* label type has it's own properties and size. For some we need to add another A4-size page first, for others we
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_Barcode
|
@@ -51,6 +51,7 @@ class TIG_PostNL_Model_Core_Observer_Barcode
|
|
51 |
*/
|
52 |
public function generateBarcode(Varien_Event_Observer $observer)
|
53 |
{
|
|
|
54 |
$helper = Mage::helper('postnl/cif');
|
55 |
|
56 |
/**
|
@@ -63,6 +64,7 @@ class TIG_PostNL_Model_Core_Observer_Barcode
|
|
63 |
/**
|
64 |
* @var Mage_Sales_Model_Order_Shipment $shipment
|
65 |
*/
|
|
|
66 |
$shipment = $observer->getShipment();
|
67 |
|
68 |
/**
|
@@ -74,19 +76,23 @@ class TIG_PostNL_Model_Core_Observer_Barcode
|
|
74 |
* If this shipment's order was not placed with PostNL, remove any PakjeGemak addresses that may have been
|
75 |
* saved.
|
76 |
*/
|
77 |
-
|
|
|
|
|
78 |
return $this;
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
* Check if a postnl shipment exists for this shipment.
|
83 |
*/
|
84 |
-
if (
|
85 |
return $this;
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
* Create a new postnl shipment entity.
|
|
|
|
|
90 |
*/
|
91 |
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
92 |
$postnlShipment->setShipmentId($shipment->getId());
|
@@ -124,6 +130,14 @@ class TIG_PostNL_Model_Core_Observer_Barcode
|
|
124 |
if ($postnlOrder->hasExpectedDeliveryTimeEnd()) {
|
125 |
$postnlShipment->setExpectedDeliveryTimeEnd($postnlOrder->getExpectedDeliveryTimeEnd());
|
126 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
}
|
128 |
|
129 |
/**
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_Barcode
|
51 |
*/
|
52 |
public function generateBarcode(Varien_Event_Observer $observer)
|
53 |
{
|
54 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
55 |
$helper = Mage::helper('postnl/cif');
|
56 |
|
57 |
/**
|
64 |
/**
|
65 |
* @var Mage_Sales_Model_Order_Shipment $shipment
|
66 |
*/
|
67 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
68 |
$shipment = $observer->getShipment();
|
69 |
|
70 |
/**
|
76 |
* If this shipment's order was not placed with PostNL, remove any PakjeGemak addresses that may have been
|
77 |
* saved.
|
78 |
*/
|
79 |
+
/** @var TIG_PostNL_Helper_Carrier $carrierHelper */
|
80 |
+
$carrierHelper = Mage::helper('postnl/carrier');
|
81 |
+
if (!$carrierHelper->isPostnlShippingMethod($shippingMethod)) {
|
82 |
return $this;
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
* Check if a postnl shipment exists for this shipment.
|
87 |
*/
|
88 |
+
if ($helper->postnlShipmentExists($shipment->getId())) {
|
89 |
return $this;
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
* Create a new postnl shipment entity.
|
94 |
+
*
|
95 |
+
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
96 |
*/
|
97 |
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
98 |
$postnlShipment->setShipmentId($shipment->getId());
|
130 |
if ($postnlOrder->hasExpectedDeliveryTimeEnd()) {
|
131 |
$postnlShipment->setExpectedDeliveryTimeEnd($postnlOrder->getExpectedDeliveryTimeEnd());
|
132 |
}
|
133 |
+
|
134 |
+
if ($postnlOrder->hasPgLocationCode()) {
|
135 |
+
$postnlShipment->setPgLocationCode($postnlOrder->getPgLocationCode());
|
136 |
+
}
|
137 |
+
|
138 |
+
if ($postnlOrder->hasPgRetailNetworkId()) {
|
139 |
+
$postnlShipment->setPgRetailNetworkId($postnlOrder->getPgRetailNetworkId());
|
140 |
+
}
|
141 |
}
|
142 |
|
143 |
/**
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_Cache
|
@@ -49,9 +49,10 @@ class TIG_PostNL_Model_Core_Observer_Cache
|
|
49 |
*/
|
50 |
public function cleanCache()
|
51 |
{
|
|
|
52 |
$cache = Mage::getSingleton('postnl_core/cache');
|
53 |
$cache->cleanCache();
|
54 |
|
55 |
return $this;
|
56 |
}
|
57 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_Cache
|
49 |
*/
|
50 |
public function cleanCache()
|
51 |
{
|
52 |
+
/** @var TIG_PostNL_Model_Core_Cache $cache */
|
53 |
$cache = Mage::getSingleton('postnl_core/cache');
|
54 |
$cache->cleanCache();
|
55 |
|
56 |
return $this;
|
57 |
}
|
58 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_Cron
|
@@ -131,6 +131,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
131 |
*/
|
132 |
public function cleanTempLabels()
|
133 |
{
|
|
|
134 |
$helper = Mage::helper('postnl');
|
135 |
|
136 |
/**
|
@@ -171,7 +172,8 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
171 |
*
|
172 |
* @var $labelModel TIG_PostNL_Model_Core_Label
|
173 |
*/
|
174 |
-
|
|
|
175 |
$tempLabelName = $labelModel::TEMP_LABEL_FILENAME;
|
176 |
|
177 |
$helper->cronLog('Attempting to read temp label files from %s.', $tempLabelsDirectory);
|
@@ -241,6 +243,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
241 |
*/
|
242 |
public function cleanOldLocks()
|
243 |
{
|
|
|
244 |
$helper = Mage::helper('postnl');
|
245 |
|
246 |
/**
|
@@ -289,7 +292,9 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
289 |
* Locks may only exist for 3600 seconds (1 hour) before being removed
|
290 |
*/
|
291 |
$maxFileStorageTime = 3600;
|
292 |
-
$
|
|
|
|
|
293 |
$maxTimestamp = $now - $maxFileStorageTime; //1 hour ago
|
294 |
|
295 |
$helper->cronLog("{$fileCount} locks found.");
|
@@ -330,6 +335,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
330 |
*/
|
331 |
public function getBarcodes()
|
332 |
{
|
|
|
333 |
$helper = Mage::helper('postnl/cif');
|
334 |
|
335 |
/**
|
@@ -356,6 +362,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
356 |
$helper->cronLog("Getting barcodes for {$postnlShipmentCollection->getSize()} shipments.");
|
357 |
|
358 |
$counter = 1000;
|
|
|
359 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
360 |
if (!$postnlShipment->getShipment(false)) {
|
361 |
continue;
|
@@ -405,6 +412,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
405 |
*/
|
406 |
public function updateShippingStatus()
|
407 |
{
|
|
|
408 |
$helper = Mage::helper('postnl');
|
409 |
|
410 |
/**
|
@@ -419,9 +427,10 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
419 |
/**
|
420 |
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
421 |
*/
|
|
|
422 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
423 |
-
$confirmedStatus
|
424 |
-
$deliveredStatus
|
425 |
|
426 |
/**
|
427 |
* Get all postnl shipments with a barcode, that are confirmed and are not yet delivered.
|
@@ -459,6 +468,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
459 |
/**
|
460 |
* Request a shipping status update
|
461 |
*/
|
|
|
462 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
463 |
/**
|
464 |
* Attempt to update the shipping status. Continue with the next one if it fails.
|
@@ -486,7 +496,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
486 |
} catch (Exception $e) {
|
487 |
$postnlShipment->unlock();
|
488 |
|
489 |
-
|
490 |
}
|
491 |
}
|
492 |
|
@@ -502,6 +512,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
502 |
*/
|
503 |
public function updateReturnStatus()
|
504 |
{
|
|
|
505 |
$helper = Mage::helper('postnl');
|
506 |
|
507 |
/**
|
@@ -516,6 +527,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
516 |
/**
|
517 |
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
518 |
*/
|
|
|
519 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
520 |
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
521 |
$deliveredStatus = $postnlShipmentModelClass::SHIPPING_PHASE_DELIVERED;
|
@@ -595,6 +607,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
595 |
/**
|
596 |
* Request a return status update
|
597 |
*/
|
|
|
598 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
599 |
/**
|
600 |
* Attempt to update the return status. Continue with the next one if it fails.
|
@@ -624,7 +637,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
624 |
} catch (Exception $e) {
|
625 |
$postnlShipment->unlock();
|
626 |
|
627 |
-
|
628 |
}
|
629 |
}
|
630 |
|
@@ -644,6 +657,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
644 |
*/
|
645 |
protected function _parseErrorCodes($e, $postnlShipment, $isReturnStatus = false)
|
646 |
{
|
|
|
647 |
$helper = Mage::helper('postnl');
|
648 |
|
649 |
/**
|
@@ -659,6 +673,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
659 |
/**
|
660 |
* @var $cifAbstractModelClassName TIG_PostNL_Model_Core_Cif_Abstract
|
661 |
*/
|
|
|
662 |
$cifAbstractModelClassName = Mage::getConfig()->getModelClassName('postnl_core/cif_abstract');
|
663 |
foreach ($errorNumbers as $errorNumber) {
|
664 |
if ($errorNumber != $cifAbstractModelClassName::SHIPMENT_NOT_FOUND_ERROR_NUMBER) { // Collo not found error
|
@@ -678,7 +693,9 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
678 |
*/
|
679 |
$confirmedAt = strtotime($postnlShipment->getConfirmedAt());
|
680 |
$yesterday = new DateTime('now', new DateTimeZone('UTC'));
|
681 |
-
$
|
|
|
|
|
682 |
->sub(new DateInterval('P1D'));
|
683 |
|
684 |
$yesterday = $yesterday->getTimestamp();
|
@@ -716,6 +733,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
716 |
*/
|
717 |
public function expireConfirmation()
|
718 |
{
|
|
|
719 |
$helper = Mage::helper('postnl/cif');
|
720 |
|
721 |
/**
|
@@ -730,6 +748,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
730 |
/**
|
731 |
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
732 |
*/
|
|
|
733 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
734 |
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
735 |
$collectionPhase = $postnlShipmentModelClass::SHIPPING_PHASE_COLLECTION;
|
@@ -740,7 +759,9 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
740 |
);
|
741 |
|
742 |
$expireTimestamp = new DateTime('now', new DateTimeZone('UTC'));
|
743 |
-
$
|
|
|
|
|
744 |
->sub(new DateInterval("P{$confirmationExpireDays}D"));
|
745 |
|
746 |
$expireDate = $expireTimestamp->format('Y-m-d H:i:s');
|
@@ -789,6 +810,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
789 |
/**
|
790 |
* Reset the shipments to 'unconfirmed' status
|
791 |
*/
|
|
|
792 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
793 |
/**
|
794 |
* Attempt to reset the shipment to a pre-confirmed status
|
@@ -832,6 +854,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
832 |
*/
|
833 |
public function sendTrackAndTraceEmail()
|
834 |
{
|
|
|
835 |
$helper = Mage::helper('postnl');
|
836 |
|
837 |
/**
|
@@ -861,17 +884,20 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
861 |
/**
|
862 |
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
863 |
*/
|
|
|
864 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
865 |
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
866 |
|
|
|
|
|
867 |
$twentyMinutesAgo = new DateTime('now', new DateTimeZone('UTC'));
|
868 |
-
$twentyMinutesAgo->setTimestamp(
|
869 |
->sub(new DateInterval('PT20M'));
|
870 |
|
871 |
$twentyMinutesAgo = $twentyMinutesAgo->format('Y-m-d H:i:s');
|
872 |
|
873 |
$oneDayAgo = new DateTime('now', new DateTimeZone('UTC'));
|
874 |
-
$oneDayAgo->setTimestamp(
|
875 |
->sub(new DateInterval('P1DT20M'));
|
876 |
|
877 |
$oneDayAgo = $oneDayAgo->format('Y-m-d H:i:s');
|
@@ -953,6 +979,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
953 |
/**
|
954 |
* Send the track and trace email for all shipments.
|
955 |
*/
|
|
|
956 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
957 |
if (!$postnlShipment->getShipment(false)) {
|
958 |
continue;
|
@@ -994,6 +1021,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
994 |
*/
|
995 |
public function removeOldLabels()
|
996 |
{
|
|
|
997 |
$helper = Mage::helper('postnl');
|
998 |
|
999 |
/**
|
@@ -1010,11 +1038,13 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1010 |
*
|
1011 |
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
1012 |
*/
|
|
|
1013 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
1014 |
|
1015 |
/**
|
1016 |
* Get the label collection
|
1017 |
*/
|
|
|
1018 |
$labelsCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
|
1019 |
|
1020 |
/**
|
@@ -1022,6 +1052,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1022 |
*/
|
1023 |
$labelsCollection->addFieldToSelect('label_id');
|
1024 |
|
|
|
1025 |
$resource = Mage::getSingleton('core/resource');
|
1026 |
|
1027 |
$select = $labelsCollection->getSelect();
|
@@ -1105,6 +1136,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1105 |
/**
|
1106 |
* Delete the labels
|
1107 |
*/
|
|
|
1108 |
foreach ($labelsCollection as $label) {
|
1109 |
$helper->cronLog("Deleting label #{$label->getId()}.");
|
1110 |
$label->delete();
|
@@ -1123,6 +1155,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1123 |
*/
|
1124 |
public function updateProductAttribute()
|
1125 |
{
|
|
|
1126 |
$helper = Mage::helper('postnl');
|
1127 |
|
1128 |
$helper->cronLog($helper->__('UpdateProductAttribute cron starting...'));
|
@@ -1159,6 +1192,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1159 |
/**
|
1160 |
* Get all products that need to be updated.
|
1161 |
*/
|
|
|
1162 |
$productCollection = Mage::getResourceModel('catalog/product_collection')
|
1163 |
->addStoreFilter(Mage_Core_Model_App::ADMIN_STORE_ID)
|
1164 |
->addFieldToFilter(
|
@@ -1191,12 +1225,13 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1191 |
/**
|
1192 |
* Update the attributes of these products.
|
1193 |
*/
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
|
|
1200 |
} catch (Exception $e) {
|
1201 |
/**
|
1202 |
* If an error occurred not all products were processed, so the cron is not finished quite yet.
|
@@ -1257,11 +1292,12 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1257 |
Mage_Core_Model_App::ADMIN_STORE_ID
|
1258 |
);
|
1259 |
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
|
|
1265 |
|
1266 |
Mage::app()->getCacheInstance()->cleanType('config');
|
1267 |
|
@@ -1276,6 +1312,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1276 |
*/
|
1277 |
public function updateDateTimeZone()
|
1278 |
{
|
|
|
1279 |
$helper = Mage::helper('postnl');
|
1280 |
|
1281 |
$helper->cronLog($helper->__('UpdateDateTimeZone cron starting...'));
|
@@ -1320,11 +1357,12 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1320 |
Mage_Core_Model_App::ADMIN_STORE_ID
|
1321 |
);
|
1322 |
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
|
|
1328 |
}
|
1329 |
|
1330 |
Mage::getConfig()->saveConfig(
|
@@ -1357,8 +1395,10 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1357 |
$postnlShipments->addFieldToFilter('entity_id', array('in' => $ids));
|
1358 |
$postnlShipments->getSelect()->limit(100);
|
1359 |
|
|
|
1360 |
$helper = Mage::helper('postnl');
|
1361 |
|
|
|
1362 |
foreach ($postnlShipments as $postnlShipment) {
|
1363 |
$helper->cronLog($helper->__('Updating shipment ID: %s', $postnlShipment->getId()));
|
1364 |
|
@@ -1427,8 +1467,10 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1427 |
$postnlOrders->addFieldToFilter('entity_id', array('in' => $ids));
|
1428 |
$postnlOrders->getSelect()->limit(100);
|
1429 |
|
|
|
1430 |
$helper = Mage::helper('postnl');
|
1431 |
|
|
|
1432 |
foreach ($postnlOrders as $postnlOrder) {
|
1433 |
$helper->cronLog($helper->__('Updating order ID: %s', $postnlOrder->getId()));
|
1434 |
|
@@ -1490,6 +1532,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1490 |
*/
|
1491 |
public function integrityCheck()
|
1492 |
{
|
|
|
1493 |
$helper = Mage::helper('postnl');
|
1494 |
|
1495 |
/**
|
@@ -1501,6 +1544,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1501 |
|
1502 |
$helper->cronLog($helper->__('IntegrityCheck cron starting...'));
|
1503 |
|
|
|
1504 |
$integrityCheckModel = Mage::getModel('postnl_core/service_integrityCheck');
|
1505 |
try {
|
1506 |
$errors = $integrityCheckModel->integrityCheck();
|
@@ -1523,4 +1567,4 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
1523 |
|
1524 |
return $this;
|
1525 |
}
|
1526 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_Cron
|
131 |
*/
|
132 |
public function cleanTempLabels()
|
133 |
{
|
134 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
135 |
$helper = Mage::helper('postnl');
|
136 |
|
137 |
/**
|
172 |
*
|
173 |
* @var $labelModel TIG_PostNL_Model_Core_Label
|
174 |
*/
|
175 |
+
/** @noinspection PhpParamsInspection */
|
176 |
+
$labelModel = Mage::app()->getConfig()->getModelClassName('postnl_core/label');
|
177 |
$tempLabelName = $labelModel::TEMP_LABEL_FILENAME;
|
178 |
|
179 |
$helper->cronLog('Attempting to read temp label files from %s.', $tempLabelsDirectory);
|
243 |
*/
|
244 |
public function cleanOldLocks()
|
245 |
{
|
246 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
247 |
$helper = Mage::helper('postnl');
|
248 |
|
249 |
/**
|
292 |
* Locks may only exist for 3600 seconds (1 hour) before being removed
|
293 |
*/
|
294 |
$maxFileStorageTime = 3600;
|
295 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
296 |
+
$dateModel = Mage::getSingleton('core/date');
|
297 |
+
$now = $dateModel->gmtTimestamp();
|
298 |
$maxTimestamp = $now - $maxFileStorageTime; //1 hour ago
|
299 |
|
300 |
$helper->cronLog("{$fileCount} locks found.");
|
335 |
*/
|
336 |
public function getBarcodes()
|
337 |
{
|
338 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
339 |
$helper = Mage::helper('postnl/cif');
|
340 |
|
341 |
/**
|
362 |
$helper->cronLog("Getting barcodes for {$postnlShipmentCollection->getSize()} shipments.");
|
363 |
|
364 |
$counter = 1000;
|
365 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
366 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
367 |
if (!$postnlShipment->getShipment(false)) {
|
368 |
continue;
|
412 |
*/
|
413 |
public function updateShippingStatus()
|
414 |
{
|
415 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
416 |
$helper = Mage::helper('postnl');
|
417 |
|
418 |
/**
|
427 |
/**
|
428 |
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
429 |
*/
|
430 |
+
/** @noinspection PhpParamsInspection */
|
431 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
432 |
+
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
433 |
+
$deliveredStatus = $postnlShipmentModelClass::SHIPPING_PHASE_DELIVERED;
|
434 |
|
435 |
/**
|
436 |
* Get all postnl shipments with a barcode, that are confirmed and are not yet delivered.
|
468 |
/**
|
469 |
* Request a shipping status update
|
470 |
*/
|
471 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
472 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
473 |
/**
|
474 |
* Attempt to update the shipping status. Continue with the next one if it fails.
|
496 |
} catch (Exception $e) {
|
497 |
$postnlShipment->unlock();
|
498 |
|
499 |
+
$helper->logException($e);
|
500 |
}
|
501 |
}
|
502 |
|
512 |
*/
|
513 |
public function updateReturnStatus()
|
514 |
{
|
515 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
516 |
$helper = Mage::helper('postnl');
|
517 |
|
518 |
/**
|
527 |
/**
|
528 |
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
529 |
*/
|
530 |
+
/** @noinspection PhpParamsInspection */
|
531 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
532 |
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
533 |
$deliveredStatus = $postnlShipmentModelClass::SHIPPING_PHASE_DELIVERED;
|
607 |
/**
|
608 |
* Request a return status update
|
609 |
*/
|
610 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
611 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
612 |
/**
|
613 |
* Attempt to update the return status. Continue with the next one if it fails.
|
637 |
} catch (Exception $e) {
|
638 |
$postnlShipment->unlock();
|
639 |
|
640 |
+
$helper->logException($e);
|
641 |
}
|
642 |
}
|
643 |
|
657 |
*/
|
658 |
protected function _parseErrorCodes($e, $postnlShipment, $isReturnStatus = false)
|
659 |
{
|
660 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
661 |
$helper = Mage::helper('postnl');
|
662 |
|
663 |
/**
|
673 |
/**
|
674 |
* @var $cifAbstractModelClassName TIG_PostNL_Model_Core_Cif_Abstract
|
675 |
*/
|
676 |
+
/** @noinspection PhpParamsInspection */
|
677 |
$cifAbstractModelClassName = Mage::getConfig()->getModelClassName('postnl_core/cif_abstract');
|
678 |
foreach ($errorNumbers as $errorNumber) {
|
679 |
if ($errorNumber != $cifAbstractModelClassName::SHIPMENT_NOT_FOUND_ERROR_NUMBER) { // Collo not found error
|
693 |
*/
|
694 |
$confirmedAt = strtotime($postnlShipment->getConfirmedAt());
|
695 |
$yesterday = new DateTime('now', new DateTimeZone('UTC'));
|
696 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
697 |
+
$dateModel = Mage::getSingleton('core/date');
|
698 |
+
$yesterday->setTimestamp($dateModel->gmtTimestamp())
|
699 |
->sub(new DateInterval('P1D'));
|
700 |
|
701 |
$yesterday = $yesterday->getTimestamp();
|
733 |
*/
|
734 |
public function expireConfirmation()
|
735 |
{
|
736 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
737 |
$helper = Mage::helper('postnl/cif');
|
738 |
|
739 |
/**
|
748 |
/**
|
749 |
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
750 |
*/
|
751 |
+
/** @noinspection PhpParamsInspection */
|
752 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
753 |
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
754 |
$collectionPhase = $postnlShipmentModelClass::SHIPPING_PHASE_COLLECTION;
|
759 |
);
|
760 |
|
761 |
$expireTimestamp = new DateTime('now', new DateTimeZone('UTC'));
|
762 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
763 |
+
$dateModel = Mage::getSingleton('core/date');
|
764 |
+
$expireTimestamp->setTimestamp($dateModel->gmtTimestamp())
|
765 |
->sub(new DateInterval("P{$confirmationExpireDays}D"));
|
766 |
|
767 |
$expireDate = $expireTimestamp->format('Y-m-d H:i:s');
|
810 |
/**
|
811 |
* Reset the shipments to 'unconfirmed' status
|
812 |
*/
|
813 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
814 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
815 |
/**
|
816 |
* Attempt to reset the shipment to a pre-confirmed status
|
854 |
*/
|
855 |
public function sendTrackAndTraceEmail()
|
856 |
{
|
857 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
858 |
$helper = Mage::helper('postnl');
|
859 |
|
860 |
/**
|
884 |
/**
|
885 |
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
886 |
*/
|
887 |
+
/** @noinspection PhpParamsInspection */
|
888 |
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
889 |
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
890 |
|
891 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
892 |
+
$dateModel = Mage::getSingleton('core/date');
|
893 |
$twentyMinutesAgo = new DateTime('now', new DateTimeZone('UTC'));
|
894 |
+
$twentyMinutesAgo->setTimestamp($dateModel->gmtTimestamp())
|
895 |
->sub(new DateInterval('PT20M'));
|
896 |
|
897 |
$twentyMinutesAgo = $twentyMinutesAgo->format('Y-m-d H:i:s');
|
898 |
|
899 |
$oneDayAgo = new DateTime('now', new DateTimeZone('UTC'));
|
900 |
+
$oneDayAgo->setTimestamp($dateModel->gmtTimestamp())
|
901 |
->sub(new DateInterval('P1DT20M'));
|
902 |
|
903 |
$oneDayAgo = $oneDayAgo->format('Y-m-d H:i:s');
|
979 |
/**
|
980 |
* Send the track and trace email for all shipments.
|
981 |
*/
|
982 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
983 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
984 |
if (!$postnlShipment->getShipment(false)) {
|
985 |
continue;
|
1021 |
*/
|
1022 |
public function removeOldLabels()
|
1023 |
{
|
1024 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1025 |
$helper = Mage::helper('postnl');
|
1026 |
|
1027 |
/**
|
1038 |
*
|
1039 |
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
1040 |
*/
|
1041 |
+
/** @noinspection PhpParamsInspection */
|
1042 |
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
1043 |
|
1044 |
/**
|
1045 |
* Get the label collection
|
1046 |
*/
|
1047 |
+
/** @var TIG_PostNL_Model_Core_Resource_Shipment_Label_Collection $labelsCollection */
|
1048 |
$labelsCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
|
1049 |
|
1050 |
/**
|
1052 |
*/
|
1053 |
$labelsCollection->addFieldToSelect('label_id');
|
1054 |
|
1055 |
+
/** @var Mage_Core_Model_Resource $resource */
|
1056 |
$resource = Mage::getSingleton('core/resource');
|
1057 |
|
1058 |
$select = $labelsCollection->getSelect();
|
1136 |
/**
|
1137 |
* Delete the labels
|
1138 |
*/
|
1139 |
+
/** @var TIG_PostNL_Model_Core_Shipment_Label $label */
|
1140 |
foreach ($labelsCollection as $label) {
|
1141 |
$helper->cronLog("Deleting label #{$label->getId()}.");
|
1142 |
$label->delete();
|
1155 |
*/
|
1156 |
public function updateProductAttribute()
|
1157 |
{
|
1158 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1159 |
$helper = Mage::helper('postnl');
|
1160 |
|
1161 |
$helper->cronLog($helper->__('UpdateProductAttribute cron starting...'));
|
1192 |
/**
|
1193 |
* Get all products that need to be updated.
|
1194 |
*/
|
1195 |
+
/** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
|
1196 |
$productCollection = Mage::getResourceModel('catalog/product_collection')
|
1197 |
->addStoreFilter(Mage_Core_Model_App::ADMIN_STORE_ID)
|
1198 |
->addFieldToFilter(
|
1225 |
/**
|
1226 |
* Update the attributes of these products.
|
1227 |
*/
|
1228 |
+
/** @var Mage_Catalog_Model_Product_Action $productAction */
|
1229 |
+
$productAction = Mage::getSingleton('catalog/product_action');
|
1230 |
+
$productAction->updateAttributes(
|
1231 |
+
$allIds,
|
1232 |
+
$currentAttributeData[0],
|
1233 |
+
Mage_Core_Model_App::ADMIN_STORE_ID
|
1234 |
+
);
|
1235 |
} catch (Exception $e) {
|
1236 |
/**
|
1237 |
* If an error occurred not all products were processed, so the cron is not finished quite yet.
|
1292 |
Mage_Core_Model_App::ADMIN_STORE_ID
|
1293 |
);
|
1294 |
|
1295 |
+
/** @var Mage_Core_Model_Config_Data $configData */
|
1296 |
+
$configData = Mage::getModel('core/config_data')
|
1297 |
+
->load(TIG_PostNL_Model_Resource_Setup::UPDATE_PRODUCT_ATTRIBUTE_STRING_PATH, 'path');
|
1298 |
+
$configData->setValue(null)
|
1299 |
+
->setPath(self::UPDATE_PRODUCT_ATTRIBUTE_STRING_PATH)
|
1300 |
+
->save();
|
1301 |
|
1302 |
Mage::app()->getCacheInstance()->cleanType('config');
|
1303 |
|
1312 |
*/
|
1313 |
public function updateDateTimeZone()
|
1314 |
{
|
1315 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1316 |
$helper = Mage::helper('postnl');
|
1317 |
|
1318 |
$helper->cronLog($helper->__('UpdateDateTimeZone cron starting...'));
|
1357 |
Mage_Core_Model_App::ADMIN_STORE_ID
|
1358 |
);
|
1359 |
|
1360 |
+
/** @var Mage_Core_Model_Config_Data $configData */
|
1361 |
+
$configData = Mage::getModel('core/config_data')
|
1362 |
+
->load(TIG_PostNL_Model_Resource_Setup::UPDATE_DATE_TIME_ZONE_STRING_PATH, 'path');
|
1363 |
+
$configData->setValue(null)
|
1364 |
+
->setPath(TIG_PostNL_Model_Resource_Setup::UPDATE_DATE_TIME_ZONE_STRING_PATH)
|
1365 |
+
->save();
|
1366 |
}
|
1367 |
|
1368 |
Mage::getConfig()->saveConfig(
|
1395 |
$postnlShipments->addFieldToFilter('entity_id', array('in' => $ids));
|
1396 |
$postnlShipments->getSelect()->limit(100);
|
1397 |
|
1398 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1399 |
$helper = Mage::helper('postnl');
|
1400 |
|
1401 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
1402 |
foreach ($postnlShipments as $postnlShipment) {
|
1403 |
$helper->cronLog($helper->__('Updating shipment ID: %s', $postnlShipment->getId()));
|
1404 |
|
1467 |
$postnlOrders->addFieldToFilter('entity_id', array('in' => $ids));
|
1468 |
$postnlOrders->getSelect()->limit(100);
|
1469 |
|
1470 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1471 |
$helper = Mage::helper('postnl');
|
1472 |
|
1473 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
1474 |
foreach ($postnlOrders as $postnlOrder) {
|
1475 |
$helper->cronLog($helper->__('Updating order ID: %s', $postnlOrder->getId()));
|
1476 |
|
1532 |
*/
|
1533 |
public function integrityCheck()
|
1534 |
{
|
1535 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1536 |
$helper = Mage::helper('postnl');
|
1537 |
|
1538 |
/**
|
1544 |
|
1545 |
$helper->cronLog($helper->__('IntegrityCheck cron starting...'));
|
1546 |
|
1547 |
+
/** @var TIG_PostNL_Model_Core_Service_IntegrityCheck $integrityCheckModel */
|
1548 |
$integrityCheckModel = Mage::getModel('postnl_core/service_integrityCheck');
|
1549 |
try {
|
1550 |
$errors = $integrityCheckModel->integrityCheck();
|
1567 |
|
1568 |
return $this;
|
1569 |
}
|
1570 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_Returns
|
@@ -121,7 +121,8 @@ class TIG_PostNL_Model_Core_Observer_Returns
|
|
121 |
/**
|
122 |
* Check if this block is the block we need to edit.
|
123 |
*/
|
124 |
-
|
|
|
125 |
$blockClassName = $this->getBlockClassName();
|
126 |
if (!($block instanceof $blockClassName)) {
|
127 |
return $this;
|
@@ -139,6 +140,7 @@ class TIG_PostNL_Model_Core_Observer_Returns
|
|
139 |
return $this;
|
140 |
}
|
141 |
|
|
|
142 |
$helper = Mage::helper('postnl');
|
143 |
|
144 |
/**
|
@@ -151,7 +153,9 @@ class TIG_PostNL_Model_Core_Observer_Returns
|
|
151 |
/**
|
152 |
* Add the link.
|
153 |
*/
|
154 |
-
|
|
|
|
|
155 |
$block->addLink(
|
156 |
'postnl_returns',
|
157 |
'postnl/order/returns',
|
@@ -168,4 +172,4 @@ class TIG_PostNL_Model_Core_Observer_Returns
|
|
168 |
$this->setProcessed(true);
|
169 |
return $this;
|
170 |
}
|
171 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_Returns
|
121 |
/**
|
122 |
* Check if this block is the block we need to edit.
|
123 |
*/
|
124 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
125 |
+
$block = $observer->getBlock();
|
126 |
$blockClassName = $this->getBlockClassName();
|
127 |
if (!($block instanceof $blockClassName)) {
|
128 |
return $this;
|
140 |
return $this;
|
141 |
}
|
142 |
|
143 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
144 |
$helper = Mage::helper('postnl');
|
145 |
|
146 |
/**
|
153 |
/**
|
154 |
* Add the link.
|
155 |
*/
|
156 |
+
/** @var Mage_Customer_Model_Session $session */
|
157 |
+
$session = Mage::getSingleton('customer/session');
|
158 |
+
if ($session->isLoggedIn()) {
|
159 |
$block->addLink(
|
160 |
'postnl_returns',
|
161 |
'postnl/order/returns',
|
172 |
$this->setProcessed(true);
|
173 |
return $this;
|
174 |
}
|
175 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_SaveShipment
|
@@ -54,7 +54,9 @@ class TIG_PostNL_Model_Core_Observer_SaveShipment
|
|
54 |
/**
|
55 |
* Check if the PostNL module is active
|
56 |
*/
|
57 |
-
|
|
|
|
|
58 |
return $this;
|
59 |
}
|
60 |
|
@@ -63,6 +65,7 @@ class TIG_PostNL_Model_Core_Observer_SaveShipment
|
|
63 |
*
|
64 |
* @var Mage_Core_Controller_Varien_Front $controller
|
65 |
*/
|
|
|
66 |
$controller = $observer->getControllerAction();
|
67 |
$shippingOptions = $controller->getRequest()->getParam('postnl');
|
68 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Observer_SaveShipment
|
54 |
/**
|
55 |
* Check if the PostNL module is active
|
56 |
*/
|
57 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
58 |
+
$helper = Mage::helper('postnl');
|
59 |
+
if (!$helper->isEnabled()) {
|
60 |
return $this;
|
61 |
}
|
62 |
|
65 |
*
|
66 |
* @var Mage_Core_Controller_Varien_Front $controller
|
67 |
*/
|
68 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
69 |
$controller = $observer->getControllerAction();
|
70 |
$shippingOptions = $controller->getRequest()->getParam('postnl');
|
71 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class TIG_PostNL_Model_Core_Order
|
@@ -57,6 +57,8 @@
|
|
57 |
* @method string getExpectedDeliveryTimeEnd()
|
58 |
* @method string getUpdatedAt()
|
59 |
* @method string getCreatedAt()
|
|
|
|
|
60 |
*
|
61 |
* @method TIG_PostNL_Model_Core_Order setIsPakketautomaat(int $value)
|
62 |
* @method TIG_PostNL_Model_Core_Order setEntityId(int $value)
|
@@ -78,6 +80,8 @@
|
|
78 |
* @method TIG_PostNL_Model_Core_Order setExpectedDeliveryTimeStart(string $value)
|
79 |
* @method TIG_PostNL_Model_Core_Order setExpectedDeliveryTimeEnd(string $value)
|
80 |
* @method TIG_PostNL_Model_Core_Order setStoreId(int $value)
|
|
|
|
|
81 |
*
|
82 |
* @method boolean hasOrderId()
|
83 |
* @method boolean hasQuoteId()
|
@@ -89,6 +93,8 @@
|
|
89 |
* @method boolean hasExpectedDeliveryTimeStart()
|
90 |
* @method boolean hasExpectedDeliveryTimeEnd()
|
91 |
* @method boolean hasStoreId()
|
|
|
|
|
92 |
*/
|
93 |
class TIG_PostNL_Model_Core_Order extends Mage_Core_Model_Abstract
|
94 |
{
|
@@ -103,12 +109,15 @@ class TIG_PostNL_Model_Core_Order extends Mage_Core_Model_Abstract
|
|
103 |
/**
|
104 |
* Available types.
|
105 |
*/
|
106 |
-
const TYPE_OVERDAG
|
107 |
-
const TYPE_AVOND
|
108 |
-
const TYPE_SUNDAY
|
109 |
-
const TYPE_PG
|
110 |
-
const TYPE_PGE
|
111 |
-
const TYPE_PA
|
|
|
|
|
|
|
112 |
|
113 |
/**
|
114 |
* Prefix of model events names.
|
@@ -408,6 +417,36 @@ class TIG_PostNL_Model_Core_Order extends Mage_Core_Model_Abstract
|
|
408 |
return false;
|
409 |
}
|
410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
/**
|
412 |
* Validate the chosen extra options. If an option is invalid, it will be unset.
|
413 |
*
|
@@ -472,6 +511,7 @@ class TIG_PostNL_Model_Core_Order extends Mage_Core_Model_Abstract
|
|
472 |
);
|
473 |
}
|
474 |
|
|
|
475 |
$cif = Mage::getModel('postnl_checkout/cif');
|
476 |
$cif->updateOrder($this, true);
|
477 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class TIG_PostNL_Model_Core_Order
|
57 |
* @method string getExpectedDeliveryTimeEnd()
|
58 |
* @method string getUpdatedAt()
|
59 |
* @method string getCreatedAt()
|
60 |
+
* @method string getPgLocationCode()
|
61 |
+
* @method string getPgRetailNetworkId()
|
62 |
*
|
63 |
* @method TIG_PostNL_Model_Core_Order setIsPakketautomaat(int $value)
|
64 |
* @method TIG_PostNL_Model_Core_Order setEntityId(int $value)
|
80 |
* @method TIG_PostNL_Model_Core_Order setExpectedDeliveryTimeStart(string $value)
|
81 |
* @method TIG_PostNL_Model_Core_Order setExpectedDeliveryTimeEnd(string $value)
|
82 |
* @method TIG_PostNL_Model_Core_Order setStoreId(int $value)
|
83 |
+
* @method TIG_PostNL_Model_Core_Order setPgLocationCode(string $value)
|
84 |
+
* @method TIG_PostNL_Model_Core_Order setPgRetailNetworkId(string $value)
|
85 |
*
|
86 |
* @method boolean hasOrderId()
|
87 |
* @method boolean hasQuoteId()
|
93 |
* @method boolean hasExpectedDeliveryTimeStart()
|
94 |
* @method boolean hasExpectedDeliveryTimeEnd()
|
95 |
* @method boolean hasStoreId()
|
96 |
+
* @method string hasPgLocationCode()
|
97 |
+
* @method string hasPgRetailNetworkId()
|
98 |
*/
|
99 |
class TIG_PostNL_Model_Core_Order extends Mage_Core_Model_Abstract
|
100 |
{
|
109 |
/**
|
110 |
* Available types.
|
111 |
*/
|
112 |
+
const TYPE_OVERDAG = 'Overdag';
|
113 |
+
const TYPE_AVOND = 'Avond';
|
114 |
+
const TYPE_SUNDAY = 'Sunday';
|
115 |
+
const TYPE_PG = 'PG';
|
116 |
+
const TYPE_PGE = 'PGE';
|
117 |
+
const TYPE_PA = 'PA';
|
118 |
+
const TYPE_SAMEDAY = 'Sameday';
|
119 |
+
const TYPE_FOOD = 'Food';
|
120 |
+
const TYPE_COOLED_FOOD = 'Cooledfood';
|
121 |
|
122 |
/**
|
123 |
* Prefix of model events names.
|
417 |
return false;
|
418 |
}
|
419 |
|
420 |
+
/**
|
421 |
+
* Check if the order is same day delivery.
|
422 |
+
*
|
423 |
+
* @return bool
|
424 |
+
*/
|
425 |
+
public function isSameDayDelivery()
|
426 |
+
{
|
427 |
+
$type = $this->getType();
|
428 |
+
if ($type == self::TYPE_SAMEDAY) {
|
429 |
+
return true;
|
430 |
+
}
|
431 |
+
|
432 |
+
return false;
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Check if the order is a food order.
|
437 |
+
*
|
438 |
+
* @return bool
|
439 |
+
*/
|
440 |
+
public function isFood()
|
441 |
+
{
|
442 |
+
$type = $this->getType();
|
443 |
+
if ($type == self::TYPE_FOOD || $type == self::TYPE_COOLED_FOOD) {
|
444 |
+
return true;
|
445 |
+
}
|
446 |
+
|
447 |
+
return false;
|
448 |
+
}
|
449 |
+
|
450 |
/**
|
451 |
* Validate the chosen extra options. If an option is invalid, it will be unset.
|
452 |
*
|
511 |
);
|
512 |
}
|
513 |
|
514 |
+
/** @var TIG_PostNL_Model_Checkout_Cif $cif */
|
515 |
$cif = Mage::getModel('postnl_checkout/cif');
|
516 |
$cif->updateOrder($this, true);
|
517 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Core_PackingSlip setStoreId(int $value)
|
@@ -55,6 +55,18 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
55 |
*/
|
56 |
const XPATH_ITEM_COLUMNS = 'postnl/packing_slip/item_columns';
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
/**
|
59 |
* The height of a page's top and bottom margins.
|
60 |
*/
|
@@ -208,9 +220,16 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
208 |
*/
|
209 |
protected function _construct()
|
210 |
{
|
211 |
-
$
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
|
216 |
/**
|
@@ -245,10 +264,11 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
245 |
{
|
246 |
$pdf = $this->_getPackingSlipPdf($postnlShipment);
|
247 |
|
248 |
-
$labelModel
|
249 |
-
|
250 |
-
|
251 |
-
|
|
|
252 |
|
253 |
/**
|
254 |
* @var TIG_PostNL_Model_Core_Shipment_Label $firstLabel
|
@@ -336,8 +356,10 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
336 |
/**
|
337 |
* Create a dummy invoice for the totals at the bottom of the packing slip.
|
338 |
*/
|
339 |
-
|
340 |
-
$
|
|
|
|
|
341 |
|
342 |
/**
|
343 |
* Set the store ID and configuration settings.
|
@@ -392,7 +414,10 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
392 |
$page->setLineColor(new Zend_Pdf_Color_GrayScale(0.9));
|
393 |
$items = $invoice->getAllItems();
|
394 |
foreach ($items as $item) {
|
395 |
-
|
|
|
|
|
|
|
396 |
continue;
|
397 |
}
|
398 |
/**
|
@@ -421,6 +446,47 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
421 |
return $pdf;
|
422 |
}
|
423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
/**
|
425 |
* Set font as regular.
|
426 |
*
|
@@ -431,7 +497,12 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
431 |
*/
|
432 |
protected function _setFontRegular($object, $size = 8)
|
433 |
{
|
434 |
-
|
|
|
|
|
|
|
|
|
|
|
435 |
$object->setFont($font, $size);
|
436 |
|
437 |
return $font;
|
@@ -447,7 +518,12 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
447 |
*/
|
448 |
protected function _setFontBold($object, $size = 8)
|
449 |
{
|
450 |
-
|
|
|
|
|
|
|
|
|
|
|
451 |
$object->setFont($font, $size);
|
452 |
|
453 |
return $font;
|
@@ -463,7 +539,12 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
463 |
*/
|
464 |
protected function _setFontItalic($object, $size = 8)
|
465 |
{
|
466 |
-
|
|
|
|
|
|
|
|
|
|
|
467 |
$object->setFont($font, $size);
|
468 |
|
469 |
return $font;
|
@@ -795,6 +876,38 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
795 |
$deliveryDate = $postnlShipment->getDeliveryDate();
|
796 |
/** @noinspection PhpParamsInspection */
|
797 |
$text = $this->getCoreHelper()->formatDate($deliveryDate, 'full', false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
798 |
$x = 580 - $this->widthForStringUsingFontSize($text, $font, 8);
|
799 |
$page->drawText($text, $x, $top, 'UTF-8');
|
800 |
|
@@ -1154,8 +1267,9 @@ class TIG_PostNL_Model_Core_PackingSlip extends Mage_Sales_Model_Order_Pdf_Abstr
|
|
1154 |
if ($commentType == 'static') {
|
1155 |
$commentText = $this->getStringHelper()->stripTags($this->getConfig('comment_text'));
|
1156 |
} else {
|
1157 |
-
$commentsCollection
|
1158 |
-
|
|
|
1159 |
|
1160 |
$commentsCollection->getSelect()
|
1161 |
->limit(1);
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Core_PackingSlip setStoreId(int $value)
|
55 |
*/
|
56 |
const XPATH_ITEM_COLUMNS = 'postnl/packing_slip/item_columns';
|
57 |
|
58 |
+
/**
|
59 |
+
* Xpath to the PDF font compatiblity mode flag.
|
60 |
+
*/
|
61 |
+
const XPATH_PDF_FONT_COMPATIBILITY_MODE = 'postnl/advanced/pdf_font_compatibility_mode';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Paths to the compatiblity mode fonts
|
65 |
+
*/
|
66 |
+
const COMPATIBLITY_FONT_REGULAR = '/lib/LinLibertineFont/LinLibertine_Re-4.4.1.ttf';
|
67 |
+
const COMPATIBLITY_FONT_BOLD = '/lib/LinLibertineFont/LinLibertine_Bd-2.8.1.ttf';
|
68 |
+
const COMPATIBLITY_FONT_ITALIC = '/lib/LinLibertineFont/LinLibertine_It-2.8.2.ttf';
|
69 |
+
|
70 |
/**
|
71 |
* The height of a page's top and bottom margins.
|
72 |
*/
|
220 |
*/
|
221 |
protected function _construct()
|
222 |
{
|
223 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
224 |
+
$helper = Mage::helper('postnl');
|
225 |
+
/** @var Mage_Core_Helper_Data $coreHelper */
|
226 |
+
$coreHelper = Mage::helper('core');
|
227 |
+
/** @var Mage_Core_Helper_String $stringHelper */
|
228 |
+
$stringHelper = Mage::helper('core/string');
|
229 |
+
|
230 |
+
$this->setHelper($helper)
|
231 |
+
->setCoreHelper($coreHelper)
|
232 |
+
->setStringHelper($stringHelper);
|
233 |
}
|
234 |
|
235 |
/**
|
264 |
{
|
265 |
$pdf = $this->_getPackingSlipPdf($postnlShipment);
|
266 |
|
267 |
+
/** @var TIG_PostNL_Model_Core_Label $labelModel */
|
268 |
+
$labelModel = Mage::getSingleton('postnl_core/label');
|
269 |
+
$labelModel = $labelModel->setLabelSize('A4')
|
270 |
+
->setOutputMode('S')
|
271 |
+
->setLabelCounter(0);
|
272 |
|
273 |
/**
|
274 |
* @var TIG_PostNL_Model_Core_Shipment_Label $firstLabel
|
356 |
/**
|
357 |
* Create a dummy invoice for the totals at the bottom of the packing slip.
|
358 |
*/
|
359 |
+
/** @var TIG_PostNL_Model_Core_Service $serviceModel */
|
360 |
+
$serviceModel = Mage::getModel('postnl_core/service');
|
361 |
+
$invoice = $serviceModel->initInvoice($shipment, true);
|
362 |
+
$storeId = $shipment->getStoreId();
|
363 |
|
364 |
/**
|
365 |
* Set the store ID and configuration settings.
|
414 |
$page->setLineColor(new Zend_Pdf_Color_GrayScale(0.9));
|
415 |
$items = $invoice->getAllItems();
|
416 |
foreach ($items as $item) {
|
417 |
+
$orderItem = $item->getOrderItem();
|
418 |
+
if ($orderItem->getParentItem() ||
|
419 |
+
$orderItem->getProductType() == 'virtual' ||
|
420 |
+
$orderItem->getProductType() == 'downloadable') {
|
421 |
continue;
|
422 |
}
|
423 |
/**
|
446 |
return $pdf;
|
447 |
}
|
448 |
|
449 |
+
/**
|
450 |
+
* Checks if the PDF font compatibility mode is activated for the current store.
|
451 |
+
*
|
452 |
+
* @return bool
|
453 |
+
*/
|
454 |
+
protected function _isCompatiblityMode()
|
455 |
+
{
|
456 |
+
$storeId = $this->getStoreId();
|
457 |
+
return (bool) Mage::getStoreConfig(self::XPATH_PDF_FONT_COMPATIBILITY_MODE, $storeId);
|
458 |
+
}
|
459 |
+
|
460 |
+
/**
|
461 |
+
* Returns the path to the regular Magento Packing Slip font.
|
462 |
+
*
|
463 |
+
* @return string
|
464 |
+
*/
|
465 |
+
protected function _getCompatiblityFontRegularPath()
|
466 |
+
{
|
467 |
+
return Mage::getBaseDir() . self::COMPATIBLITY_FONT_REGULAR;
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Returns the path to the bold Magento Packing Slip font.
|
472 |
+
*
|
473 |
+
* @return string
|
474 |
+
*/
|
475 |
+
protected function _getCompatiblityFontBoldPath()
|
476 |
+
{
|
477 |
+
return Mage::getBaseDir() . self::COMPATIBLITY_FONT_BOLD;
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* Returns the path to the italic Magento Packing Slip font.
|
482 |
+
*
|
483 |
+
* @return string
|
484 |
+
*/
|
485 |
+
protected function _getCompatiblityFontItalicPath()
|
486 |
+
{
|
487 |
+
return Mage::getBaseDir() . self::COMPATIBLITY_FONT_ITALIC;
|
488 |
+
}
|
489 |
+
|
490 |
/**
|
491 |
* Set font as regular.
|
492 |
*
|
497 |
*/
|
498 |
protected function _setFontRegular($object, $size = 8)
|
499 |
{
|
500 |
+
if ($this->_isCompatiblityMode()) {
|
501 |
+
$font = Zend_Pdf_Font::fontWithPath($this->_getCompatiblityFontRegularPath());
|
502 |
+
} else {
|
503 |
+
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
|
504 |
+
}
|
505 |
+
|
506 |
$object->setFont($font, $size);
|
507 |
|
508 |
return $font;
|
518 |
*/
|
519 |
protected function _setFontBold($object, $size = 8)
|
520 |
{
|
521 |
+
if ($this->_isCompatiblityMode()) {
|
522 |
+
$font = Zend_Pdf_Font::fontWithPath($this->_getCompatiblityFontBoldPath());
|
523 |
+
} else {
|
524 |
+
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
|
525 |
+
}
|
526 |
+
|
527 |
$object->setFont($font, $size);
|
528 |
|
529 |
return $font;
|
539 |
*/
|
540 |
protected function _setFontItalic($object, $size = 8)
|
541 |
{
|
542 |
+
if ($this->_isCompatiblityMode()) {
|
543 |
+
$font = Zend_Pdf_Font::fontWithPath($this->_getCompatiblityFontItalicPath());
|
544 |
+
} else {
|
545 |
+
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_ITALIC);
|
546 |
+
}
|
547 |
+
|
548 |
$object->setFont($font, $size);
|
549 |
|
550 |
return $font;
|
876 |
$deliveryDate = $postnlShipment->getDeliveryDate();
|
877 |
/** @noinspection PhpParamsInspection */
|
878 |
$text = $this->getCoreHelper()->formatDate($deliveryDate, 'full', false);
|
879 |
+
|
880 |
+
switch ($postnlShipment->getShipmentType()) {
|
881 |
+
case $postnlShipment::SHIPMENT_TYPE_AVOND: //no break
|
882 |
+
case $postnlShipment::SHIPMENT_TYPE_AVOND_COD:
|
883 |
+
$text .= ' (' . $this->getHelper()->__('Evening Delivery') . ')';
|
884 |
+
break;
|
885 |
+
case $postnlShipment::SHIPMENT_TYPE_SAMEDAY:
|
886 |
+
$text .= ' (' . $this->getHelper()->__('Same Day Delivery') . ')';
|
887 |
+
break;
|
888 |
+
case $postnlShipment::SHIPMENT_TYPE_PG: //no break
|
889 |
+
case $postnlShipment::SHIPMENT_TYPE_PG_COD:
|
890 |
+
$text .= ' (' . $this->getHelper()->__('Post Office') . ')';
|
891 |
+
break;
|
892 |
+
case $postnlShipment::SHIPMENT_TYPE_PGE: //no break
|
893 |
+
case $postnlShipment::SHIPMENT_TYPE_PGE_COD:
|
894 |
+
$text .= ' (' . $this->getHelper()->__('Early Pickup') . ')';
|
895 |
+
break;
|
896 |
+
case $postnlShipment::SHIPMENT_TYPE_PA:
|
897 |
+
$text .= ' (' . $this->getHelper()->__('Parcel Dispenser') . ')';
|
898 |
+
break;
|
899 |
+
case $postnlShipment::SHIPMENT_TYPE_BUSPAKJE:
|
900 |
+
$text .= ' (' . $this->getHelper()->__('Letter Box Parcel') . ')';
|
901 |
+
break;
|
902 |
+
case $postnlShipment::SHIPMENT_TYPE_FOOD:
|
903 |
+
$text .= ' (' . $this->getHelper()->__('Food Delivery') . ')';
|
904 |
+
break;
|
905 |
+
case $postnlShipment::SHIPMENT_TYPE_COOLED:
|
906 |
+
$text .= ' (' . $this->getHelper()->__('Cooled Food Delivery') . ')';
|
907 |
+
break;
|
908 |
+
// no default
|
909 |
+
}
|
910 |
+
|
911 |
$x = 580 - $this->widthForStringUsingFontSize($text, $font, 8);
|
912 |
$page->drawText($text, $x, $top, 'UTF-8');
|
913 |
|
1267 |
if ($commentType == 'static') {
|
1268 |
$commentText = $this->getStringHelper()->stripTags($this->getConfig('comment_text'));
|
1269 |
} else {
|
1270 |
+
/** @var Mage_Sales_Model_Resource_Order_Shipment_Comment_Collection $commentsCollection */
|
1271 |
+
$commentsCollection = $shipment->getCommentsCollection();
|
1272 |
+
$commentsCollection = $commentsCollection->addFieldToFilter('is_visible_on_front', array('eq' => 1));
|
1273 |
|
1274 |
$commentsCollection->getSelect()
|
1275 |
->limit(1);
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method array getItemColumns()
|
@@ -100,6 +100,8 @@ class TIG_PostNL_Model_Core_Packingslip_Pdf_Items_Invoice_Default extends Mage_S
|
|
100 |
// Custom options
|
101 |
$options = $this->getItemOptions();
|
102 |
if ($options) {
|
|
|
|
|
103 |
foreach ($options as $option) {
|
104 |
$optionText = strip_tags($option['label']);
|
105 |
|
@@ -113,7 +115,7 @@ class TIG_PostNL_Model_Core_Packingslip_Pdf_Items_Invoice_Default extends Mage_S
|
|
113 |
|
114 |
// draw options
|
115 |
$lines[][] = array(
|
116 |
-
'text' =>
|
117 |
'font' => 'italic',
|
118 |
'feed' => $nameFeed,
|
119 |
'font_size' => 7,
|
@@ -143,10 +145,14 @@ class TIG_PostNL_Model_Core_Packingslip_Pdf_Items_Invoice_Default extends Mage_S
|
|
143 |
{
|
144 |
switch ($field) {
|
145 |
case 'name':
|
146 |
-
|
|
|
|
|
147 |
break;
|
148 |
case 'sku':
|
149 |
-
|
|
|
|
|
150 |
break;
|
151 |
case 'price':
|
152 |
$value = $this->getOrder()->formatPriceTxt($item->getPrice());
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method array getItemColumns()
|
100 |
// Custom options
|
101 |
$options = $this->getItemOptions();
|
102 |
if ($options) {
|
103 |
+
/** @var Mage_Core_Helper_String $stringHelper */
|
104 |
+
$stringHelper = Mage::helper('core/string');
|
105 |
foreach ($options as $option) {
|
106 |
$optionText = strip_tags($option['label']);
|
107 |
|
115 |
|
116 |
// draw options
|
117 |
$lines[][] = array(
|
118 |
+
'text' => $stringHelper->str_split(strip_tags($optionText), 120, true, true),
|
119 |
'font' => 'italic',
|
120 |
'feed' => $nameFeed,
|
121 |
'font_size' => 7,
|
145 |
{
|
146 |
switch ($field) {
|
147 |
case 'name':
|
148 |
+
/** @var Mage_Core_Helper_String $stringHelper */
|
149 |
+
$stringHelper = Mage::helper('core/string');
|
150 |
+
$value = $stringHelper->str_split($item->getName(), 60, true, true);
|
151 |
break;
|
152 |
case 'sku':
|
153 |
+
/** @var Mage_Core_Helper_String $stringHelper */
|
154 |
+
$stringHelper = Mage::helper('core/string');
|
155 |
+
$value = $stringHelper->str_split($this->getSku($item), 20);
|
156 |
break;
|
157 |
case 'price':
|
158 |
$value = $this->getOrder()->formatPriceTxt($item->getPrice());
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Integrity extends TIG_PostNL_Model_Resource_Db_Abstract
|
@@ -85,4 +85,4 @@ class TIG_PostNL_Model_Core_Resource_Integrity extends TIG_PostNL_Model_Resource
|
|
85 |
|
86 |
return $this;
|
87 |
}
|
88 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Integrity extends TIG_PostNL_Model_Resource_Db_Abstract
|
85 |
|
86 |
return $this;
|
87 |
}
|
88 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Integrity_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
@@ -57,4 +57,4 @@ class TIG_PostNL_Model_Core_Resource_Integrity_Collection extends TIG_PostNL_Mod
|
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/integrity');
|
59 |
}
|
60 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Integrity_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/integrity');
|
59 |
}
|
60 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Order extends TIG_PostNL_Model_Resource_Db_Abstract
|
@@ -63,4 +63,4 @@ class TIG_PostNL_Model_Core_Resource_Order extends TIG_PostNL_Model_Resource_Db_
|
|
63 |
|
64 |
return $adapter->fetchOne($select, $bind);
|
65 |
}
|
66 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Order extends TIG_PostNL_Model_Resource_Db_Abstract
|
63 |
|
64 |
return $adapter->fetchOne($select, $bind);
|
65 |
}
|
66 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Order_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
@@ -57,4 +57,4 @@ class TIG_PostNL_Model_Core_Resource_Order_Collection extends TIG_PostNL_Model_R
|
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/order');
|
59 |
}
|
60 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Order_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/order');
|
59 |
}
|
60 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment extends TIG_PostNL_Model_Resource_Db_Abstract
|
@@ -60,4 +60,4 @@ class TIG_PostNL_Model_Core_Resource_Shipment extends TIG_PostNL_Model_Resource_
|
|
60 |
|
61 |
return $adapter->fetchOne($select, $bind);
|
62 |
}
|
63 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment extends TIG_PostNL_Model_Resource_Db_Abstract
|
60 |
|
61 |
return $adapter->fetchOne($select, $bind);
|
62 |
}
|
63 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Barcode extends Mage_Core_Model_Resource_Db_Abstract
|
@@ -42,4 +42,4 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Barcode extends Mage_Core_Model_Re
|
|
42 |
{
|
43 |
$this->_init('postnl_core/shipment_barcode', 'barcode_id');
|
44 |
}
|
45 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Barcode extends Mage_Core_Model_Resource_Db_Abstract
|
42 |
{
|
43 |
$this->_init('postnl_core/shipment_barcode', 'barcode_id');
|
44 |
}
|
45 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Barcode_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
@@ -57,4 +57,4 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Barcode_Collection extends TIG_Pos
|
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/shipment_barcode');
|
59 |
}
|
60 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Barcode_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/shipment_barcode');
|
59 |
}
|
60 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
@@ -57,4 +57,4 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Collection extends TIG_PostNL_Mode
|
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/shipment');
|
59 |
}
|
60 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/shipment');
|
59 |
}
|
60 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Label extends Mage_Core_Model_Resource_Db_Abstract
|
@@ -42,4 +42,4 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Label extends Mage_Core_Model_Reso
|
|
42 |
{
|
43 |
$this->_init('postnl_core/shipment_label', 'label_id');
|
44 |
}
|
45 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Label extends Mage_Core_Model_Resource_Db_Abstract
|
42 |
{
|
43 |
$this->_init('postnl_core/shipment_label', 'label_id');
|
44 |
}
|
45 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Label_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
@@ -57,4 +57,4 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Label_Collection extends TIG_PostN
|
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/shipment_label');
|
59 |
}
|
60 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Label_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
57 |
parent::_construct();
|
58 |
$this->_init('postnl_core/shipment_label');
|
59 |
}
|
60 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Status_History extends Mage_Core_Model_Resource_Db_Abstract
|
@@ -42,4 +42,4 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Status_History extends Mage_Core_M
|
|
42 |
{
|
43 |
$this->_init('postnl_core/shipment_status_history', 'status_id');
|
44 |
}
|
45 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Status_History extends Mage_Core_Model_Resource_Db_Abstract
|
42 |
{
|
43 |
$this->_init('postnl_core/shipment_status_history', 'status_id');
|
44 |
}
|
45 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Status_History_Collection
|
@@ -58,4 +58,4 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Status_History_Collection
|
|
58 |
parent::_construct();
|
59 |
$this->_init('postnl_core/shipment_status_history');
|
60 |
}
|
61 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Resource_Shipment_Status_History_Collection
|
58 |
parent::_construct();
|
59 |
$this->_init('postnl_core/shipment_status_history');
|
60 |
}
|
61 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service
|
@@ -72,10 +72,11 @@ class TIG_PostNL_Model_Core_Service
|
|
72 |
/**
|
73 |
* Save all related objects (invoice, order and shipment).
|
74 |
*/
|
75 |
-
$transactionSave
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
$transactionSave->save();
|
80 |
|
81 |
return $this;
|
@@ -125,7 +126,9 @@ class TIG_PostNL_Model_Core_Service
|
|
125 |
* Create the invoice.
|
126 |
*/
|
127 |
if (!$createDummyInvoice) {
|
128 |
-
|
|
|
|
|
129 |
} else {
|
130 |
$invoice = $this->_prepareDummyInvoice($order, $qtys);
|
131 |
}
|
@@ -155,13 +158,17 @@ class TIG_PostNL_Model_Core_Service
|
|
155 |
{
|
156 |
$serviceOrder = Mage::getModel('sales/service_order', $order);
|
157 |
if (method_exists($serviceOrder, 'updateLocaleNumbers')) {
|
158 |
-
|
159 |
-
|
|
|
160 |
}
|
161 |
|
|
|
162 |
$convertor = Mage::getModel('sales/convert_order');
|
163 |
|
|
|
164 |
$dummyPaymentMethod = Mage::getModel('postnl_core/service_paymentMethodDummy');
|
|
|
165 |
$dummyPaymentMethod->setInfoInstance(Mage::getModel('payment/info'));
|
166 |
|
167 |
$dummyPayment = Mage::getModel('postnl_core/service_paymentDummy');
|
@@ -169,6 +176,7 @@ class TIG_PostNL_Model_Core_Service
|
|
169 |
$dummyPayment->setMethod('postnl_dummy')
|
170 |
->setMethodInstance($dummyPaymentMethod);
|
171 |
|
|
|
172 |
$dummyOrder = Mage::getModel('postnl_core/service_orderDummy');
|
173 |
/** @noinspection PhpUndefinedMethodInspection */
|
174 |
$dummyOrder->setData($order->getData())
|
@@ -180,6 +188,7 @@ class TIG_PostNL_Model_Core_Service
|
|
180 |
->setBaseHiddenTaxInvoiced(0)
|
181 |
->setPayment($dummyPayment);
|
182 |
|
|
|
183 |
$invoice = Mage::getModel('postnl_core/service_invoiceDummy');
|
184 |
/** @noinspection PhpUndefinedMethodInspection */
|
185 |
$invoice->setOrder($dummyOrder)
|
@@ -188,7 +197,9 @@ class TIG_PostNL_Model_Core_Service
|
|
188 |
->setBillingAddressId($dummyOrder->getBillingAddressId())
|
189 |
->setShippingAddressId($dummyOrder->getShippingAddressId());
|
190 |
|
191 |
-
|
|
|
|
|
192 |
|
193 |
/**
|
194 |
* @var Mage_Sales_Model_Order_Item $orderItem
|
@@ -261,4 +272,4 @@ class TIG_PostNL_Model_Core_Service
|
|
261 |
|
262 |
return $qtys;
|
263 |
}
|
264 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service
|
72 |
/**
|
73 |
* Save all related objects (invoice, order and shipment).
|
74 |
*/
|
75 |
+
/** @var Mage_Core_Model_Resource_Transaction $transactionSave */
|
76 |
+
$transactionSave = Mage::getModel('core/resource_transaction');
|
77 |
+
$transactionSave = $transactionSave->addObject($invoice)
|
78 |
+
->addObject($order)
|
79 |
+
->addObject($shipment);
|
80 |
$transactionSave->save();
|
81 |
|
82 |
return $this;
|
126 |
* Create the invoice.
|
127 |
*/
|
128 |
if (!$createDummyInvoice) {
|
129 |
+
/** @var Mage_Sales_Model_Service_Order $serviceModel */
|
130 |
+
$serviceModel = Mage::getModel('sales/service_order', $order);
|
131 |
+
$invoice = $serviceModel->prepareInvoice($qtys);
|
132 |
} else {
|
133 |
$invoice = $this->_prepareDummyInvoice($order, $qtys);
|
134 |
}
|
158 |
{
|
159 |
$serviceOrder = Mage::getModel('sales/service_order', $order);
|
160 |
if (method_exists($serviceOrder, 'updateLocaleNumbers')) {
|
161 |
+
/** @var Mage_Sales_Model_Service_Order $serviceModel */
|
162 |
+
$serviceModel = Mage::getModel('sales/service_order', $order);
|
163 |
+
$serviceModel->updateLocaleNumbers($qtys);
|
164 |
}
|
165 |
|
166 |
+
/** @var Mage_Sales_Model_Convert_Order $convertor */
|
167 |
$convertor = Mage::getModel('sales/convert_order');
|
168 |
|
169 |
+
/** @var TIG_PostNL_Model_Core_Service_PaymentMethodDummy $dummyPaymentMethod */
|
170 |
$dummyPaymentMethod = Mage::getModel('postnl_core/service_paymentMethodDummy');
|
171 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
172 |
$dummyPaymentMethod->setInfoInstance(Mage::getModel('payment/info'));
|
173 |
|
174 |
$dummyPayment = Mage::getModel('postnl_core/service_paymentDummy');
|
176 |
$dummyPayment->setMethod('postnl_dummy')
|
177 |
->setMethodInstance($dummyPaymentMethod);
|
178 |
|
179 |
+
/** @var TIG_PostNL_Model_Core_Service_OrderDummy $dummyOrder */
|
180 |
$dummyOrder = Mage::getModel('postnl_core/service_orderDummy');
|
181 |
/** @noinspection PhpUndefinedMethodInspection */
|
182 |
$dummyOrder->setData($order->getData())
|
188 |
->setBaseHiddenTaxInvoiced(0)
|
189 |
->setPayment($dummyPayment);
|
190 |
|
191 |
+
/** @var TIG_PostNL_Model_Core_Service_InvoiceDummy $invoice */
|
192 |
$invoice = Mage::getModel('postnl_core/service_invoiceDummy');
|
193 |
/** @noinspection PhpUndefinedMethodInspection */
|
194 |
$invoice->setOrder($dummyOrder)
|
197 |
->setBillingAddressId($dummyOrder->getBillingAddressId())
|
198 |
->setShippingAddressId($dummyOrder->getShippingAddressId());
|
199 |
|
200 |
+
/** @var Mage_Core_Helper_Data $helper */
|
201 |
+
$helper = Mage::helper('core');
|
202 |
+
$helper->copyFieldset('sales_convert_order', 'to_invoice', $order, $invoice);
|
203 |
|
204 |
/**
|
205 |
* @var Mage_Sales_Model_Order_Item $orderItem
|
272 |
|
273 |
return $qtys;
|
274 |
}
|
275 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_IntegrityCheck
|
@@ -110,8 +110,10 @@ class TIG_PostNL_Model_Core_Service_IntegrityCheck
|
|
110 |
*/
|
111 |
public function validatePostnlOrderIntegrity()
|
112 |
{
|
|
|
113 |
$resource = Mage::getSingleton('core/resource');
|
114 |
|
|
|
115 |
$postnlOrderCollection = Mage::getResourceModel('postnl_core/order_collection')
|
116 |
->addFieldToSelect(array('entity_id', 'quote_id', 'order_id'));
|
117 |
|
@@ -139,6 +141,7 @@ class TIG_PostNL_Model_Core_Service_IntegrityCheck
|
|
139 |
)
|
140 |
);
|
141 |
|
|
|
142 |
foreach ($postnlOrderCollection as $postnlOrder) {
|
143 |
if ($postnlOrder->hasOrderId()) {
|
144 |
$this->_validateOrderId($postnlOrder);
|
@@ -159,8 +162,10 @@ class TIG_PostNL_Model_Core_Service_IntegrityCheck
|
|
159 |
*/
|
160 |
public function validatePostnlShipmentIntegrity()
|
161 |
{
|
|
|
162 |
$resource = Mage::getSingleton('core/resource');
|
163 |
|
|
|
164 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection')
|
165 |
->addFieldToSelect(array('entity_id', 'shipment_id', 'order_id'));
|
166 |
|
@@ -188,6 +193,7 @@ class TIG_PostNL_Model_Core_Service_IntegrityCheck
|
|
188 |
)
|
189 |
);
|
190 |
|
|
|
191 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
192 |
if ($postnlShipment->hasOrderId()) {
|
193 |
$this->_validateOrderId($postnlShipment);
|
@@ -309,4 +315,4 @@ class TIG_PostNL_Model_Core_Service_IntegrityCheck
|
|
309 |
|
310 |
return true;
|
311 |
}
|
312 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_IntegrityCheck
|
110 |
*/
|
111 |
public function validatePostnlOrderIntegrity()
|
112 |
{
|
113 |
+
/** @var Mage_Core_Model_Resource $resource */
|
114 |
$resource = Mage::getSingleton('core/resource');
|
115 |
|
116 |
+
/** @var TIG_PostNL_Model_Core_Resource_Order_Collection $postnlOrderCollection */
|
117 |
$postnlOrderCollection = Mage::getResourceModel('postnl_core/order_collection')
|
118 |
->addFieldToSelect(array('entity_id', 'quote_id', 'order_id'));
|
119 |
|
141 |
)
|
142 |
);
|
143 |
|
144 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
145 |
foreach ($postnlOrderCollection as $postnlOrder) {
|
146 |
if ($postnlOrder->hasOrderId()) {
|
147 |
$this->_validateOrderId($postnlOrder);
|
162 |
*/
|
163 |
public function validatePostnlShipmentIntegrity()
|
164 |
{
|
165 |
+
/** @var Mage_Core_Model_Resource $resource */
|
166 |
$resource = Mage::getSingleton('core/resource');
|
167 |
|
168 |
+
/** @var TIG_PostNL_Model_Core_Resource_Shipment_Collection $postnlShipmentCollection */
|
169 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection')
|
170 |
->addFieldToSelect(array('entity_id', 'shipment_id', 'order_id'));
|
171 |
|
193 |
)
|
194 |
);
|
195 |
|
196 |
+
/** @var TIG_PostNL_Model_Core_Shipment $postnlShipment */
|
197 |
foreach ($postnlShipmentCollection as $postnlShipment) {
|
198 |
if ($postnlShipment->hasOrderId()) {
|
199 |
$this->_validateOrderId($postnlShipment);
|
315 |
|
316 |
return true;
|
317 |
}
|
318 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_InvoiceDummy extends Mage_Sales_Model_Order_Invoice
|
@@ -52,4 +52,4 @@ class TIG_PostNL_Model_Core_Service_InvoiceDummy extends Mage_Sales_Model_Order_
|
|
52 |
{
|
53 |
return false;
|
54 |
}
|
55 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_InvoiceDummy extends Mage_Sales_Model_Order_Invoice
|
52 |
{
|
53 |
return false;
|
54 |
}
|
55 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_OrderDummy extends Mage_Sales_Model_Order
|
@@ -62,4 +62,4 @@ class TIG_PostNL_Model_Core_Service_OrderDummy extends Mage_Sales_Model_Order
|
|
62 |
{
|
63 |
return false;
|
64 |
}
|
65 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_OrderDummy extends Mage_Sales_Model_Order
|
62 |
{
|
63 |
return false;
|
64 |
}
|
65 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_PaymentDummy extends Mage_Sales_Model_Order_Payment
|
@@ -52,6 +52,8 @@ class TIG_PostNL_Model_Core_Service_PaymentDummy extends Mage_Sales_Model_Order_
|
|
52 |
}
|
53 |
|
54 |
/**
|
|
|
|
|
55 |
* @return bool
|
56 |
*/
|
57 |
public function canVoid(Varien_Object $document)
|
@@ -98,4 +100,4 @@ class TIG_PostNL_Model_Core_Service_PaymentDummy extends Mage_Sales_Model_Order_
|
|
98 |
{
|
99 |
return false;
|
100 |
}
|
101 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_PaymentDummy extends Mage_Sales_Model_Order_Payment
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
+
* @param Varien_Object $document
|
56 |
+
*
|
57 |
* @return bool
|
58 |
*/
|
59 |
public function canVoid(Varien_Object $document)
|
100 |
{
|
101 |
return false;
|
102 |
}
|
103 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_PaymentMethodDummy extends Mage_Payment_Model_Method_Abstract
|
@@ -117,4 +117,4 @@ class TIG_PostNL_Model_Core_Service_PaymentMethodDummy extends Mage_Payment_Mode
|
|
117 |
* @var bool
|
118 |
*/
|
119 |
protected $_canManageRecurringProfiles = false;
|
120 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_PaymentMethodDummy extends Mage_Payment_Model_Method_Abstract
|
117 |
* @var bool
|
118 |
*/
|
119 |
protected $_canManageRecurringProfiles = false;
|
120 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_Shipment
|
@@ -167,7 +167,9 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
167 |
/**
|
168 |
* Check if the shipping method used is allowed
|
169 |
*/
|
170 |
-
|
|
|
|
|
171 |
return false;
|
172 |
}
|
173 |
|
@@ -192,7 +194,9 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
192 |
$shipmentIds = array($shipmentIds);
|
193 |
}
|
194 |
|
|
|
195 |
$helper = Mage::helper('postnl/carrier');
|
|
|
196 |
$resource = Mage::getSingleton('core/resource');
|
197 |
$postnlShippingMethods = $helper->getPostnlShippingMethods();
|
198 |
|
@@ -216,6 +220,7 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
216 |
* Get the requested shipments. Only shipments that have been shipped using PostNL will be returned.
|
217 |
*/
|
218 |
if ($loadPostnlShipments) {
|
|
|
219 |
$shipments = Mage::getResourceModel('postnl_core/shipment_collection')
|
220 |
->addFieldToFilter('shipment_id', array('in' => $shipmentIds))
|
221 |
->addFieldToFilter(
|
@@ -235,6 +240,7 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
235 |
|
236 |
$processedShipmentIds = $shipments->getColumnValues('shipment_id');
|
237 |
} else {
|
|
|
238 |
$shipments = Mage::getResourceModel('sales/order_shipment_collection')
|
239 |
->addFieldToFilter('main_table.entity_id', array('in' => $shipmentIds))
|
240 |
->addFieldToFilter(
|
@@ -266,7 +272,7 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
266 |
/**
|
267 |
* If any requested shipments were not found, it's because they were not shipped using PostNL.
|
268 |
*/
|
269 |
-
$adapter =
|
270 |
foreach ($missingIds as $shipmentId) {
|
271 |
/**
|
272 |
* Get the shipment's increment ID. We need this, because many merchants do not know the difference between
|
@@ -334,8 +340,9 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
334 |
);
|
335 |
}
|
336 |
|
337 |
-
|
338 |
-
|
|
|
339 |
|
340 |
$shipment->register();
|
341 |
$this->_saveShipment($shipment);
|
@@ -355,6 +362,7 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
355 |
*/
|
356 |
public function createShipments(array $orderIds, $loadExisting = false, $registerExisting = true)
|
357 |
{
|
|
|
358 |
$helper = Mage::helper('postnl');
|
359 |
|
360 |
/**
|
@@ -485,7 +493,9 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
485 |
/**
|
486 |
* Check if printing return labels is allowed.
|
487 |
*/
|
488 |
-
|
|
|
|
|
489 |
$includeReturnLabels = false;
|
490 |
}
|
491 |
|
@@ -586,7 +596,8 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
586 |
*/
|
587 |
public function confirmShipment($shipment)
|
588 |
{
|
589 |
-
$helper
|
|
|
590 |
|
591 |
/**
|
592 |
* Load the PostNL shipment.
|
@@ -625,7 +636,7 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
625 |
$postnlShipment->generateBarcodes();
|
626 |
}
|
627 |
|
628 |
-
$printReturnLabel =
|
629 |
if ($printReturnLabel && !$postnlShipment->hasReturnBarcode() && $postnlShipment->canGenerateReturnBarcode()) {
|
630 |
$postnlShipment->generateReturnBarcode();
|
631 |
}
|
@@ -739,7 +750,8 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
739 |
*/
|
740 |
public function getMassLabelsOutput($shipments)
|
741 |
{
|
742 |
-
$helper
|
|
|
743 |
|
744 |
/**
|
745 |
* Get the labels from CIF.
|
@@ -747,14 +759,14 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
747 |
$labels = array();
|
748 |
foreach ($shipments as $shipment) {
|
749 |
try {
|
750 |
-
$printReturnLabels =
|
751 |
$shipment->getStoreId()
|
752 |
);
|
753 |
|
754 |
$shipmentLabels = $this->getLabels($shipment, true, $printReturnLabels);
|
755 |
$labels = array_merge($labels, $shipmentLabels);
|
756 |
} catch (TIG_PostNL_Model_Core_Cif_Exception $e) {
|
757 |
-
|
758 |
|
759 |
$helper->logException($e);
|
760 |
$this->addWarning(
|
@@ -792,6 +804,7 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
792 |
/**
|
793 |
* The label wills be base64 encoded strings. Convert these to a single pdf.
|
794 |
*/
|
|
|
795 |
$label = Mage::getModel('postnl_core/label');
|
796 |
$output = $label->createPdf($labels);
|
797 |
|
@@ -809,11 +822,13 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
809 |
*/
|
810 |
public function getMassPackingSlipsOutput($shipments)
|
811 |
{
|
812 |
-
$helper
|
|
|
813 |
|
814 |
/**
|
815 |
* Get the packing slip model.
|
816 |
*/
|
|
|
817 |
$packingSlipModel = Mage::getModel('postnl_core/packingSlip');
|
818 |
|
819 |
/**
|
@@ -846,7 +861,7 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
846 |
);
|
847 |
}
|
848 |
|
849 |
-
$printReturnLabels =
|
850 |
$shipment->getStoreId()
|
851 |
);
|
852 |
|
@@ -859,7 +874,7 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
859 |
|
860 |
$packingSlipModel->createPdf($shipmentLabels, $shipment, $pdf);
|
861 |
} catch (TIG_PostNL_Model_Core_Cif_Exception $e) {
|
862 |
-
|
863 |
|
864 |
$helper->logException($e);
|
865 |
$this->addWarning(
|
@@ -915,7 +930,9 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
915 |
$orderIds = array($orderIds);
|
916 |
}
|
917 |
|
918 |
-
|
|
|
|
|
919 |
|
920 |
/**
|
921 |
* This regex will filter all non-postnl shipments.
|
@@ -966,7 +983,9 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
966 |
$postnlShipment->generateBarcodes();
|
967 |
}
|
968 |
|
969 |
-
|
|
|
|
|
970 |
if ($printReturnLabel && $postnlShipment->canGenerateReturnBarcode()) {
|
971 |
$postnlShipment->generateReturnBarcode();
|
972 |
}
|
@@ -1033,11 +1052,13 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
1033 |
*/
|
1034 |
protected function _saveShipment($shipment)
|
1035 |
{
|
|
|
1036 |
$shipment->getOrder()->setIsInProcess(true);
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
|
|
1041 |
|
1042 |
return $this;
|
1043 |
}
|
@@ -1053,9 +1074,10 @@ class TIG_PostNL_Model_Core_Service_Shipment
|
|
1053 |
*/
|
1054 |
protected function _checkIsAllowed($actions = array())
|
1055 |
{
|
|
|
1056 |
$helper = Mage::helper('postnl');
|
1057 |
$isAllowed = $helper->checkIsPostnlActionAllowed($actions, false);
|
1058 |
|
1059 |
return $isAllowed;
|
1060 |
}
|
1061 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Service_Shipment
|
167 |
/**
|
168 |
* Check if the shipping method used is allowed
|
169 |
*/
|
170 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
171 |
+
$helper = Mage::helper('postnl/carrier');
|
172 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
173 |
return false;
|
174 |
}
|
175 |
|
194 |
$shipmentIds = array($shipmentIds);
|
195 |
}
|
196 |
|
197 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
198 |
$helper = Mage::helper('postnl/carrier');
|
199 |
+
/** @var Mage_Core_Model_Resource $resource */
|
200 |
$resource = Mage::getSingleton('core/resource');
|
201 |
$postnlShippingMethods = $helper->getPostnlShippingMethods();
|
202 |
|
220 |
* Get the requested shipments. Only shipments that have been shipped using PostNL will be returned.
|
221 |
*/
|
222 |
if ($loadPostnlShipments) {
|
223 |
+
/** @var TIG_PostNL_Model_Core_Resource_Shipment_Collection $shipments */
|
224 |
$shipments = Mage::getResourceModel('postnl_core/shipment_collection')
|
225 |
->addFieldToFilter('shipment_id', array('in' => $shipmentIds))
|
226 |
->addFieldToFilter(
|
240 |
|
241 |
$processedShipmentIds = $shipments->getColumnValues('shipment_id');
|
242 |
} else {
|
243 |
+
/** @var TIG_PostNL_Model_Core_Resource_Shipment_Collection $shipments */
|
244 |
$shipments = Mage::getResourceModel('sales/order_shipment_collection')
|
245 |
->addFieldToFilter('main_table.entity_id', array('in' => $shipmentIds))
|
246 |
->addFieldToFilter(
|
272 |
/**
|
273 |
* If any requested shipments were not found, it's because they were not shipped using PostNL.
|
274 |
*/
|
275 |
+
$adapter = $resource->getConnection('core_read');
|
276 |
foreach ($missingIds as $shipmentId) {
|
277 |
/**
|
278 |
* Get the shipment's increment ID. We need this, because many merchants do not know the difference between
|
340 |
);
|
341 |
}
|
342 |
|
343 |
+
/** @var Mage_Sales_Model_Service_Order $serviceModel */
|
344 |
+
$serviceModel = Mage::getModel('sales/service_order', $order);
|
345 |
+
$shipment = $serviceModel->prepareShipment($this->_getItemQtys($order));
|
346 |
|
347 |
$shipment->register();
|
348 |
$this->_saveShipment($shipment);
|
362 |
*/
|
363 |
public function createShipments(array $orderIds, $loadExisting = false, $registerExisting = true)
|
364 |
{
|
365 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
366 |
$helper = Mage::helper('postnl');
|
367 |
|
368 |
/**
|
493 |
/**
|
494 |
* Check if printing return labels is allowed.
|
495 |
*/
|
496 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
497 |
+
$helper = Mage::helper('postnl');
|
498 |
+
if (!$helper->isReturnsEnabled($shipment->getStoreId())) {
|
499 |
$includeReturnLabels = false;
|
500 |
}
|
501 |
|
596 |
*/
|
597 |
public function confirmShipment($shipment)
|
598 |
{
|
599 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
600 |
+
$helper = Mage::helper('postnl/cif');
|
601 |
|
602 |
/**
|
603 |
* Load the PostNL shipment.
|
636 |
$postnlShipment->generateBarcodes();
|
637 |
}
|
638 |
|
639 |
+
$printReturnLabel = $helper->isReturnsEnabled($shipment->getStoreId());
|
640 |
if ($printReturnLabel && !$postnlShipment->hasReturnBarcode() && $postnlShipment->canGenerateReturnBarcode()) {
|
641 |
$postnlShipment->generateReturnBarcode();
|
642 |
}
|
750 |
*/
|
751 |
public function getMassLabelsOutput($shipments)
|
752 |
{
|
753 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
754 |
+
$helper = Mage::helper('postnl/cif');
|
755 |
|
756 |
/**
|
757 |
* Get the labels from CIF.
|
759 |
$labels = array();
|
760 |
foreach ($shipments as $shipment) {
|
761 |
try {
|
762 |
+
$printReturnLabels = $helper->canPrintReturnLabelsWithShippingLabels(
|
763 |
$shipment->getStoreId()
|
764 |
);
|
765 |
|
766 |
$shipmentLabels = $this->getLabels($shipment, true, $printReturnLabels);
|
767 |
$labels = array_merge($labels, $shipmentLabels);
|
768 |
} catch (TIG_PostNL_Model_Core_Cif_Exception $e) {
|
769 |
+
$helper->parseCifException($e);
|
770 |
|
771 |
$helper->logException($e);
|
772 |
$this->addWarning(
|
804 |
/**
|
805 |
* The label wills be base64 encoded strings. Convert these to a single pdf.
|
806 |
*/
|
807 |
+
/** @var TIG_PostNL_Model_Core_Label $label */
|
808 |
$label = Mage::getModel('postnl_core/label');
|
809 |
$output = $label->createPdf($labels);
|
810 |
|
822 |
*/
|
823 |
public function getMassPackingSlipsOutput($shipments)
|
824 |
{
|
825 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
826 |
+
$helper = Mage::helper('postnl/cif');
|
827 |
|
828 |
/**
|
829 |
* Get the packing slip model.
|
830 |
*/
|
831 |
+
/** @var TIG_PostNL_Model_Core_PackingSlip $packingSlipModel */
|
832 |
$packingSlipModel = Mage::getModel('postnl_core/packingSlip');
|
833 |
|
834 |
/**
|
861 |
);
|
862 |
}
|
863 |
|
864 |
+
$printReturnLabels = $helper->canPrintReturnLabelsWithShippingLabels(
|
865 |
$shipment->getStoreId()
|
866 |
);
|
867 |
|
874 |
|
875 |
$packingSlipModel->createPdf($shipmentLabels, $shipment, $pdf);
|
876 |
} catch (TIG_PostNL_Model_Core_Cif_Exception $e) {
|
877 |
+
$helper->parseCifException($e);
|
878 |
|
879 |
$helper->logException($e);
|
880 |
$this->addWarning(
|
930 |
$orderIds = array($orderIds);
|
931 |
}
|
932 |
|
933 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
934 |
+
$helper = Mage::helper('postnl/carrier');
|
935 |
+
$postnlShippingMethods = $helper->getPostnlShippingMethods();
|
936 |
|
937 |
/**
|
938 |
* This regex will filter all non-postnl shipments.
|
983 |
$postnlShipment->generateBarcodes();
|
984 |
}
|
985 |
|
986 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
987 |
+
$helper = Mage::helper('postnl/cif');
|
988 |
+
$printReturnLabel = $helper->isReturnsEnabled($postnlShipment->getStoreId());
|
989 |
if ($printReturnLabel && $postnlShipment->canGenerateReturnBarcode()) {
|
990 |
$postnlShipment->generateReturnBarcode();
|
991 |
}
|
1052 |
*/
|
1053 |
protected function _saveShipment($shipment)
|
1054 |
{
|
1055 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1056 |
$shipment->getOrder()->setIsInProcess(true);
|
1057 |
+
/** @var Mage_Core_Model_Resource_Transaction $transaction */
|
1058 |
+
$transaction = Mage::getModel('core/resource_transaction');
|
1059 |
+
$transaction->addObject($shipment)
|
1060 |
+
->addObject($shipment->getOrder())
|
1061 |
+
->save();
|
1062 |
|
1063 |
return $this;
|
1064 |
}
|
1074 |
*/
|
1075 |
protected function _checkIsAllowed($actions = array())
|
1076 |
{
|
1077 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1078 |
$helper = Mage::helper('postnl');
|
1079 |
$isAllowed = $helper->checkIsPostnlActionAllowed($actions, false);
|
1080 |
|
1081 |
return $isAllowed;
|
1082 |
}
|
1083 |
+
}
|
@@ -77,6 +77,7 @@
|
|
77 |
* - postnl_shipment_send_return_label_email_after
|
78 |
*
|
79 |
* @method boolean getIsDomesticShipment()
|
|
|
80 |
* @method boolean getIsEuShipment()
|
81 |
* @method boolean getIsGlobalShipment()
|
82 |
* @method int getParcelCount()
|
@@ -99,10 +100,17 @@
|
|
99 |
* @method boolean getIsBuspakjeShipment()
|
100 |
* @method boolean getIsSundayShipment()
|
101 |
* @method boolean getIsMondayShipment()
|
|
|
|
|
|
|
102 |
* @method int getReturnLabelsPrinted()
|
103 |
* @method string getExpectedDeliveryTimeStart()
|
104 |
* @method string getExpectedDeliveryTimeEnd()
|
105 |
* @method int getReturnPhase()
|
|
|
|
|
|
|
|
|
106 |
*
|
107 |
* @method TIG_PostNL_Model_Core_Shipment setLabelsPrinted(int $value)
|
108 |
* @method TIG_PostNL_Model_Core_Shipment setTreatAsAbandoned(int $value)
|
@@ -136,6 +144,9 @@
|
|
136 |
* @method TIG_PostNL_Model_Core_Shipment setIsBuspakjeShipment(bool $value)
|
137 |
* @method TIG_PostNL_Model_Core_Shipment setIsSundayShipment(bool $value)
|
138 |
* @method TIG_PostNL_Model_Core_Shipment setIsMondayShipment(bool $value)
|
|
|
|
|
|
|
139 |
* @method TIG_PostNL_Model_Core_Shipment setDefaultProductCode(string $value)
|
140 |
* @method TIG_PostNL_Model_Core_Shipment setLabels(mixed $value)
|
141 |
* @method TIG_PostNL_Model_Core_Shipment setProductOption(string $value)
|
@@ -145,6 +156,10 @@
|
|
145 |
* @method TIG_PostNL_Model_Core_Shipment setExpectedDeliveryTimeStart(string $value)
|
146 |
* @method TIG_PostNL_Model_Core_Shipment setExpectedDeliveryTimeEnd(string $value)
|
147 |
* @method TIG_PostNL_Model_Core_Shipment setReturnBarcodeUrl(string $value)
|
|
|
|
|
|
|
|
|
148 |
*
|
149 |
* @method boolean hasBarcodeUrl()
|
150 |
* @method boolean hasPostnlOrder()
|
@@ -168,6 +183,9 @@
|
|
168 |
* @method boolean hasIsBuspakjeShipment()
|
169 |
* @method boolean hasIsSundayShipment()
|
170 |
* @method boolean hasIsMondayShipment()
|
|
|
|
|
|
|
171 |
* @method boolean hasDefaultProductCode()
|
172 |
* @method boolean hasProductOption()
|
173 |
* @method boolean hasPayment()
|
@@ -176,6 +194,8 @@
|
|
176 |
* @method boolean hasExpectedDeliveryTimeEnd()
|
177 |
* @method boolean hasReturnPhase()
|
178 |
* @method boolean hasReturnBarcodeUrl()
|
|
|
|
|
179 |
*/
|
180 |
class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
181 |
{
|
@@ -218,28 +238,36 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
218 |
const SHIPMENT_TYPE_BUSPAKJE = 'buspakje';
|
219 |
const SHIPMENT_TYPE_SUNDAY = 'sunday';
|
220 |
const SHIPMENT_TYPE_MONDAY = 'monday';
|
|
|
|
|
|
|
221 |
|
222 |
/**
|
223 |
* Xpaths to default product options settings.
|
224 |
*/
|
225 |
-
const XPATH_DEFAULT_STANDARD_PRODUCT_OPTION
|
226 |
-
const
|
227 |
-
const
|
228 |
-
const
|
229 |
-
const
|
230 |
-
const
|
231 |
-
const
|
232 |
-
const
|
233 |
-
const
|
234 |
-
const
|
235 |
-
const
|
236 |
-
const
|
237 |
-
const
|
238 |
-
const
|
239 |
-
const
|
240 |
-
const
|
241 |
-
const
|
242 |
-
const
|
|
|
|
|
|
|
|
|
|
|
243 |
|
244 |
/**
|
245 |
* Xpath to weight per parcel config setting.
|
@@ -434,6 +462,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
434 |
}
|
435 |
$orderId = $this->getOrderId();
|
436 |
|
|
|
437 |
$payment = Mage::getModel('sales/order_payment')
|
438 |
->load($orderId, 'parent_id');
|
439 |
|
@@ -580,10 +609,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
580 |
*
|
581 |
* @param string $type
|
582 |
*
|
583 |
-
* @return TIG_PostNL_Helper_Data|TIG_PostNL_Helper_Cif|TIG_PostNL_Helper_Carrier|TIG_PostNL_Helper_DeliveryOptions
|
584 |
-
* |TIG_PostNL_Helper_AddressValidation|TIG_PostNL_Helper_Checkout|TIG_PostNL_Helper_Mijnpakket
|
585 |
-
* |TIG_PostNL_Helper_Parcelware|TIG_PostNL_Helper_Payment|TIG_PostNL_Helper_Webservices
|
586 |
-
* |TIG_PostNL_Helper_Date
|
587 |
*/
|
588 |
public function getHelper($type = 'data')
|
589 |
{
|
@@ -639,8 +665,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
639 |
return $this->_extraCoverProductCodes;
|
640 |
}
|
641 |
|
642 |
-
$
|
643 |
-
|
|
|
644 |
|
645 |
$this->_extraCoverProductCodes = array_keys($productCodes);
|
646 |
return $this->_extraCoverProductCodes;
|
@@ -704,7 +731,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
704 |
* If the product code was switched from a combi-label product code to a regular one, switch it back so we can
|
705 |
* find the product code that was chosen by the merchant.
|
706 |
*/
|
707 |
-
$
|
|
|
708 |
if (isset($combiLabelProductCodes[$productCode])) {
|
709 |
$productCode = $combiLabelProductCodes[$productCode];
|
710 |
}
|
@@ -712,8 +740,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
712 |
/**
|
713 |
* Get all product options.
|
714 |
*/
|
715 |
-
$
|
716 |
-
|
|
|
717 |
|
718 |
if (isset($productOptions[$productCode])) {
|
719 |
$productOption = $productOptions[$productCode];
|
@@ -806,6 +835,18 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
806 |
return self::SHIPMENT_TYPE_MONDAY;
|
807 |
}
|
808 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
809 |
if ($this->isDomesticShipment()) {
|
810 |
return self::SHIPMENT_TYPE_DOMESTIC;
|
811 |
}
|
@@ -814,12 +855,22 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
814 |
return self::SHIPMENT_TYPE_EPS;
|
815 |
}
|
816 |
|
817 |
-
if ($this->isGlobalShipment()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
818 |
return self::SHIPMENT_TYPE_GLOBALPACK;
|
819 |
}
|
820 |
|
821 |
throw new TIG_PostNL_Exception(
|
822 |
-
$this->getHelper()->__('No valid shipment type found for
|
823 |
'POSTNL-0167'
|
824 |
);
|
825 |
}
|
@@ -1173,7 +1224,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1173 |
$xpath = self::XPATH_DEFAULT_EVENING_COD_PRODUCT_OPTION;
|
1174 |
break;
|
1175 |
case self::SHIPMENT_TYPE_PG:
|
1176 |
-
$
|
|
|
|
|
|
|
|
|
1177 |
break;
|
1178 |
case self::SHIPMENT_TYPE_PG_COD:
|
1179 |
$xpath = self::XPATH_DEFAULT_PAKJEGEMAK_COD_PRODUCT_OPTION;
|
@@ -1188,10 +1243,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1188 |
$xpath = self::XPATH_DEFAULT_PAKKETAUTOMAAT_PRODUCT_OPTION;
|
1189 |
break;
|
1190 |
case self::SHIPMENT_TYPE_EPS:
|
1191 |
-
$shippingAddress = $this->getShippingAddress();
|
1192 |
if ($this->getHelper()->canUseEpsBEOnlyOption($this->getStoreId())
|
1193 |
-
&& $
|
1194 |
-
&& $shippingAddress->getCountryId() == 'BE'
|
1195 |
) {
|
1196 |
$xpath = self::XPATH_DEFAULT_EU_BE_PRODUCT_OPTION;
|
1197 |
} else {
|
@@ -1207,11 +1260,22 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1207 |
case self::SHIPMENT_TYPE_SUNDAY:
|
1208 |
$xpath = self::XPATH_DEFAULT_SUNDAY_PRODUCT_OPTION;
|
1209 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1210 |
//no default
|
1211 |
}
|
1212 |
|
1213 |
/**
|
1214 |
-
* If the shipment is not EU or global, it's dutch (AKA a 'standard' shipment).
|
1215 |
*/
|
1216 |
if (!$xpath && $postnlOrder && $postnlOrder->hasOptions()) {
|
1217 |
$xpath = $this->_getDefaultProductCodeXpathByOptions();
|
@@ -1239,7 +1303,16 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1239 |
* If we still don't have an xpath, the shipment is a regular domestic shipment.
|
1240 |
*/
|
1241 |
if (!$xpath) {
|
1242 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1243 |
}
|
1244 |
|
1245 |
/**
|
@@ -1541,6 +1614,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1541 |
return $this->_getData('label_collection');
|
1542 |
}
|
1543 |
|
|
|
1544 |
$labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
|
1545 |
$labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
|
1546 |
|
@@ -1579,7 +1653,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1579 |
switch ($shipmentType) {
|
1580 |
case self::SHIPMENT_TYPE_DOMESTIC:
|
1581 |
case self::SHIPMENT_TYPE_MONDAY:
|
1582 |
-
$allowedProductCodes = $cifHelper->getStandardProductCodes($flat);
|
1583 |
break;
|
1584 |
case self::SHIPMENT_TYPE_DOMESTIC_COD:
|
1585 |
$allowedProductCodes = $cifHelper->getStandardCodProductCodes($flat);
|
@@ -1591,7 +1665,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1591 |
$allowedProductCodes = $cifHelper->getAvondCodProductCodes($flat);
|
1592 |
break;
|
1593 |
case self::SHIPMENT_TYPE_PG:
|
1594 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1595 |
break;
|
1596 |
case self::SHIPMENT_TYPE_PG_COD:
|
1597 |
$allowedProductCodes = $cifHelper->getPakjeGemakCodProductCodes($flat);
|
@@ -1617,6 +1698,15 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1617 |
case self::SHIPMENT_TYPE_SUNDAY:
|
1618 |
$allowedProductCodes = $cifHelper->getSundayProductCodes($flat);
|
1619 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1620 |
default:
|
1621 |
$allowedProductCodes = array();
|
1622 |
break;
|
@@ -1647,11 +1737,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1647 |
return $deliveryDate;
|
1648 |
}
|
1649 |
|
1650 |
-
/**
|
1651 |
-
* @var TIG_PostNL_Helper_Date $helper
|
1652 |
-
*/
|
1653 |
$helper = Mage::helper('postnl/date');
|
1654 |
-
|
|
|
|
|
1655 |
$deliveryDate = $helper->getDeliveryDate($orderDate, $this->getStoreId())->format('Y-m-d H:i:s');
|
1656 |
|
1657 |
return $deliveryDate;
|
@@ -2016,7 +2106,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2016 |
return false;
|
2017 |
}
|
2018 |
|
2019 |
-
$
|
|
|
2020 |
|
2021 |
$labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
|
2022 |
$labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()))
|
@@ -2202,6 +2293,37 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2202 |
return true;
|
2203 |
}
|
2204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2205 |
return false;
|
2206 |
}
|
2207 |
|
@@ -2440,6 +2562,57 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2440 |
return $isMonday;
|
2441 |
}
|
2442 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2443 |
/**
|
2444 |
* Checks if the order of this shipment is a Sunday order.
|
2445 |
*
|
@@ -2462,6 +2635,10 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2462 |
*/
|
2463 |
public function isMonday()
|
2464 |
{
|
|
|
|
|
|
|
|
|
2465 |
$postnlOrder = $this->getPostnlOrder();
|
2466 |
if ($postnlOrder && $postnlOrder->getType() == 'Monday') {
|
2467 |
return true;
|
@@ -2470,6 +2647,55 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2470 |
return false;
|
2471 |
}
|
2472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2473 |
/**
|
2474 |
* Checks if this shipment is a COD shipment.
|
2475 |
*
|
@@ -2477,7 +2703,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2477 |
*/
|
2478 |
public function isCod()
|
2479 |
{
|
2480 |
-
$codPaymentMethods =
|
2481 |
|
2482 |
/**
|
2483 |
* @var Mage_Sales_Model_Order_Payment $payment
|
@@ -2579,7 +2805,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2579 |
/**
|
2580 |
* Return barcodes are only available for Dutch parcel shipments.
|
2581 |
*/
|
2582 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
2583 |
return false;
|
2584 |
}
|
2585 |
|
@@ -2971,7 +3202,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2971 |
*/
|
2972 |
public function canPrintReturnLabels()
|
2973 |
{
|
2974 |
-
if (!$this->isDomesticShipment() || $this->isBuspakjeShipment()) {
|
2975 |
return false;
|
2976 |
}
|
2977 |
|
@@ -3342,12 +3573,15 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
3342 |
'POSTNL-0071'
|
3343 |
);
|
3344 |
}
|
|
|
|
|
|
|
3345 |
$labels = $shipment->Labels->Label;
|
3346 |
|
3347 |
/**
|
3348 |
* If this is an EU shipment and a non-combi label was returned, the product code needs to be updated.
|
3349 |
*/
|
3350 |
-
if ($this->isEuShipment()
|
3351 |
$this->setProductCode($shipment->ProductCodeDelivery);
|
3352 |
}
|
3353 |
|
@@ -3403,20 +3637,6 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
3403 |
$parcelCount = $this->_calculateParcelCount();
|
3404 |
}
|
3405 |
|
3406 |
-
/**
|
3407 |
-
* Only confirm the main shipment
|
3408 |
-
*/
|
3409 |
-
if ($parcelCount < 2) {
|
3410 |
-
$this->_confirm();
|
3411 |
-
|
3412 |
-
$this->registerConfirmation();
|
3413 |
-
|
3414 |
-
Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
|
3415 |
-
|
3416 |
-
$this->unlock();
|
3417 |
-
return $this;
|
3418 |
-
}
|
3419 |
-
|
3420 |
/**
|
3421 |
* Confirm each parcel in the shipment separately
|
3422 |
*/
|
@@ -3743,6 +3963,30 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
3743 |
return $this;
|
3744 |
}
|
3745 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3746 |
/**
|
3747 |
* Update the complete status history for the specified barcode.
|
3748 |
*
|
@@ -3814,10 +4058,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
3814 |
$statusHistory->setParentId($this->getId())
|
3815 |
->setCode($status->Code)
|
3816 |
->setDescription($status->Description)
|
3817 |
-
->setLocationCode($status->LocationCode)
|
3818 |
-
->setDestinationLocationCode(
|
3819 |
-
|
3820 |
-
|
|
|
|
|
3821 |
->setTimestamp($timestamp)
|
3822 |
->save();
|
3823 |
}
|
@@ -3922,7 +4168,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
3922 |
*/
|
3923 |
public function sendTrackAndTraceEmail($ignoreAlreadySent = false, $ignoreConfig = false)
|
3924 |
{
|
3925 |
-
$helper =
|
3926 |
if (!$this->canSendTrackAndTraceEmail($ignoreAlreadySent, $ignoreConfig)) {
|
3927 |
throw new TIG_PostNL_Exception(
|
3928 |
$helper->__('The sendTrackAndTraceEmail action is currently unavailable.'),
|
@@ -4033,7 +4279,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4033 |
$copyTo = explode(',', Mage::getStoreConfig(self::XPATH_EMAIL_COPY_TO, $storeId));
|
4034 |
$copyMethod = Mage::getStoreConfig(self::XPATH_EMAIL_COPY_METHOD, $storeId);
|
4035 |
|
|
|
4036 |
$mailer = Mage::getModel('core/email_template_mailer');
|
|
|
4037 |
$emailInfo = Mage::getModel('core/email_info');
|
4038 |
$emailInfo->addTo($order->getCustomerEmail(), $shippingAddress->getName());
|
4039 |
|
@@ -4084,15 +4332,15 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4084 |
/**
|
4085 |
* Add a comment to the order and shipment that the track & trace email has been sent.
|
4086 |
*/
|
4087 |
-
/** @
|
4088 |
-
$order->addStatusHistoryComment(
|
4089 |
$helper->__(
|
4090 |
'PostNL track & trace email has been sent for shipment #%s.',
|
4091 |
$shipment->getIncrementId()
|
4092 |
)
|
4093 |
-
)
|
4094 |
-
|
4095 |
-
|
4096 |
|
4097 |
$shipment->addComment(
|
4098 |
$helper->__('PostNL track & trace email has been sent.'),
|
@@ -4368,7 +4616,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4368 |
*/
|
4369 |
public function sendReturnLabelEmail()
|
4370 |
{
|
4371 |
-
$helper =
|
4372 |
if (!$this->canSendReturnLabelEmail()) {
|
4373 |
throw new TIG_PostNL_Exception(
|
4374 |
$helper->__('The sendReturnLabelEmail action is currently unavailable.'),
|
@@ -4472,10 +4720,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4472 |
|
4473 |
$templateVariables = new Varien_Object($templateVariables);
|
4474 |
|
4475 |
-
$
|
4476 |
-
|
4477 |
-
|
4478 |
-
|
|
|
4479 |
$returnLabelObject = new varien_Object(array('label_pdf' => $returnLabelPdf));
|
4480 |
|
4481 |
Mage::dispatchEvent(
|
@@ -4487,9 +4736,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4487 |
)
|
4488 |
);
|
4489 |
|
|
|
4490 |
$emailInfo = Mage::getModel('core/email_info');
|
4491 |
$emailInfo->addTo($order->getCustomerEmail(), $shippingAddress->getName());
|
4492 |
|
|
|
4493 |
$transactionalEmail = Mage::getModel('core/email_template');
|
4494 |
$transactionalEmail->setDesignConfig(array('area' => 'frontend', 'store' => $storeId));
|
4495 |
|
@@ -4516,15 +4767,15 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4516 |
/**
|
4517 |
* Add a comment to the order and shipment that the return label email has been sent.
|
4518 |
*/
|
4519 |
-
/** @
|
4520 |
-
$order->addStatusHistoryComment(
|
4521 |
-
|
4522 |
-
|
4523 |
-
|
4524 |
-
|
4525 |
-
|
4526 |
-
|
4527 |
-
|
4528 |
|
4529 |
$shipment->addComment(
|
4530 |
$helper->__('PostNL return label email has been sent.'),
|
@@ -4584,6 +4835,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4584 |
protected function _getIsBuspakje()
|
4585 |
{
|
4586 |
if (!$this->isDomesticShipment()
|
|
|
4587 |
|| $this->isPakketautomaatShipment()
|
4588 |
|| $this->isPakjeGemakShipment()
|
4589 |
|| $this->isCod()
|
@@ -4763,6 +5015,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4763 |
if (isset($codes['use_default']) && $codes['use_default'] == '1') {
|
4764 |
return $this->getDefaultProductCode();
|
4765 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4766 |
/**
|
4767 |
* Get the selected product code for the current shipment's shipment type.
|
4768 |
*/
|
@@ -4800,7 +5060,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4800 |
* Check if the product code is allowed.
|
4801 |
*/
|
4802 |
if (!in_array($productCode, $allowedProductCodes)) {
|
4803 |
-
$
|
|
|
|
|
4804 |
$productName = $cifHelper->__($options[$productCode]['label']);
|
4805 |
|
4806 |
throw new TIG_PostNL_Exception(
|
@@ -4826,7 +5088,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4826 |
if (!$shippingAddress
|
4827 |
|| !in_array($shippingAddress->getCountryId(), $allowedCountries)
|
4828 |
) {
|
4829 |
-
$
|
|
|
|
|
4830 |
$productName = $cifHelper->__($options[$productCode]['label']);
|
4831 |
|
4832 |
throw new TIG_PostNL_Exception(
|
@@ -4924,7 +5188,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
4924 |
/**
|
4925 |
* Only Dutch shipments that are not COD support multi-colli shipments.
|
4926 |
*/
|
4927 |
-
if (
|
4928 |
return 1;
|
4929 |
}
|
4930 |
|
77 |
* - postnl_shipment_send_return_label_email_after
|
78 |
*
|
79 |
* @method boolean getIsDomesticShipment()
|
80 |
+
* @method boolean getIsBelgiumShipment()
|
81 |
* @method boolean getIsEuShipment()
|
82 |
* @method boolean getIsGlobalShipment()
|
83 |
* @method int getParcelCount()
|
100 |
* @method boolean getIsBuspakjeShipment()
|
101 |
* @method boolean getIsSundayShipment()
|
102 |
* @method boolean getIsMondayShipment()
|
103 |
+
* @method boolean getIsSameDayShipment()
|
104 |
+
* @method boolean getIsFoodShipment()
|
105 |
+
* @method boolean getIsCooledShipment()
|
106 |
* @method int getReturnLabelsPrinted()
|
107 |
* @method string getExpectedDeliveryTimeStart()
|
108 |
* @method string getExpectedDeliveryTimeEnd()
|
109 |
* @method int getReturnPhase()
|
110 |
+
* @method string getPgLocationCode()
|
111 |
+
* @method string getPgRetailNetworkId()
|
112 |
+
* @method string getDownPartnerId()
|
113 |
+
* @method string getDownPartnerBarcode()
|
114 |
*
|
115 |
* @method TIG_PostNL_Model_Core_Shipment setLabelsPrinted(int $value)
|
116 |
* @method TIG_PostNL_Model_Core_Shipment setTreatAsAbandoned(int $value)
|
144 |
* @method TIG_PostNL_Model_Core_Shipment setIsBuspakjeShipment(bool $value)
|
145 |
* @method TIG_PostNL_Model_Core_Shipment setIsSundayShipment(bool $value)
|
146 |
* @method TIG_PostNL_Model_Core_Shipment setIsMondayShipment(bool $value)
|
147 |
+
* @method TIG_PostNL_Model_Core_Shipment setIsSameDayShipment(bool $value)
|
148 |
+
* @method TIG_PostNL_Model_Core_Shipment setIsFoodShipment(bool $value)
|
149 |
+
* @method TIG_PostNL_Model_Core_Shipment setIsCooledShipment(bool $value)
|
150 |
* @method TIG_PostNL_Model_Core_Shipment setDefaultProductCode(string $value)
|
151 |
* @method TIG_PostNL_Model_Core_Shipment setLabels(mixed $value)
|
152 |
* @method TIG_PostNL_Model_Core_Shipment setProductOption(string $value)
|
156 |
* @method TIG_PostNL_Model_Core_Shipment setExpectedDeliveryTimeStart(string $value)
|
157 |
* @method TIG_PostNL_Model_Core_Shipment setExpectedDeliveryTimeEnd(string $value)
|
158 |
* @method TIG_PostNL_Model_Core_Shipment setReturnBarcodeUrl(string $value)
|
159 |
+
* @method TIG_PostNL_Model_Core_Shipment setPgLocationCode(string $value)
|
160 |
+
* @method TIG_PostNL_Model_Core_Shipment setPgRetailNetworkId(string $value)
|
161 |
+
* @method TIG_PostNL_Model_Core_Shipment setDownPartnerId(string $value)
|
162 |
+
* @method TIG_PostNL_Model_Core_Shipment setDownPartnerBarcode(string $value)
|
163 |
*
|
164 |
* @method boolean hasBarcodeUrl()
|
165 |
* @method boolean hasPostnlOrder()
|
183 |
* @method boolean hasIsBuspakjeShipment()
|
184 |
* @method boolean hasIsSundayShipment()
|
185 |
* @method boolean hasIsMondayShipment()
|
186 |
+
* @method boolean hasIsSameDayShipment()
|
187 |
+
* @method boolean hasIsFoodShipment()
|
188 |
+
* @method boolean hasIsCooledShipment()
|
189 |
* @method boolean hasDefaultProductCode()
|
190 |
* @method boolean hasProductOption()
|
191 |
* @method boolean hasPayment()
|
194 |
* @method boolean hasExpectedDeliveryTimeEnd()
|
195 |
* @method boolean hasReturnPhase()
|
196 |
* @method boolean hasReturnBarcodeUrl()
|
197 |
+
* @method string hasPgLocationCode()
|
198 |
+
* @method string hasPgRetailNetworkId()
|
199 |
*/
|
200 |
class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
201 |
{
|
238 |
const SHIPMENT_TYPE_BUSPAKJE = 'buspakje';
|
239 |
const SHIPMENT_TYPE_SUNDAY = 'sunday';
|
240 |
const SHIPMENT_TYPE_MONDAY = 'monday';
|
241 |
+
const SHIPMENT_TYPE_SAMEDAY = 'sameday';
|
242 |
+
const SHIPMENT_TYPE_FOOD = 'food';
|
243 |
+
const SHIPMENT_TYPE_COOLED = 'cooledfood'; /** @todo rename to 'cooled_food' for consistency */
|
244 |
|
245 |
/**
|
246 |
* Xpaths to default product options settings.
|
247 |
*/
|
248 |
+
const XPATH_DEFAULT_STANDARD_PRODUCT_OPTION = 'postnl/grid/default_product_option';
|
249 |
+
const XPATH_DEFAULT_STANDARD_PRODUCT_OPTION_NETHERLANDS = 'postnl/grid/default_product_option_netherlands';
|
250 |
+
const XPATH_DEFAULT_STANDARD_COD_PRODUCT_OPTION = 'postnl/cod/default_cod_product_option';
|
251 |
+
const XPATH_DEFAULT_EVENING_PRODUCT_OPTION = 'postnl/grid/default_evening_product_option';
|
252 |
+
const XPATH_DEFAULT_EVENING_COD_PRODUCT_OPTION = 'postnl/cod/default_evening_cod_product_option';
|
253 |
+
const XPATH_DEFAULT_PAKJEGEMAK_PRODUCT_OPTION = 'postnl/grid/default_pakjegemak_product_option';
|
254 |
+
const XPATH_DEFAULT_PAKJEGEMAK_BE_PRODUCT_OPTION = 'postnl/grid/default_pakjegemak_be_product_option';
|
255 |
+
const XPATH_DEFAULT_PAKJEGEMAK_COD_PRODUCT_OPTION = 'postnl/cod/default_pakjegemak_cod_product_option';
|
256 |
+
const XPATH_DEFAULT_PGE_PRODUCT_OPTION = 'postnl/grid/default_pge_product_option';
|
257 |
+
const XPATH_DEFAULT_PGE_COD_PRODUCT_OPTION = 'postnl/cod/default_pge_cod_product_option';
|
258 |
+
const XPATH_DEFAULT_PAKKETAUTOMAAT_PRODUCT_OPTION = 'postnl/delivery_options/default_pakketautomaat_product_option';
|
259 |
+
const XPATH_DEFAULT_FOOD_PRODUCT_OPTION = 'postnl/delivery_options/default_food_product_option';
|
260 |
+
const XPATH_DEFAULT_COOLED_PRODUCT_OPTION = 'postnl/delivery_options/default_cooled_product_option';
|
261 |
+
const XPATH_DEFAULT_EU_PRODUCT_OPTION = 'postnl/grid/default_eu_product_option';
|
262 |
+
const XPATH_DEFAULT_EU_BE_PRODUCT_OPTION = 'postnl/grid/default_eu_be_product_option';
|
263 |
+
const XPATH_DEFAULT_GLOBAL_PRODUCT_OPTION = 'postnl/cif_globalpack_settings/default_global_product_option';
|
264 |
+
const XPATH_DEFAULT_BUSPAKJE_PRODUCT_OPTION = 'postnl/grid/default_buspakje_product_option';
|
265 |
+
const XPATH_USE_ALTERNATIVE_DEFAULT = 'postnl/grid/use_alternative_default';
|
266 |
+
const XPATH_ALTERNATIVE_DEFAULT_MAX_AMOUNT = 'postnl/grid/alternative_default_max_amount';
|
267 |
+
const XPATH_ALTERNATIVE_DEFAULT_OPTION = 'postnl/grid/alternative_default_option';
|
268 |
+
const XPATH_DEFAULT_STATED_ADDRESS_ONLY_OPTION = 'postnl/grid/default_stated_address_only_product_option';
|
269 |
+
const XPATH_DEFAULT_SUNDAY_PRODUCT_OPTION = 'postnl/grid/default_sunday_product_option';
|
270 |
+
const XPATH_DEFAULT_SAMEDAY_PRODUCT_OPTION = 'postnl/grid/default_sameday_product_option';
|
271 |
|
272 |
/**
|
273 |
* Xpath to weight per parcel config setting.
|
462 |
}
|
463 |
$orderId = $this->getOrderId();
|
464 |
|
465 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
466 |
$payment = Mage::getModel('sales/order_payment')
|
467 |
->load($orderId, 'parent_id');
|
468 |
|
609 |
*
|
610 |
* @param string $type
|
611 |
*
|
612 |
+
* @return TIG_PostNL_Helper_Data|TIG_PostNL_Helper_Cif|TIG_PostNL_Helper_Carrier|TIG_PostNL_Helper_DeliveryOptions|TIG_PostNL_Helper_DeliveryOptions_Fee|TIG_PostNL_Helper_AddressValidation|TIG_PostNL_Helper_Checkout|TIG_PostNL_Helper_Mijnpakket|TIG_PostNL_Helper_Parcelware|TIG_PostNL_Helper_Payment|TIG_PostNL_Helper_Webservices|TIG_PostNL_Helper_Date
|
|
|
|
|
|
|
613 |
*/
|
614 |
public function getHelper($type = 'data')
|
615 |
{
|
665 |
return $this->_extraCoverProductCodes;
|
666 |
}
|
667 |
|
668 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $productCodesModel */
|
669 |
+
$productCodesModel = Mage::getModel('postnl_core/system_config_source_allProductOptions');
|
670 |
+
$productCodes = $productCodesModel->getOptions(array('isExtraCover' => true), true);
|
671 |
|
672 |
$this->_extraCoverProductCodes = array_keys($productCodes);
|
673 |
return $this->_extraCoverProductCodes;
|
731 |
* If the product code was switched from a combi-label product code to a regular one, switch it back so we can
|
732 |
* find the product code that was chosen by the merchant.
|
733 |
*/
|
734 |
+
$cifHelper = $this->getHelper('cif');
|
735 |
+
$combiLabelProductCodes = $cifHelper->getCombiLabelProductCodes();
|
736 |
if (isset($combiLabelProductCodes[$productCode])) {
|
737 |
$productCode = $combiLabelProductCodes[$productCode];
|
738 |
}
|
740 |
/**
|
741 |
* Get all product options.
|
742 |
*/
|
743 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $productOptionsModel */
|
744 |
+
$productOptionsModel = Mage::getModel('postnl_core/system_config_source_allProductOptions');
|
745 |
+
$productOptions = $productOptionsModel->getOptions(array(), true);
|
746 |
|
747 |
if (isset($productOptions[$productCode])) {
|
748 |
$productOption = $productOptions[$productCode];
|
835 |
return self::SHIPMENT_TYPE_MONDAY;
|
836 |
}
|
837 |
|
838 |
+
if ($this->isSameDayShipment()) {
|
839 |
+
return self::SHIPMENT_TYPE_SAMEDAY;
|
840 |
+
}
|
841 |
+
|
842 |
+
if ($this->isCooledShipment()) {
|
843 |
+
return self::SHIPMENT_TYPE_COOLED;
|
844 |
+
}
|
845 |
+
|
846 |
+
if ($this->isFoodShipment()) {
|
847 |
+
return self::SHIPMENT_TYPE_FOOD;
|
848 |
+
}
|
849 |
+
|
850 |
if ($this->isDomesticShipment()) {
|
851 |
return self::SHIPMENT_TYPE_DOMESTIC;
|
852 |
}
|
855 |
return self::SHIPMENT_TYPE_EPS;
|
856 |
}
|
857 |
|
858 |
+
if ($this->isGlobalShipment()) {
|
859 |
+
if (!$this->getHelper('cif')->isGlobalAllowed()) {
|
860 |
+
throw new TIG_PostNL_Exception(
|
861 |
+
$this->getHelper()->__(
|
862 |
+
'Unable to create a shipment for order #%s, because GlobalPack is currently disabled.',
|
863 |
+
$this->getOrder()->getIncrementId()
|
864 |
+
),
|
865 |
+
'POSTNL-0240'
|
866 |
+
);
|
867 |
+
}
|
868 |
+
|
869 |
return self::SHIPMENT_TYPE_GLOBALPACK;
|
870 |
}
|
871 |
|
872 |
throw new TIG_PostNL_Exception(
|
873 |
+
$this->getHelper()->__('No valid shipment type found for order #%s.', $this->getOrderId()),
|
874 |
'POSTNL-0167'
|
875 |
);
|
876 |
}
|
1224 |
$xpath = self::XPATH_DEFAULT_EVENING_COD_PRODUCT_OPTION;
|
1225 |
break;
|
1226 |
case self::SHIPMENT_TYPE_PG:
|
1227 |
+
if ($this->isBelgiumShipment()) {
|
1228 |
+
$xpath = self::XPATH_DEFAULT_PAKJEGEMAK_BE_PRODUCT_OPTION;
|
1229 |
+
} else {
|
1230 |
+
$xpath = self::XPATH_DEFAULT_PAKJEGEMAK_PRODUCT_OPTION;
|
1231 |
+
}
|
1232 |
break;
|
1233 |
case self::SHIPMENT_TYPE_PG_COD:
|
1234 |
$xpath = self::XPATH_DEFAULT_PAKJEGEMAK_COD_PRODUCT_OPTION;
|
1243 |
$xpath = self::XPATH_DEFAULT_PAKKETAUTOMAAT_PRODUCT_OPTION;
|
1244 |
break;
|
1245 |
case self::SHIPMENT_TYPE_EPS:
|
|
|
1246 |
if ($this->getHelper()->canUseEpsBEOnlyOption($this->getStoreId())
|
1247 |
+
&& $this->isBelgiumShipment()
|
|
|
1248 |
) {
|
1249 |
$xpath = self::XPATH_DEFAULT_EU_BE_PRODUCT_OPTION;
|
1250 |
} else {
|
1260 |
case self::SHIPMENT_TYPE_SUNDAY:
|
1261 |
$xpath = self::XPATH_DEFAULT_SUNDAY_PRODUCT_OPTION;
|
1262 |
break;
|
1263 |
+
case self::SHIPMENT_TYPE_SAMEDAY:
|
1264 |
+
$xpath = self::XPATH_DEFAULT_SAMEDAY_PRODUCT_OPTION;
|
1265 |
+
break;
|
1266 |
+
case self::SHIPMENT_TYPE_FOOD:
|
1267 |
+
$xpath = self::XPATH_DEFAULT_FOOD_PRODUCT_OPTION;
|
1268 |
+
break;
|
1269 |
+
case self::SHIPMENT_TYPE_COOLED:
|
1270 |
+
$xpath = self::XPATH_DEFAULT_COOLED_PRODUCT_OPTION;
|
1271 |
+
break;
|
1272 |
+
|
1273 |
+
|
1274 |
//no default
|
1275 |
}
|
1276 |
|
1277 |
/**
|
1278 |
+
* If the shipment is not EU or global, it's dutch (AKA a 'standard' shipment).
|
1279 |
*/
|
1280 |
if (!$xpath && $postnlOrder && $postnlOrder->hasOptions()) {
|
1281 |
$xpath = $this->_getDefaultProductCodeXpathByOptions();
|
1303 |
* If we still don't have an xpath, the shipment is a regular domestic shipment.
|
1304 |
*/
|
1305 |
if (!$xpath) {
|
1306 |
+
$helper = $this->getHelper('deliveryOptions');
|
1307 |
+
$shippingAddress = $this->getShippingAddress();
|
1308 |
+
if (
|
1309 |
+
$shippingAddress->getCountryId() == 'NL' &&
|
1310 |
+
$helper->canUseDutchProducts()
|
1311 |
+
) {
|
1312 |
+
$xpath = self::XPATH_DEFAULT_STANDARD_PRODUCT_OPTION_NETHERLANDS;
|
1313 |
+
} else {
|
1314 |
+
$xpath = self::XPATH_DEFAULT_STANDARD_PRODUCT_OPTION;
|
1315 |
+
}
|
1316 |
}
|
1317 |
|
1318 |
/**
|
1614 |
return $this->_getData('label_collection');
|
1615 |
}
|
1616 |
|
1617 |
+
/** @var TIG_PostNL_Model_Core_Resource_Shipment_Label_Collection $labelCollection */
|
1618 |
$labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
|
1619 |
$labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
|
1620 |
|
1653 |
switch ($shipmentType) {
|
1654 |
case self::SHIPMENT_TYPE_DOMESTIC:
|
1655 |
case self::SHIPMENT_TYPE_MONDAY:
|
1656 |
+
$allowedProductCodes = $cifHelper->getStandardProductCodes($flat, $this->getShippingAddress()->getCountryId());
|
1657 |
break;
|
1658 |
case self::SHIPMENT_TYPE_DOMESTIC_COD:
|
1659 |
$allowedProductCodes = $cifHelper->getStandardCodProductCodes($flat);
|
1665 |
$allowedProductCodes = $cifHelper->getAvondCodProductCodes($flat);
|
1666 |
break;
|
1667 |
case self::SHIPMENT_TYPE_PG:
|
1668 |
+
$destination = false;
|
1669 |
+
|
1670 |
+
$shippingAddress = $this->getShippingAddress();
|
1671 |
+
if ($shippingAddress) {
|
1672 |
+
$destination = $shippingAddress->getCountryId();
|
1673 |
+
}
|
1674 |
+
|
1675 |
+
$allowedProductCodes = $cifHelper->getPakjeGemakProductCodes($flat, $destination);
|
1676 |
break;
|
1677 |
case self::SHIPMENT_TYPE_PG_COD:
|
1678 |
$allowedProductCodes = $cifHelper->getPakjeGemakCodProductCodes($flat);
|
1698 |
case self::SHIPMENT_TYPE_SUNDAY:
|
1699 |
$allowedProductCodes = $cifHelper->getSundayProductCodes($flat);
|
1700 |
break;
|
1701 |
+
case self::SHIPMENT_TYPE_SAMEDAY:
|
1702 |
+
$allowedProductCodes = $cifHelper->getSameDayProductCodes($flat);
|
1703 |
+
break;
|
1704 |
+
case self::SHIPMENT_TYPE_COOLED:
|
1705 |
+
$allowedProductCodes = $cifHelper->getCooledProductCodes($flat);
|
1706 |
+
break;
|
1707 |
+
case self::SHIPMENT_TYPE_FOOD:
|
1708 |
+
$allowedProductCodes = $cifHelper->getFoodProductCodes($flat);
|
1709 |
+
break;
|
1710 |
default:
|
1711 |
$allowedProductCodes = array();
|
1712 |
break;
|
1737 |
return $deliveryDate;
|
1738 |
}
|
1739 |
|
1740 |
+
/** @var TIG_PostNL_Helper_Date $helper */
|
|
|
|
|
1741 |
$helper = Mage::helper('postnl/date');
|
1742 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
1743 |
+
$dateModel = Mage::getSingleton('core/date');
|
1744 |
+
$orderDate = $dateModel->date(null, $this->getOrder()->getCreatedAt());
|
1745 |
$deliveryDate = $helper->getDeliveryDate($orderDate, $this->getStoreId())->format('Y-m-d H:i:s');
|
1746 |
|
1747 |
return $deliveryDate;
|
2106 |
return false;
|
2107 |
}
|
2108 |
|
2109 |
+
$cifHelper = $this->getHelper('cif');
|
2110 |
+
$returnLabelTypes = $cifHelper->getReturnLabelTypes();
|
2111 |
|
2112 |
$labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
|
2113 |
$labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()))
|
2293 |
return true;
|
2294 |
}
|
2295 |
|
2296 |
+
if (
|
2297 |
+
$shippingDestination == 'NL' &&
|
2298 |
+
$domesticCountry == 'BE' &&
|
2299 |
+
$this->getHelper('deliveryOptions')->canUseDutchProducts()
|
2300 |
+
) {
|
2301 |
+
return true;
|
2302 |
+
}
|
2303 |
+
|
2304 |
+
return false;
|
2305 |
+
}
|
2306 |
+
|
2307 |
+
/**
|
2308 |
+
* Check if the shipping destination of this shipment is Belgium.
|
2309 |
+
*
|
2310 |
+
* @return bool
|
2311 |
+
*/
|
2312 |
+
public function isBelgiumShipment()
|
2313 |
+
{
|
2314 |
+
if ($this->getIsBelgiumShipment()) {
|
2315 |
+
return true;
|
2316 |
+
}
|
2317 |
+
|
2318 |
+
$shippingAddress = $this->getShippingAddress();
|
2319 |
+
if (!$shippingAddress) {
|
2320 |
+
return false;
|
2321 |
+
}
|
2322 |
+
|
2323 |
+
if ($shippingAddress->getCountryId() == 'BE') {
|
2324 |
+
return true;
|
2325 |
+
}
|
2326 |
+
|
2327 |
return false;
|
2328 |
}
|
2329 |
|
2562 |
return $isMonday;
|
2563 |
}
|
2564 |
|
2565 |
+
/**
|
2566 |
+
* Check if this shipment is a same day delivery shipment.
|
2567 |
+
*
|
2568 |
+
* @return boolean
|
2569 |
+
*/
|
2570 |
+
public function isSameDayShipment()
|
2571 |
+
{
|
2572 |
+
if ($this->hasIsSameDayShipment()) {
|
2573 |
+
return $this->getIsSameDayShipment();
|
2574 |
+
}
|
2575 |
+
|
2576 |
+
$isMonday = $this->isSameDay();
|
2577 |
+
|
2578 |
+
$this->setIsSameDayShipment($isMonday);
|
2579 |
+
return $isMonday;
|
2580 |
+
}
|
2581 |
+
|
2582 |
+
/**
|
2583 |
+
* Check if this shipment is a food delivery shipment.
|
2584 |
+
*
|
2585 |
+
* @return bool
|
2586 |
+
*/
|
2587 |
+
public function isFoodShipment()
|
2588 |
+
{
|
2589 |
+
if ($this->hasIsFoodShipment()) {
|
2590 |
+
return $this->getIsFoodShipment();
|
2591 |
+
}
|
2592 |
+
|
2593 |
+
$isFood = $this->isFood();
|
2594 |
+
|
2595 |
+
$this->setIsFoodShipment($isFood);
|
2596 |
+
return $isFood;
|
2597 |
+
}
|
2598 |
+
|
2599 |
+
/**
|
2600 |
+
* Check if this shipment is a cooled food delivery shipment.
|
2601 |
+
*
|
2602 |
+
* @return bool
|
2603 |
+
*/
|
2604 |
+
public function isCooledShipment()
|
2605 |
+
{
|
2606 |
+
if ($this->hasIsCooledShipment()) {
|
2607 |
+
return $this->getIsCooledShipment();
|
2608 |
+
}
|
2609 |
+
|
2610 |
+
$isFood = $this->isCooled();
|
2611 |
+
|
2612 |
+
$this->setIsCooledShipment($isFood);
|
2613 |
+
return $isFood;
|
2614 |
+
}
|
2615 |
+
|
2616 |
/**
|
2617 |
* Checks if the order of this shipment is a Sunday order.
|
2618 |
*
|
2635 |
*/
|
2636 |
public function isMonday()
|
2637 |
{
|
2638 |
+
if (!$this->isDomesticShipment()) {
|
2639 |
+
return false;
|
2640 |
+
}
|
2641 |
+
|
2642 |
$postnlOrder = $this->getPostnlOrder();
|
2643 |
if ($postnlOrder && $postnlOrder->getType() == 'Monday') {
|
2644 |
return true;
|
2647 |
return false;
|
2648 |
}
|
2649 |
|
2650 |
+
/**
|
2651 |
+
* Checks if the order of this shipment is a Sameday order.
|
2652 |
+
*
|
2653 |
+
* @return bool
|
2654 |
+
*/
|
2655 |
+
public function isSameDay()
|
2656 |
+
{
|
2657 |
+
$postnlOrder = $this->getPostnlOrder();
|
2658 |
+
if ($postnlOrder && $postnlOrder->getType() == 'Sameday') {
|
2659 |
+
return true;
|
2660 |
+
}
|
2661 |
+
|
2662 |
+
return false;
|
2663 |
+
}
|
2664 |
+
|
2665 |
+
/**
|
2666 |
+
* Checks if the order of this shipment is a Food order.
|
2667 |
+
*
|
2668 |
+
* @return bool
|
2669 |
+
*/
|
2670 |
+
public function isFood()
|
2671 |
+
{
|
2672 |
+
$postnlOrder = $this->getPostnlOrder();
|
2673 |
+
if ($postnlOrder
|
2674 |
+
&& ($postnlOrder->getType() == $postnlOrder::TYPE_FOOD
|
2675 |
+
|| $postnlOrder->getType() == $postnlOrder::TYPE_COOLED_FOOD
|
2676 |
+
)
|
2677 |
+
) {
|
2678 |
+
return true;
|
2679 |
+
}
|
2680 |
+
|
2681 |
+
return false;
|
2682 |
+
}
|
2683 |
+
|
2684 |
+
/**
|
2685 |
+
* Checks if the order of this shipment is a Cooled Food order.
|
2686 |
+
*
|
2687 |
+
* @return bool
|
2688 |
+
*/
|
2689 |
+
public function isCooled()
|
2690 |
+
{
|
2691 |
+
$postnlOrder = $this->getPostnlOrder();
|
2692 |
+
if ($postnlOrder && $postnlOrder->getType() == $postnlOrder::TYPE_COOLED_FOOD) {
|
2693 |
+
return true;
|
2694 |
+
}
|
2695 |
+
|
2696 |
+
return false;
|
2697 |
+
}
|
2698 |
+
|
2699 |
/**
|
2700 |
* Checks if this shipment is a COD shipment.
|
2701 |
*
|
2703 |
*/
|
2704 |
public function isCod()
|
2705 |
{
|
2706 |
+
$codPaymentMethods = $this->getHelper('payment')->getCodPaymentMethods();
|
2707 |
|
2708 |
/**
|
2709 |
* @var Mage_Sales_Model_Order_Payment $payment
|
2805 |
/**
|
2806 |
* Return barcodes are only available for Dutch parcel shipments.
|
2807 |
*/
|
2808 |
+
if (
|
2809 |
+
$this->getShippingAddress()->getCountryId() != 'NL' ||
|
2810 |
+
!$this->isDomesticShipment() ||
|
2811 |
+
$this->isBuspakjeShipment() ||
|
2812 |
+
$this->isFoodShipment()
|
2813 |
+
) {
|
2814 |
return false;
|
2815 |
}
|
2816 |
|
3202 |
*/
|
3203 |
public function canPrintReturnLabels()
|
3204 |
{
|
3205 |
+
if (!$this->isDomesticShipment() || $this->isBuspakjeShipment() || $this->isFoodShipment()) {
|
3206 |
return false;
|
3207 |
}
|
3208 |
|
3573 |
'POSTNL-0071'
|
3574 |
);
|
3575 |
}
|
3576 |
+
|
3577 |
+
$this->_saveDownPartnerData($shipment);
|
3578 |
+
|
3579 |
$labels = $shipment->Labels->Label;
|
3580 |
|
3581 |
/**
|
3582 |
* If this is an EU shipment and a non-combi label was returned, the product code needs to be updated.
|
3583 |
*/
|
3584 |
+
if ($this->isEuShipment()) {
|
3585 |
$this->setProductCode($shipment->ProductCodeDelivery);
|
3586 |
}
|
3587 |
|
3637 |
$parcelCount = $this->_calculateParcelCount();
|
3638 |
}
|
3639 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3640 |
/**
|
3641 |
* Confirm each parcel in the shipment separately
|
3642 |
*/
|
3963 |
return $this;
|
3964 |
}
|
3965 |
|
3966 |
+
/**
|
3967 |
+
* @param $shipment
|
3968 |
+
*
|
3969 |
+
* @throws TIG_PostNL_Exception
|
3970 |
+
*/
|
3971 |
+
protected function _saveDownPartnerData($shipment)
|
3972 |
+
{
|
3973 |
+
if (isset($shipment->DownPartnerID)
|
3974 |
+
&& isset($shipment->DownPartnerBarcode)
|
3975 |
+
&& !is_null($shipment->DownPartnerID)
|
3976 |
+
&& !is_null($shipment->DownPartnerBarcode)
|
3977 |
+
) {
|
3978 |
+
try {
|
3979 |
+
$this->setDownPartnerId($shipment->DownPartnerID);
|
3980 |
+
$this->setDownPartnerBarcode($shipment->DownPartnerBarcode);
|
3981 |
+
} catch (Exception $e) {
|
3982 |
+
throw new TIG_PostNL_Exception(
|
3983 |
+
Mage::helper('postnl')->__('Unable to save down partner data.'),
|
3984 |
+
'POSTNL-0245'
|
3985 |
+
);
|
3986 |
+
}
|
3987 |
+
}
|
3988 |
+
}
|
3989 |
+
|
3990 |
/**
|
3991 |
* Update the complete status history for the specified barcode.
|
3992 |
*
|
4058 |
$statusHistory->setParentId($this->getId())
|
4059 |
->setCode($status->Code)
|
4060 |
->setDescription($status->Description)
|
4061 |
+
->setLocationCode(empty($status->LocationCode) ? null : $status->LocationCode)
|
4062 |
+
->setDestinationLocationCode(
|
4063 |
+
empty($status->DestinationLocationCode) ? null : $status->DestinationLocationCode
|
4064 |
+
)
|
4065 |
+
->setRouteCode(empty($status->RouteCode) ? null : $status->RouteCode)
|
4066 |
+
->setRouteName(empty($status->RouteName) ? null : $status->RouteName)
|
4067 |
->setTimestamp($timestamp)
|
4068 |
->save();
|
4069 |
}
|
4168 |
*/
|
4169 |
public function sendTrackAndTraceEmail($ignoreAlreadySent = false, $ignoreConfig = false)
|
4170 |
{
|
4171 |
+
$helper = $this->getHelper();
|
4172 |
if (!$this->canSendTrackAndTraceEmail($ignoreAlreadySent, $ignoreConfig)) {
|
4173 |
throw new TIG_PostNL_Exception(
|
4174 |
$helper->__('The sendTrackAndTraceEmail action is currently unavailable.'),
|
4279 |
$copyTo = explode(',', Mage::getStoreConfig(self::XPATH_EMAIL_COPY_TO, $storeId));
|
4280 |
$copyMethod = Mage::getStoreConfig(self::XPATH_EMAIL_COPY_METHOD, $storeId);
|
4281 |
|
4282 |
+
/** @var Mage_Core_Model_Email_Template_Mailer $mailer */
|
4283 |
$mailer = Mage::getModel('core/email_template_mailer');
|
4284 |
+
/** @var Mage_Core_Model_Email_Info $emailInfo */
|
4285 |
$emailInfo = Mage::getModel('core/email_info');
|
4286 |
$emailInfo->addTo($order->getCustomerEmail(), $shippingAddress->getName());
|
4287 |
|
4332 |
/**
|
4333 |
* Add a comment to the order and shipment that the track & trace email has been sent.
|
4334 |
*/
|
4335 |
+
/** @var Mage_Sales_Model_Order_Status_History $orderHistory */
|
4336 |
+
$orderHistory = $order->addStatusHistoryComment(
|
4337 |
$helper->__(
|
4338 |
'PostNL track & trace email has been sent for shipment #%s.',
|
4339 |
$shipment->getIncrementId()
|
4340 |
)
|
4341 |
+
);
|
4342 |
+
$orderHistory->setIsCustomerNotified(1);
|
4343 |
+
$orderHistory->save();
|
4344 |
|
4345 |
$shipment->addComment(
|
4346 |
$helper->__('PostNL track & trace email has been sent.'),
|
4616 |
*/
|
4617 |
public function sendReturnLabelEmail()
|
4618 |
{
|
4619 |
+
$helper = $this->getHelper();
|
4620 |
if (!$this->canSendReturnLabelEmail()) {
|
4621 |
throw new TIG_PostNL_Exception(
|
4622 |
$helper->__('The sendReturnLabelEmail action is currently unavailable.'),
|
4720 |
|
4721 |
$templateVariables = new Varien_Object($templateVariables);
|
4722 |
|
4723 |
+
/** @var TIG_PostNL_Model_Core_Label $labelModel */
|
4724 |
+
$labelModel = Mage::getModel('postnl_core/label');
|
4725 |
+
$returnLabelPdf = $labelModel->setLabelSize('A4')
|
4726 |
+
->setOutputMode('S')
|
4727 |
+
->createPdf($returnLabels);
|
4728 |
$returnLabelObject = new varien_Object(array('label_pdf' => $returnLabelPdf));
|
4729 |
|
4730 |
Mage::dispatchEvent(
|
4736 |
)
|
4737 |
);
|
4738 |
|
4739 |
+
/** @var Mage_Core_Model_Email_Info $emailInfo */
|
4740 |
$emailInfo = Mage::getModel('core/email_info');
|
4741 |
$emailInfo->addTo($order->getCustomerEmail(), $shippingAddress->getName());
|
4742 |
|
4743 |
+
/** @var Mage_Core_Model_Email_Template $transactionalEmail */
|
4744 |
$transactionalEmail = Mage::getModel('core/email_template');
|
4745 |
$transactionalEmail->setDesignConfig(array('area' => 'frontend', 'store' => $storeId));
|
4746 |
|
4767 |
/**
|
4768 |
* Add a comment to the order and shipment that the return label email has been sent.
|
4769 |
*/
|
4770 |
+
/** @var Mage_Sales_Model_Order_Status_History $orderHistory */
|
4771 |
+
$orderHistory = $order->addStatusHistoryComment(
|
4772 |
+
$helper->__(
|
4773 |
+
'PostNL return label email has been sent for shipment #%s.',
|
4774 |
+
$shipment->getIncrementId()
|
4775 |
+
)
|
4776 |
+
);
|
4777 |
+
$orderHistory->setIsCustomerNotified(1);
|
4778 |
+
$orderHistory->save();
|
4779 |
|
4780 |
$shipment->addComment(
|
4781 |
$helper->__('PostNL return label email has been sent.'),
|
4835 |
protected function _getIsBuspakje()
|
4836 |
{
|
4837 |
if (!$this->isDomesticShipment()
|
4838 |
+
|| $this->getShippingAddress()->getCountryId() != 'NL'
|
4839 |
|| $this->isPakketautomaatShipment()
|
4840 |
|| $this->isPakjeGemakShipment()
|
4841 |
|| $this->isCod()
|
5015 |
if (isset($codes['use_default']) && $codes['use_default'] == '1') {
|
5016 |
return $this->getDefaultProductCode();
|
5017 |
}
|
5018 |
+
|
5019 |
+
/**
|
5020 |
+
* If this is a Belgian PG shipment, add the 'be' suffix.
|
5021 |
+
*/
|
5022 |
+
if ($shipmentType == self::SHIPMENT_TYPE_PG && $this->isBelgiumShipment()) {
|
5023 |
+
$shipmentType .= '_be';
|
5024 |
+
}
|
5025 |
+
|
5026 |
/**
|
5027 |
* Get the selected product code for the current shipment's shipment type.
|
5028 |
*/
|
5060 |
* Check if the product code is allowed.
|
5061 |
*/
|
5062 |
if (!in_array($productCode, $allowedProductCodes)) {
|
5063 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $productOptionsModel */
|
5064 |
+
$productOptionsModel = Mage::getSingleton('postnl_core/system_config_source_allProductOptions');
|
5065 |
+
$options = $productOptionsModel->getOptions();
|
5066 |
$productName = $cifHelper->__($options[$productCode]['label']);
|
5067 |
|
5068 |
throw new TIG_PostNL_Exception(
|
5088 |
if (!$shippingAddress
|
5089 |
|| !in_array($shippingAddress->getCountryId(), $allowedCountries)
|
5090 |
) {
|
5091 |
+
/** @var TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions $productOptionsModel */
|
5092 |
+
$productOptionsModel = Mage::getSingleton('postnl_core/system_config_source_allProductOptions');
|
5093 |
+
$options = $productOptionsModel->getOptions();
|
5094 |
$productName = $cifHelper->__($options[$productCode]['label']);
|
5095 |
|
5096 |
throw new TIG_PostNL_Exception(
|
5188 |
/**
|
5189 |
* Only Dutch shipments that are not COD support multi-colli shipments.
|
5190 |
*/
|
5191 |
+
if ($this->getShippingAddress()->getCountryId() != 'NL' || $this->isCod()) {
|
5192 |
return 1;
|
5193 |
}
|
5194 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class TIG_PostNL_Model_Core_Shipment_Barcode
|
@@ -104,4 +104,4 @@ class TIG_PostNL_Model_Core_Shipment_Barcode extends Mage_Core_Model_Abstract
|
|
104 |
|
105 |
return $this;
|
106 |
}
|
107 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class TIG_PostNL_Model_Core_Shipment_Barcode
|
104 |
|
105 |
return $this;
|
106 |
}
|
107 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class TIG_PostNL_Model_Core_Shipment_Label
|
@@ -52,8 +52,8 @@ class TIG_PostNL_Model_Core_Shipment_Label extends Mage_Core_Model_Abstract
|
|
52 |
* Supported label types.
|
53 |
*/
|
54 |
const LABEL_TYPE_LABEL = 'Label';
|
55 |
-
const LABEL_TYPE_RETURN_LABEL = 'Return
|
56 |
-
const LABEL_TYPE_BUSPAKJE = '
|
57 |
const LABEL_TYPE_BUSPAKJEEXTRA = 'BusPakjeExtra';
|
58 |
const LABEL_TYPE_LABEL_COMBI = 'Label-combi';
|
59 |
const LABEL_TYPE_CODCARD = 'CODcard';
|
@@ -113,7 +113,9 @@ class TIG_PostNL_Model_Core_Shipment_Label extends Mage_Core_Model_Abstract
|
|
113 |
public function isReturnLabel()
|
114 |
{
|
115 |
$labelType = $this->getLabelType();
|
116 |
-
|
|
|
|
|
117 |
|
118 |
if (in_array($labelType, $returnLabelTypes)) {
|
119 |
return true;
|
@@ -155,4 +157,4 @@ class TIG_PostNL_Model_Core_Shipment_Label extends Mage_Core_Model_Abstract
|
|
155 |
|
156 |
return parent::_beforeSave();
|
157 |
}
|
158 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class TIG_PostNL_Model_Core_Shipment_Label
|
52 |
* Supported label types.
|
53 |
*/
|
54 |
const LABEL_TYPE_LABEL = 'Label';
|
55 |
+
const LABEL_TYPE_RETURN_LABEL = 'Return Label';
|
56 |
+
const LABEL_TYPE_BUSPAKJE = 'BusPakje';
|
57 |
const LABEL_TYPE_BUSPAKJEEXTRA = 'BusPakjeExtra';
|
58 |
const LABEL_TYPE_LABEL_COMBI = 'Label-combi';
|
59 |
const LABEL_TYPE_CODCARD = 'CODcard';
|
113 |
public function isReturnLabel()
|
114 |
{
|
115 |
$labelType = $this->getLabelType();
|
116 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
117 |
+
$helper = Mage::helper('postnl/cif');
|
118 |
+
$returnLabelTypes = $helper->getReturnLabelTypes();
|
119 |
|
120 |
if (in_array($labelType, $returnLabelTypes)) {
|
121 |
return true;
|
157 |
|
158 |
return parent::_beforeSave();
|
159 |
}
|
160 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
@@ -60,14 +60,14 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
|
60 |
*/
|
61 |
protected function _getLockFile()
|
62 |
{
|
63 |
-
if ($this->_lockFile
|
64 |
return $this->_lockFile;
|
65 |
}
|
66 |
|
67 |
$varDir = Mage::getConfig()->getVarDir('locks');
|
68 |
$file = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
|
69 |
|
70 |
-
if (is_file($file)) {
|
71 |
if($this->_lockIsExpired()){
|
72 |
unlink($file);//remove file
|
73 |
$this->_lockFile = fopen($file, 'x');//create new lock file
|
@@ -78,7 +78,9 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
|
78 |
$this->_lockFile = fopen($file, 'x');
|
79 |
}
|
80 |
|
81 |
-
|
|
|
|
|
82 |
|
83 |
return $this->_lockFile;
|
84 |
}
|
@@ -191,7 +193,9 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
|
191 |
return false;
|
192 |
}
|
193 |
|
194 |
-
$
|
|
|
|
|
195 |
|
196 |
$contents = file_get_contents($file);
|
197 |
$lockTime = strtotime($contents);
|
@@ -220,4 +224,4 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
|
220 |
|
221 |
return;
|
222 |
}
|
223 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
60 |
*/
|
61 |
protected function _getLockFile()
|
62 |
{
|
63 |
+
if ($this->_lockFile) {
|
64 |
return $this->_lockFile;
|
65 |
}
|
66 |
|
67 |
$varDir = Mage::getConfig()->getVarDir('locks');
|
68 |
$file = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
|
69 |
|
70 |
+
if (is_file($file) && is_writable($file)) {
|
71 |
if($this->_lockIsExpired()){
|
72 |
unlink($file);//remove file
|
73 |
$this->_lockFile = fopen($file, 'x');//create new lock file
|
78 |
$this->_lockFile = fopen($file, 'x');
|
79 |
}
|
80 |
|
81 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
82 |
+
$dateModel = Mage::getModel('core/date');
|
83 |
+
fwrite($this->_lockFile, date('r', $dateModel->gmtTimestamp()));
|
84 |
|
85 |
return $this->_lockFile;
|
86 |
}
|
193 |
return false;
|
194 |
}
|
195 |
|
196 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
197 |
+
$dateModel = Mage::getModel('core/date');
|
198 |
+
$fiveMinAgo = $dateModel->gmtTimestamp();
|
199 |
|
200 |
$contents = file_get_contents($file);
|
201 |
$lockTime = strtotime($contents);
|
224 |
|
225 |
return;
|
226 |
}
|
227 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class TIG_PostNL_Model_Core_Shipment_Status_History
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Class TIG_PostNL_Model_Core_Shipment_Status_History
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Backend_HourMinute extends Mage_Core_Model_Config_Data
|
@@ -54,4 +54,4 @@ class TIG_PostNL_Model_Core_System_Config_Backend_HourMinute extends Mage_Core_M
|
|
54 |
|
55 |
return parent::_beforeSave();
|
56 |
}
|
57 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Backend_HourMinute extends Mage_Core_Model_Config_Data
|
54 |
|
55 |
return parent::_beforeSave();
|
56 |
}
|
57 |
+
}
|
@@ -33,8 +33,10 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
|
|
|
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Backend_Image_Pdf extends Mage_Adminhtml_Model_System_Config_Backend_Image_Pdf
|
40 |
{
|
@@ -99,9 +101,6 @@ class TIG_PostNL_Model_Core_System_Config_Backend_Image_Pdf extends Mage_Adminht
|
|
99 |
*/
|
100 |
protected function _getBaseUploadDir()
|
101 |
{
|
102 |
-
/**
|
103 |
-
* @var $fieldConfig Varien_Simplexml_Element
|
104 |
-
*/
|
105 |
$fieldConfig = $this->getFieldConfig();
|
106 |
|
107 |
if (empty($fieldConfig->upload_dir)) {
|
@@ -122,4 +121,4 @@ class TIG_PostNL_Model_Core_System_Config_Backend_Image_Pdf extends Mage_Adminht
|
|
122 |
|
123 |
return $uploadDir;
|
124 |
}
|
125 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*
|
39 |
+
* @method Varien_Simplexml_Element getFieldConfig()
|
40 |
*/
|
41 |
class TIG_PostNL_Model_Core_System_Config_Backend_Image_Pdf extends Mage_Adminhtml_Model_System_Config_Backend_Image_Pdf
|
42 |
{
|
101 |
*/
|
102 |
protected function _getBaseUploadDir()
|
103 |
{
|
|
|
|
|
|
|
104 |
$fieldConfig = $this->getFieldConfig();
|
105 |
|
106 |
if (empty($fieldConfig->upload_dir)) {
|
121 |
|
122 |
return $uploadDir;
|
123 |
}
|
124 |
+
}
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Model_Core_System_Config_Backend_ProductType extends Mage_Core_Model_Config_Data
|
40 |
+
{
|
41 |
+
const ATTRIBUTE_CODE_PRODUCT_TYPE = 'postnl_product_type';
|
42 |
+
|
43 |
+
const PRODUCTY_TYPE_NON_FOOD = '0';
|
44 |
+
const PRODUCTY_TYPE_DRY_GROCERIES = '1';
|
45 |
+
const PRODUCTY_TYPE_COOL_PRODUCTS = '2';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @var array
|
49 |
+
*/
|
50 |
+
protected $_validOptions = array(
|
51 |
+
self::PRODUCTY_TYPE_NON_FOOD,
|
52 |
+
self::PRODUCTY_TYPE_DRY_GROCERIES,
|
53 |
+
self::PRODUCTY_TYPE_COOL_PRODUCTS,
|
54 |
+
);
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Validate the value chosen by the user.
|
58 |
+
*/
|
59 |
+
protected function _beforeSave()
|
60 |
+
{
|
61 |
+
$value = $this->getValue();
|
62 |
+
|
63 |
+
if (!in_array($value, $this->_validOptions)) {
|
64 |
+
throw new TIG_PostNL_Exception(
|
65 |
+
Mage::helper('postnl')->__("Please enter a valid default value for PostNL product type."),
|
66 |
+
''
|
67 |
+
);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* The product attribute's default value needs to be updated to the chosen value.
|
73 |
+
*/
|
74 |
+
protected function _afterSave()
|
75 |
+
{
|
76 |
+
$value = $this->getValue();
|
77 |
+
|
78 |
+
/** @var Mage_Eav_Model_Entity_Attribute $attributeModel */
|
79 |
+
$attributeModel = Mage::getModel('eav/entity_attribute');
|
80 |
+
$attributeModel->loadByCode(Mage_Catalog_Model_Product::ENTITY, self::ATTRIBUTE_CODE_PRODUCT_TYPE);
|
81 |
+
|
82 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
83 |
+
$attributeModel->setDefaultValue($value)->save();
|
84 |
+
}
|
85 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Backend_SenderCountry extends Mage_Core_Model_Config_Data
|
@@ -41,7 +41,10 @@ class TIG_PostNL_Model_Core_System_Config_Backend_SenderCountry extends Mage_Cor
|
|
41 |
/**
|
42 |
* Xpath to alternative sender country setting.
|
43 |
*/
|
44 |
-
const XPATH_ALTERNATIVE_SENDER_COUNTRY
|
|
|
|
|
|
|
45 |
|
46 |
/**
|
47 |
* @var array
|
@@ -87,13 +90,44 @@ class TIG_PostNL_Model_Core_System_Config_Backend_SenderCountry extends Mage_Cor
|
|
87 |
*/
|
88 |
protected function _afterSave()
|
89 |
{
|
|
|
90 |
$alternativeSenderCountry = Mage::getModel('core/config_data')
|
91 |
->load(self::XPATH_ALTERNATIVE_SENDER_COUNTRY, 'path');
|
92 |
|
|
|
93 |
$alternativeSenderCountry->setData($this->getData())
|
94 |
->setPath(self::XPATH_ALTERNATIVE_SENDER_COUNTRY)
|
95 |
->save();
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
return parent::_afterSave();
|
98 |
}
|
99 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Backend_SenderCountry extends Mage_Core_Model_Config_Data
|
41 |
/**
|
42 |
* Xpath to alternative sender country setting.
|
43 |
*/
|
44 |
+
const XPATH_ALTERNATIVE_SENDER_COUNTRY = 'postnl/cif_address/alternative_sender_country';
|
45 |
+
const XPATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/grid/supported_product_options';
|
46 |
+
const XPATH_SUPPORTED_PRODUCT_OPTIONS_BE = 'postnl/grid/supported_product_options_be';
|
47 |
+
const XPATH_USE_DUTCH_PRODUCTS = 'postnl/cif_labels_and_confirming/use_dutch_products';
|
48 |
|
49 |
/**
|
50 |
* @var array
|
90 |
*/
|
91 |
protected function _afterSave()
|
92 |
{
|
93 |
+
/** @var Mage_Core_Model_Config_Data $alternativeSenderCountry */
|
94 |
$alternativeSenderCountry = Mage::getModel('core/config_data')
|
95 |
->load(self::XPATH_ALTERNATIVE_SENDER_COUNTRY, 'path');
|
96 |
|
97 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
98 |
$alternativeSenderCountry->setData($this->getData())
|
99 |
->setPath(self::XPATH_ALTERNATIVE_SENDER_COUNTRY)
|
100 |
->save();
|
101 |
|
102 |
+
/**
|
103 |
+
* If the country is changed from the Netherlands to Belgium or vice versa, we need to update the
|
104 |
+
* default selected product codes. Retrieve the default value and save them to the config.
|
105 |
+
*/
|
106 |
+
if ($this->isValueChanged()) {
|
107 |
+
Mage::getConfig()->deleteConfig(self::XPATH_SUPPORTED_PRODUCT_OPTIONS);
|
108 |
+
|
109 |
+
if ($this->getValue() == 'BE') {
|
110 |
+
$canUseDutchProducts = Mage::getStoreConfig(self::XPATH_USE_DUTCH_PRODUCTS);
|
111 |
+
if ($canUseDutchProducts) {
|
112 |
+
$value = Mage::getStoreConfig(self::XPATH_SUPPORTED_PRODUCT_OPTIONS);
|
113 |
+
$value .= ',' .Mage::getStoreConfig(self::XPATH_SUPPORTED_PRODUCT_OPTIONS_BE);
|
114 |
+
|
115 |
+
$values = explode(',', $value);
|
116 |
+
$values = array_unique($values);
|
117 |
+
sort($values);
|
118 |
+
|
119 |
+
$value = implode(',', $values);
|
120 |
+
} else {
|
121 |
+
$value = Mage::getStoreConfig(self::XPATH_SUPPORTED_PRODUCT_OPTIONS_BE);
|
122 |
+
}
|
123 |
+
|
124 |
+
Mage::getModel('core/config')->saveConfig(
|
125 |
+
self::XPATH_SUPPORTED_PRODUCT_OPTIONS,
|
126 |
+
$value
|
127 |
+
);
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
return parent::_afterSave();
|
132 |
}
|
133 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsIncludingTax()
|
@@ -77,11 +77,13 @@ class TIG_PostNL_Model_Core_System_Config_Backend_ValidateDefaultOption extends
|
|
77 |
return true;
|
78 |
}
|
79 |
|
|
|
80 |
$helper = Mage::helper('postnl');
|
81 |
|
82 |
/**
|
83 |
* Get the system.xml configuration.
|
84 |
*/
|
|
|
85 |
$configFields = Mage::getSingleton('adminhtml/config');
|
86 |
$sections = $configFields->getSections('postnl');
|
87 |
|
@@ -100,6 +102,7 @@ class TIG_PostNL_Model_Core_System_Config_Backend_ValidateDefaultOption extends
|
|
100 |
/**
|
101 |
* Get the translated label of the supported options field.
|
102 |
*/
|
|
|
103 |
$supportedOptionsLabel = (string) $sections->postnl
|
104 |
->groups
|
105 |
->cif_product_options
|
@@ -149,4 +152,4 @@ class TIG_PostNL_Model_Core_System_Config_Backend_ValidateDefaultOption extends
|
|
149 |
|
150 |
return parent::_beforeSave();
|
151 |
}
|
152 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasIsIncludingTax()
|
77 |
return true;
|
78 |
}
|
79 |
|
80 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
81 |
$helper = Mage::helper('postnl');
|
82 |
|
83 |
/**
|
84 |
* Get the system.xml configuration.
|
85 |
*/
|
86 |
+
/** @var Mage_Adminhtml_Model_Config $configFields */
|
87 |
$configFields = Mage::getSingleton('adminhtml/config');
|
88 |
$sections = $configFields->getSections('postnl');
|
89 |
|
102 |
/**
|
103 |
* Get the translated label of the supported options field.
|
104 |
*/
|
105 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
106 |
$supportedOptionsLabel = (string) $sections->postnl
|
107 |
->groups
|
108 |
->cif_product_options
|
152 |
|
153 |
return parent::_beforeSave();
|
154 |
}
|
155 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
@@ -60,6 +60,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
60 |
'isAvond' => true,
|
61 |
'isSunday' => false,
|
62 |
'isCod' => true,
|
|
|
63 |
'countryLimitation' => 'NL',
|
64 |
'group' => 'standard_options',
|
65 |
),
|
@@ -70,6 +71,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
70 |
'isAvond' => true,
|
71 |
'isSunday' => false,
|
72 |
'isCod' => true,
|
|
|
73 |
'countryLimitation' => 'NL',
|
74 |
'group' => 'standard_options',
|
75 |
),
|
@@ -80,6 +82,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
80 |
'isAvond' => true,
|
81 |
'isSunday' => false,
|
82 |
'isCod' => true,
|
|
|
83 |
'countryLimitation'=> 'NL',
|
84 |
'group' => 'standard_options',
|
85 |
),
|
@@ -90,6 +93,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
90 |
'isAvond' => true,
|
91 |
'isSunday' => false,
|
92 |
'isCod' => true,
|
|
|
93 |
'countryLimitation'=> 'NL',
|
94 |
'group' => 'standard_options',
|
95 |
),
|
@@ -100,6 +104,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
100 |
'isAvond' => true,
|
101 |
'isSunday' => true,
|
102 |
'isCod' => false,
|
|
|
103 |
'countryLimitation' => 'NL',
|
104 |
'group' => 'standard_options',
|
105 |
),
|
@@ -110,6 +115,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
110 |
'isSunday' => true,
|
111 |
'isExtraCover' => true,
|
112 |
'isCod' => false,
|
|
|
113 |
'countryLimitation'=> 'NL',
|
114 |
'group' => 'standard_options',
|
115 |
),
|
@@ -130,6 +136,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
130 |
'isAvond' => true,
|
131 |
'isSunday' => true,
|
132 |
'isCod' => false,
|
|
|
133 |
'statedAddressOnly' => true,
|
134 |
'isBelgiumOnly' => false,
|
135 |
'countryLimitation' => 'NL',
|
@@ -152,6 +159,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
152 |
'isAvond' => true,
|
153 |
'isSunday' => true,
|
154 |
'isCod' => false,
|
|
|
155 |
'statedAddressOnly' => true,
|
156 |
'isBelgiumOnly' => false,
|
157 |
'countryLimitation' => 'NL',
|
@@ -174,6 +182,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
174 |
'isAvond' => true,
|
175 |
'isSunday' => true,
|
176 |
'isCod' => false,
|
|
|
177 |
'statedAddressOnly' => true,
|
178 |
'countryLimitation' => 'NL',
|
179 |
'group' => 'standard_options',
|
@@ -185,6 +194,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
185 |
'isAvond' => true,
|
186 |
'isSunday' => true,
|
187 |
'isCod' => false,
|
|
|
188 |
'statedAddressOnly' => true,
|
189 |
'countryLimitation' => 'NL',
|
190 |
'group' => 'standard_options',
|
@@ -269,6 +279,17 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
269 |
'countryLimitation' => 'NL',
|
270 |
'group' => 'pakjegemak_options',
|
271 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
'4952' => array(
|
273 |
'value' => '4952',
|
274 |
'label' => 'EU Pack Special Consumer (incl. signature)',
|
@@ -407,6 +428,30 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
407 |
'countryLimitation' => 'BE',
|
408 |
'group' => 'standard_options',
|
409 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
);
|
411 |
|
412 |
/**
|
@@ -415,11 +460,14 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
415 |
protected $_groups = array(
|
416 |
'standard_options' => 'Domestic options',
|
417 |
'pakjegemak_options' => 'Post Office options',
|
|
|
418 |
'eu_options' => 'EU options',
|
419 |
'global_options' => 'Global options',
|
420 |
'pakketautomaat_options' => 'Parcel Dispenser options',
|
421 |
'buspakje_options' => 'Letter Box Parcel options',
|
422 |
'sunday_options' => 'Sunday options',
|
|
|
|
|
423 |
);
|
424 |
|
425 |
/**
|
@@ -433,8 +481,10 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
433 |
*/
|
434 |
public function getOptions($flags = array(), $asFlatArray = false, $checkAvailable = false)
|
435 |
{
|
|
|
436 |
$helper = Mage::helper('postnl');
|
437 |
-
|
|
|
438 |
$domesticCountry = $helper->getDomesticCountry();
|
439 |
$flags['countryLimitation'] = array(
|
440 |
$domesticCountry,
|
@@ -482,6 +532,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
482 |
{
|
483 |
$options = $this->getGroupedOptions();
|
484 |
|
|
|
485 |
$helper = Mage::helper('postnl');
|
486 |
if ($helper->canUseEpsBEOnlyOption()) {
|
487 |
$options['eu_options']['value']['4955'] = array(
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
60 |
'isAvond' => true,
|
61 |
'isSunday' => false,
|
62 |
'isCod' => true,
|
63 |
+
'isSameDay' => true,
|
64 |
'countryLimitation' => 'NL',
|
65 |
'group' => 'standard_options',
|
66 |
),
|
71 |
'isAvond' => true,
|
72 |
'isSunday' => false,
|
73 |
'isCod' => true,
|
74 |
+
'isSameDay' => true,
|
75 |
'countryLimitation' => 'NL',
|
76 |
'group' => 'standard_options',
|
77 |
),
|
82 |
'isAvond' => true,
|
83 |
'isSunday' => false,
|
84 |
'isCod' => true,
|
85 |
+
'isSameDay' => true,
|
86 |
'countryLimitation'=> 'NL',
|
87 |
'group' => 'standard_options',
|
88 |
),
|
93 |
'isAvond' => true,
|
94 |
'isSunday' => false,
|
95 |
'isCod' => true,
|
96 |
+
'isSameDay' => true,
|
97 |
'countryLimitation'=> 'NL',
|
98 |
'group' => 'standard_options',
|
99 |
),
|
104 |
'isAvond' => true,
|
105 |
'isSunday' => true,
|
106 |
'isCod' => false,
|
107 |
+
'isSameDay' => true,
|
108 |
'countryLimitation' => 'NL',
|
109 |
'group' => 'standard_options',
|
110 |
),
|
115 |
'isSunday' => true,
|
116 |
'isExtraCover' => true,
|
117 |
'isCod' => false,
|
118 |
+
'isSameDay' => true,
|
119 |
'countryLimitation'=> 'NL',
|
120 |
'group' => 'standard_options',
|
121 |
),
|
136 |
'isAvond' => true,
|
137 |
'isSunday' => true,
|
138 |
'isCod' => false,
|
139 |
+
'isSameDay' => true,
|
140 |
'statedAddressOnly' => true,
|
141 |
'isBelgiumOnly' => false,
|
142 |
'countryLimitation' => 'NL',
|
159 |
'isAvond' => true,
|
160 |
'isSunday' => true,
|
161 |
'isCod' => false,
|
162 |
+
'isSameDay' => true,
|
163 |
'statedAddressOnly' => true,
|
164 |
'isBelgiumOnly' => false,
|
165 |
'countryLimitation' => 'NL',
|
182 |
'isAvond' => true,
|
183 |
'isSunday' => true,
|
184 |
'isCod' => false,
|
185 |
+
'isSameDay' => true,
|
186 |
'statedAddressOnly' => true,
|
187 |
'countryLimitation' => 'NL',
|
188 |
'group' => 'standard_options',
|
194 |
'isAvond' => true,
|
195 |
'isSunday' => true,
|
196 |
'isCod' => false,
|
197 |
+
'isSameDay' => true,
|
198 |
'statedAddressOnly' => true,
|
199 |
'countryLimitation' => 'NL',
|
200 |
'group' => 'standard_options',
|
279 |
'countryLimitation' => 'NL',
|
280 |
'group' => 'pakjegemak_options',
|
281 |
),
|
282 |
+
'4932' => array(
|
283 |
+
'value' => '4932',
|
284 |
+
'label' => 'Post Office',
|
285 |
+
'isExtraCover' => false,
|
286 |
+
'isSunday' => false,
|
287 |
+
'isPge' => false,
|
288 |
+
'isCod' => false,
|
289 |
+
'isBelgiumOnly' => true,
|
290 |
+
'countryLimitation' => 'NL',
|
291 |
+
'group' => 'pakjegemak_be_options',
|
292 |
+
),
|
293 |
'4952' => array(
|
294 |
'value' => '4952',
|
295 |
'label' => 'EU Pack Special Consumer (incl. signature)',
|
428 |
'countryLimitation' => 'BE',
|
429 |
'group' => 'standard_options',
|
430 |
),
|
431 |
+
'3083' => array(
|
432 |
+
'value' => '3083',
|
433 |
+
'label' => 'Dry & Groceries',
|
434 |
+
'isExtraCover' => false,
|
435 |
+
'isAvond' => true,
|
436 |
+
'isSunday' => true,
|
437 |
+
'isCod' => false,
|
438 |
+
'isSameDay' => true,
|
439 |
+
'statedAddressOnly' => true,
|
440 |
+
'countryLimitation' => 'NL',
|
441 |
+
'group' => 'food_options',
|
442 |
+
),
|
443 |
+
'3084' => array(
|
444 |
+
'value' => '3084',
|
445 |
+
'label' => 'Cooled Products',
|
446 |
+
'isExtraCover' => false,
|
447 |
+
'isAvond' => true,
|
448 |
+
'isSunday' => true,
|
449 |
+
'isCod' => false,
|
450 |
+
'isSameDay' => true,
|
451 |
+
'statedAddressOnly' => true,
|
452 |
+
'countryLimitation' => 'NL',
|
453 |
+
'group' => 'cooled_options',
|
454 |
+
),
|
455 |
);
|
456 |
|
457 |
/**
|
460 |
protected $_groups = array(
|
461 |
'standard_options' => 'Domestic options',
|
462 |
'pakjegemak_options' => 'Post Office options',
|
463 |
+
'pakjegemak_be_options' => 'Post Office Belgium options',
|
464 |
'eu_options' => 'EU options',
|
465 |
'global_options' => 'Global options',
|
466 |
'pakketautomaat_options' => 'Parcel Dispenser options',
|
467 |
'buspakje_options' => 'Letter Box Parcel options',
|
468 |
'sunday_options' => 'Sunday options',
|
469 |
+
'food_options' => 'Food Delivery Options',
|
470 |
+
'cooled_options' => 'Cooled Delivery Options',
|
471 |
);
|
472 |
|
473 |
/**
|
481 |
*/
|
482 |
public function getOptions($flags = array(), $asFlatArray = false, $checkAvailable = false)
|
483 |
{
|
484 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
485 |
$helper = Mage::helper('postnl');
|
486 |
+
$canUseDutchProducts = Mage::helper('postnl/deliveryOptions')->canUseDutchProducts();
|
487 |
+
if (!isset($flags['countryLimitation']) && !$canUseDutchProducts) {
|
488 |
$domesticCountry = $helper->getDomesticCountry();
|
489 |
$flags['countryLimitation'] = array(
|
490 |
$domesticCountry,
|
532 |
{
|
533 |
$options = $this->getGroupedOptions();
|
534 |
|
535 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
536 |
$helper = Mage::helper('postnl');
|
537 |
if ($helper->canUseEpsBEOnlyOption()) {
|
538 |
$options['eu_options']['value']['4955'] = array(
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_Attributes
|
@@ -45,6 +45,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_Attributes
|
|
45 |
*/
|
46 |
public function toOptionArray()
|
47 |
{
|
|
|
48 |
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
49 |
->addFieldToSelect(array('attribute_code', 'frontend_label'))
|
50 |
->addFieldToFilter('frontend_label', array('notnull' => true));
|
@@ -56,6 +57,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_Attributes
|
|
56 |
* @var Mage_Catalog_Model_Entity_Attribute $attribute
|
57 |
*/
|
58 |
foreach ($attributes as $attribute) {
|
|
|
59 |
$label = $attribute->getFrontendLabel();
|
60 |
if (empty($label)) {
|
61 |
continue;
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_Attributes
|
45 |
*/
|
46 |
public function toOptionArray()
|
47 |
{
|
48 |
+
/** @var Mage_Catalog_Model_Resource_Product_Attribute_Collection $attributes */
|
49 |
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
50 |
->addFieldToSelect(array('attribute_code', 'frontend_label'))
|
51 |
->addFieldToFilter('frontend_label', array('notnull' => true));
|
57 |
* @var Mage_Catalog_Model_Entity_Attribute $attribute
|
58 |
*/
|
59 |
foreach ($attributes as $attribute) {
|
60 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
61 |
$label = $attribute->getFrontendLabel();
|
62 |
if (empty($label)) {
|
63 |
continue;
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_BuspakjeProductOptions
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_BuspakjeProductOptions
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_CheckoutExtensions
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_CheckoutExtensions
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_CommentType
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_CommentType
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Model_Core_System_Config_Source_CooledProductOptions
|
40 |
+
extends TIG_PostNL_Model_Core_System_Config_Source_ProductOptions_Abstract
|
41 |
+
{
|
42 |
+
/**postnl_product_option
|
43 |
+
* @var array
|
44 |
+
*/
|
45 |
+
protected $_options = array(
|
46 |
+
array(
|
47 |
+
'value' => '3084',
|
48 |
+
'label' => 'Cooled Products',
|
49 |
+
'isExtraCover' => false,
|
50 |
+
'isAvond' => true,
|
51 |
+
'isCod' => false,
|
52 |
+
'isSameDay' => true,
|
53 |
+
'statedAddressOnly' => true,
|
54 |
+
'countryLimitation' => 'NL',
|
55 |
+
),
|
56 |
+
);
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Gets an array of possible food delivery product options.
|
60 |
+
*
|
61 |
+
* @return array
|
62 |
+
*/
|
63 |
+
public function toOptionArray()
|
64 |
+
{
|
65 |
+
return $this->getOptions(array('isCod' => false));
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
70 |
+
*
|
71 |
+
* @param boolean $flat
|
72 |
+
* @param string|null|false $country
|
73 |
+
*
|
74 |
+
* @return array
|
75 |
+
*/
|
76 |
+
public function getAvailableOptions($flat = false, $country = null)
|
77 |
+
{
|
78 |
+
$flags = array(
|
79 |
+
'isCod' => false,
|
80 |
+
);
|
81 |
+
|
82 |
+
if (!$country) {
|
83 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
84 |
+
$helper = Mage::helper('postnl');
|
85 |
+
$country = $helper->getDomesticCountry();
|
86 |
+
}
|
87 |
+
|
88 |
+
if ($country) {
|
89 |
+
$flags['countryLimitation'] = $country;
|
90 |
+
}
|
91 |
+
|
92 |
+
return $this->getOptions($flags, $flat, true);
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
97 |
+
*
|
98 |
+
* @param boolean $flat
|
99 |
+
*
|
100 |
+
* @return array
|
101 |
+
*/
|
102 |
+
public function getAvailableNlOptions($flat = false)
|
103 |
+
{
|
104 |
+
return $this->getAvailableOptions($flat, 'NL');
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
109 |
+
*
|
110 |
+
* @param boolean $flat
|
111 |
+
*
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
public function getAvailableBeOptions($flat = false)
|
115 |
+
{
|
116 |
+
return $this->getAvailableOptions($flat, 'BE');
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get available avond options.
|
121 |
+
*
|
122 |
+
* @param boolean $flat
|
123 |
+
*
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
+
public function getAvailableAvondOptions($flat = false)
|
127 |
+
{
|
128 |
+
return $this->getOptions(array('isAvond' => true, 'isCod' => false), $flat, true);
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Get available same day delivery options.
|
133 |
+
*
|
134 |
+
* @param boolean $flat
|
135 |
+
*
|
136 |
+
* @return array
|
137 |
+
*/
|
138 |
+
public function getAvailableSameDayOptions($flat = false)
|
139 |
+
{
|
140 |
+
return $this->getOptions(array('isSameDay' => true, 'isCod' => false), $flat, true);
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Get available 'stated address only' options.
|
145 |
+
*
|
146 |
+
* @param boolean $flat
|
147 |
+
*
|
148 |
+
* @return array
|
149 |
+
*/
|
150 |
+
public function getAvailableStatedAddressOnlyOptions($flat = false)
|
151 |
+
{
|
152 |
+
return $this->getOptions(array('statedAddressOnly' => true), $flat, true);
|
153 |
+
}
|
154 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_CutOffTime
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_CutOffTime
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_DebugMode
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_DebugMode
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_Direction
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_Direction
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions
|
@@ -62,6 +62,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions
|
|
62 |
{
|
63 |
$options = parent::getOptions($flags, $asFlatArray, $checkAvailable);
|
64 |
|
|
|
65 |
$helper = Mage::helper('postnl');
|
66 |
if ($helper->canUseEpsBEOnlyOption()) {
|
67 |
if (!$asFlatArray) {
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions
|
62 |
{
|
63 |
$options = parent::getOptions($flags, $asFlatArray, $checkAvailable);
|
64 |
|
65 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
66 |
$helper = Mage::helper('postnl');
|
67 |
if ($helper->canUseEpsBEOnlyOption()) {
|
68 |
if (!$asFlatArray) {
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Model_Core_System_Config_Source_FoodProductOptions
|
40 |
+
extends TIG_PostNL_Model_Core_System_Config_Source_ProductOptions_Abstract
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* @var array
|
44 |
+
*/
|
45 |
+
protected $_options = array(
|
46 |
+
array(
|
47 |
+
'value' => '3083',
|
48 |
+
'label' => 'Dry & Groceries',
|
49 |
+
'isExtraCover' => false,
|
50 |
+
'isAvond' => true,
|
51 |
+
'isCod' => false,
|
52 |
+
'isSameDay' => true,
|
53 |
+
'statedAddressOnly' => true,
|
54 |
+
'countryLimitation' => 'NL',
|
55 |
+
),
|
56 |
+
);
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Gets an array of possible food delivery product options.
|
60 |
+
*
|
61 |
+
* @return array
|
62 |
+
*/
|
63 |
+
public function toOptionArray()
|
64 |
+
{
|
65 |
+
return $this->getOptions(array('isCod' => false));
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
70 |
+
*
|
71 |
+
* @param boolean $flat
|
72 |
+
* @param string|null|false $country
|
73 |
+
*
|
74 |
+
* @return array
|
75 |
+
*/
|
76 |
+
public function getAvailableOptions($flat = false, $country = null)
|
77 |
+
{
|
78 |
+
$flags = array(
|
79 |
+
'isCod' => false,
|
80 |
+
);
|
81 |
+
|
82 |
+
if (!$country) {
|
83 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
84 |
+
$helper = Mage::helper('postnl');
|
85 |
+
$country = $helper->getDomesticCountry();
|
86 |
+
}
|
87 |
+
|
88 |
+
if ($country) {
|
89 |
+
$flags['countryLimitation'] = $country;
|
90 |
+
}
|
91 |
+
|
92 |
+
return $this->getOptions($flags, $flat, true);
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
97 |
+
*
|
98 |
+
* @param boolean $flat
|
99 |
+
*
|
100 |
+
* @return array
|
101 |
+
*/
|
102 |
+
public function getAvailableNlOptions($flat = false)
|
103 |
+
{
|
104 |
+
return $this->getAvailableOptions($flat, 'NL');
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
109 |
+
*
|
110 |
+
* @param boolean $flat
|
111 |
+
*
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
public function getAvailableBeOptions($flat = false)
|
115 |
+
{
|
116 |
+
return $this->getAvailableOptions($flat, 'BE');
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get available avond options.
|
121 |
+
*
|
122 |
+
* @param boolean $flat
|
123 |
+
*
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
+
public function getAvailableAvondOptions($flat = false)
|
127 |
+
{
|
128 |
+
return $this->getOptions(array('isAvond' => true, 'isCod' => false), $flat, true);
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Get available same day delivery options.
|
133 |
+
*
|
134 |
+
* @param boolean $flat
|
135 |
+
*
|
136 |
+
* @return array
|
137 |
+
*/
|
138 |
+
public function getAvailableSameDayOptions($flat = false)
|
139 |
+
{
|
140 |
+
return $this->getOptions(array('isSameDay' => true, 'isCod' => false), $flat, true);
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Get available 'stated address only' options.
|
145 |
+
*
|
146 |
+
* @param boolean $flat
|
147 |
+
*
|
148 |
+
* @return array
|
149 |
+
*/
|
150 |
+
public function getAvailableStatedAddressOnlyOptions($flat = false)
|
151 |
+
{
|
152 |
+
return $this->getOptions(array('statedAddressOnly' => true), $flat, true);
|
153 |
+
}
|
154 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_GlobalProductOptions
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_GlobalProductOptions
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_GlobalpackShipmentType
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_GlobalpackShipmentType
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_HourMinute
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_HourMinute
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_LabelSize
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_LabelSize
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ManualAutomatic
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ManualAutomatic
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_PackingSlipItemFields
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_PackingSlipItemFields
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
@@ -64,4 +64,4 @@ class TIG_PostNL_Model_Core_System_Config_Source_PackingSlipLabel
|
|
64 |
);
|
65 |
return $array;
|
66 |
}
|
67 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
64 |
);
|
65 |
return $array;
|
66 |
}
|
67 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
@@ -44,60 +44,76 @@ class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
|
44 |
*/
|
45 |
protected $_options = array(
|
46 |
array(
|
47 |
-
'value'
|
48 |
-
'label'
|
49 |
-
'isExtraCover'
|
50 |
-
'isPge'
|
51 |
-
'isCod'
|
|
|
52 |
),
|
53 |
array(
|
54 |
-
'value'
|
55 |
-
'label'
|
56 |
-
'isExtraCover'
|
57 |
-
'isPge'
|
58 |
-
'isCod'
|
|
|
59 |
),
|
60 |
array(
|
61 |
-
'value'
|
62 |
-
'label'
|
63 |
-
'isExtraCover'
|
64 |
-
'isPge'
|
65 |
-
'isCod'
|
|
|
66 |
),
|
67 |
array(
|
68 |
-
'value'
|
69 |
-
'label'
|
70 |
-
'isExtraCover'
|
71 |
-
'isPge'
|
72 |
-
'isCod'
|
|
|
73 |
),
|
74 |
array(
|
75 |
-
'value'
|
76 |
-
'label'
|
77 |
-
'isExtraCover'
|
78 |
-
'isPge'
|
79 |
-
'isCod'
|
|
|
80 |
),
|
81 |
array(
|
82 |
-
'value'
|
83 |
-
'label'
|
84 |
-
'isExtraCover'
|
85 |
-
'isPge'
|
86 |
-
'isCod'
|
|
|
87 |
),
|
88 |
array(
|
89 |
-
'value'
|
90 |
-
'label'
|
91 |
-
'isExtraCover'
|
92 |
-
'isPge'
|
93 |
-
'isCod'
|
|
|
94 |
),
|
95 |
array(
|
96 |
-
'value'
|
97 |
-
'label'
|
98 |
-
'isExtraCover'
|
99 |
-
'isPge'
|
100 |
-
'isCod'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
),
|
102 |
);
|
103 |
|
@@ -120,7 +136,20 @@ class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
|
120 |
*/
|
121 |
public function getAvailableOptions($flat = false)
|
122 |
{
|
123 |
-
return $this->getOptions(array('isCod' => false), $flat, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
|
126 |
/**
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
44 |
*/
|
45 |
protected $_options = array(
|
46 |
array(
|
47 |
+
'value' => '3534',
|
48 |
+
'label' => 'Post Office + Extra Cover',
|
49 |
+
'isExtraCover' => true,
|
50 |
+
'isPge' => false,
|
51 |
+
'isCod' => false,
|
52 |
+
'isBelgiumOnly' => false,
|
53 |
),
|
54 |
array(
|
55 |
+
'value' => '3544',
|
56 |
+
'label' => 'Post Office + Extra Cover + Notification',
|
57 |
+
'isExtraCover' => true,
|
58 |
+
'isPge' => true,
|
59 |
+
'isCod' => false,
|
60 |
+
'isBelgiumOnly' => false,
|
61 |
),
|
62 |
array(
|
63 |
+
'value' => '3533',
|
64 |
+
'label' => 'Post Office + Signature on Delivery',
|
65 |
+
'isExtraCover' => false,
|
66 |
+
'isPge' => false,
|
67 |
+
'isCod' => false,
|
68 |
+
'isBelgiumOnly' => false,
|
69 |
),
|
70 |
array(
|
71 |
+
'value' => '3543',
|
72 |
+
'label' => 'Post Office + Signature on Delivery + Notification',
|
73 |
+
'isExtraCover' => false,
|
74 |
+
'isPge' => true,
|
75 |
+
'isCod' => false,
|
76 |
+
'isBelgiumOnly' => false,
|
77 |
),
|
78 |
array(
|
79 |
+
'value' => '3535',
|
80 |
+
'label' => 'Post Office + COD',
|
81 |
+
'isExtraCover' => false,
|
82 |
+
'isPge' => false,
|
83 |
+
'isCod' => true,
|
84 |
+
'isBelgiumOnly' => false,
|
85 |
),
|
86 |
array(
|
87 |
+
'value' => '3545',
|
88 |
+
'label' => 'Post Office + COD + Notification',
|
89 |
+
'isExtraCover' => false,
|
90 |
+
'isPge' => true,
|
91 |
+
'isCod' => true,
|
92 |
+
'isBelgiumOnly' => false,
|
93 |
),
|
94 |
array(
|
95 |
+
'value' => '3536',
|
96 |
+
'label' => 'Post Office + COD + Extra Cover',
|
97 |
+
'isExtraCover' => false,
|
98 |
+
'isPge' => false,
|
99 |
+
'isCod' => true,
|
100 |
+
'isBelgiumOnly' => false,
|
101 |
),
|
102 |
array(
|
103 |
+
'value' => '3546',
|
104 |
+
'label' => 'Post Office + COD + Extra Cover + Notification',
|
105 |
+
'isExtraCover' => false,
|
106 |
+
'isPge' => true,
|
107 |
+
'isCod' => true,
|
108 |
+
'isBelgiumOnly' => false,
|
109 |
+
),
|
110 |
+
array(
|
111 |
+
'value' => '4932',
|
112 |
+
'label' => 'Post Office (Belgium)',
|
113 |
+
'isExtraCover' => false,
|
114 |
+
'isPge' => false,
|
115 |
+
'isCod' => false,
|
116 |
+
'isBelgiumOnly' => true,
|
117 |
),
|
118 |
);
|
119 |
|
136 |
*/
|
137 |
public function getAvailableOptions($flat = false)
|
138 |
{
|
139 |
+
return $this->getOptions(array('isCod' => false, 'isBelgiumOnly' => false), $flat, true);
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Get a list of available options for Belgium. This is a filtered/modified version of the array supplied by
|
144 |
+
* toOptionArray();
|
145 |
+
*
|
146 |
+
* @param boolean $flat
|
147 |
+
*
|
148 |
+
* @return array
|
149 |
+
*/
|
150 |
+
public function getAvailableBeOptions($flat = false)
|
151 |
+
{
|
152 |
+
return $this->getOptions(array('isCod' => false, 'isBelgiumOnly' => true), $flat, true);
|
153 |
}
|
154 |
|
155 |
/**
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_PakketautomaatProductOptions
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_PakketautomaatProductOptions
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_Core_System_Config_Source_ProductOptions_Abstract
|
@@ -41,7 +41,8 @@ abstract class TIG_PostNL_Model_Core_System_Config_Source_ProductOptions_Abstrac
|
|
41 |
/**
|
42 |
* Xpath to supported options configuration setting
|
43 |
*/
|
44 |
-
const XPATH_SUPPORTED_PRODUCT_OPTIONS
|
|
|
45 |
|
46 |
/**
|
47 |
* @var array
|
@@ -65,6 +66,7 @@ abstract class TIG_PostNL_Model_Core_System_Config_Source_ProductOptions_Abstrac
|
|
65 |
public function getOptions($flags = array(), $asFlatArray = false, $checkAvailable = false)
|
66 |
{
|
67 |
$options = $this->_options;
|
|
|
68 |
if (!empty($flags)) {
|
69 |
foreach ($options as $key => $option) {
|
70 |
if (!$this->_optionMatchesFlags($option, $flags)) {
|
@@ -231,6 +233,7 @@ abstract class TIG_PostNL_Model_Core_System_Config_Source_ProductOptions_Abstrac
|
|
231 |
*/
|
232 |
protected function _filterAvailable(&$options)
|
233 |
{
|
|
|
234 |
$helper = Mage::helper('postnl');
|
235 |
$canUseEpsBEOnly = $helper->canUseEpsBEOnlyOption();
|
236 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_Core_System_Config_Source_ProductOptions_Abstract
|
41 |
/**
|
42 |
* Xpath to supported options configuration setting
|
43 |
*/
|
44 |
+
const XPATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/grid/supported_product_options';
|
45 |
+
const XPATH_USE_DUTCH_PRODUCTS = 'postnl/cif_labels_and_confirming/use_dutch_products';
|
46 |
|
47 |
/**
|
48 |
* @var array
|
66 |
public function getOptions($flags = array(), $asFlatArray = false, $checkAvailable = false)
|
67 |
{
|
68 |
$options = $this->_options;
|
69 |
+
|
70 |
if (!empty($flags)) {
|
71 |
foreach ($options as $key => $option) {
|
72 |
if (!$this->_optionMatchesFlags($option, $flags)) {
|
233 |
*/
|
234 |
protected function _filterAvailable(&$options)
|
235 |
{
|
236 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
237 |
$helper = Mage::helper('postnl');
|
238 |
$canUseEpsBEOnly = $helper->canUseEpsBEOnlyOption();
|
239 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ReferenceType
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ReferenceType
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_SenderCountry
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_SenderCountry
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ShippingDays
|
@@ -45,6 +45,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_ShippingDays
|
|
45 |
*/
|
46 |
public function toOptionArray()
|
47 |
{
|
|
|
48 |
$helper = Mage::helper('postnl/deliveryOptions');
|
49 |
$labelSizes = array(
|
50 |
array(
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ShippingDays
|
45 |
*/
|
46 |
public function toOptionArray()
|
47 |
{
|
48 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
49 |
$helper = Mage::helper('postnl/deliveryOptions');
|
50 |
$labelSizes = array(
|
51 |
array(
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ShippingDuration
|
@@ -48,6 +48,10 @@ class TIG_PostNL_Model_Core_System_Config_Source_ShippingDuration
|
|
48 |
$helper = Mage::helper('postnl');
|
49 |
|
50 |
$options = array(
|
|
|
|
|
|
|
|
|
51 |
array(
|
52 |
'value' => 1,
|
53 |
'label' => '1 ' . $helper->__('day'),
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ShippingDuration
|
48 |
$helper = Mage::helper('postnl');
|
49 |
|
50 |
$options = array(
|
51 |
+
array(
|
52 |
+
'value' => 0,
|
53 |
+
'label' => '0 ' . $helper->__('days'),
|
54 |
+
),
|
55 |
array(
|
56 |
'value' => 1,
|
57 |
'label' => '1 ' . $helper->__('day'),
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ShippingDurationDays
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ShippingDurationDays
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ShippingMethods
|
@@ -47,14 +47,15 @@ class TIG_PostNL_Model_Core_System_Config_Source_ShippingMethods
|
|
47 |
*
|
48 |
* @return array
|
49 |
*/
|
50 |
-
public function toOptionArray(
|
|
|
51 |
{
|
52 |
$methods = array();
|
53 |
|
54 |
-
/**
|
55 |
-
|
56 |
-
|
57 |
-
$
|
58 |
foreach ($carriers as $carrierCode => $carrierModel) {
|
59 |
if ($isActiveOnlyFlag && !$carrierModel->isActive()) {
|
60 |
continue;
|
@@ -66,7 +67,9 @@ class TIG_PostNL_Model_Core_System_Config_Source_ShippingMethods
|
|
66 |
continue;
|
67 |
}
|
68 |
} catch (Exception $e) {
|
69 |
-
|
|
|
|
|
70 |
continue;
|
71 |
}
|
72 |
|
@@ -98,10 +101,10 @@ class TIG_PostNL_Model_Core_System_Config_Source_ShippingMethods
|
|
98 |
{
|
99 |
$methods = array();
|
100 |
|
101 |
-
/**
|
102 |
-
|
103 |
-
|
104 |
-
$
|
105 |
foreach ($carriers as $carrierCode => $carrierModel) {
|
106 |
if ($isActiveOnlyFlag && !$carrierModel->isActive()) {
|
107 |
continue;
|
@@ -119,4 +122,4 @@ class TIG_PostNL_Model_Core_System_Config_Source_ShippingMethods
|
|
119 |
|
120 |
return $methods;
|
121 |
}
|
122 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_ShippingMethods
|
47 |
*
|
48 |
* @return array
|
49 |
*/
|
50 |
+
public function toOptionArray(/** @noinspection PhpUnusedParameterInspection */
|
51 |
+
$isMultiSelect = false, $isActiveOnlyFlag = false)
|
52 |
{
|
53 |
$methods = array();
|
54 |
|
55 |
+
/** @var Mage_Shipping_Model_Config $config */
|
56 |
+
$config = Mage::getSingleton('shipping/config');
|
57 |
+
$carriers = $config->getAllCarriers();
|
58 |
+
/** @var Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Carrier_Interface $carrierModel */
|
59 |
foreach ($carriers as $carrierCode => $carrierModel) {
|
60 |
if ($isActiveOnlyFlag && !$carrierModel->isActive()) {
|
61 |
continue;
|
67 |
continue;
|
68 |
}
|
69 |
} catch (Exception $e) {
|
70 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
71 |
+
$helper = Mage::helper('postnl');
|
72 |
+
$helper->logException($e);
|
73 |
continue;
|
74 |
}
|
75 |
|
101 |
{
|
102 |
$methods = array();
|
103 |
|
104 |
+
/** @var Mage_Shipping_Model_Config $config */
|
105 |
+
$config = Mage::getSingleton('shipping/config');
|
106 |
+
$carriers = $config->getAllCarriers();
|
107 |
+
/** @var Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Carrier_Interface $carrierModel */
|
108 |
foreach ($carriers as $carrierCode => $carrierModel) {
|
109 |
if ($isActiveOnlyFlag && !$carrierModel->isActive()) {
|
110 |
continue;
|
122 |
|
123 |
return $methods;
|
124 |
}
|
125 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
@@ -49,6 +49,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
49 |
'isExtraCover' => false,
|
50 |
'isAvond' => false,
|
51 |
'isCod' => false,
|
|
|
52 |
'statedAddressOnly' => false,
|
53 |
'countryLimitation' => 'NL',
|
54 |
),
|
@@ -58,6 +59,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
58 |
'isExtraCover' => true,
|
59 |
'isAvond' => true,
|
60 |
'isCod' => false,
|
|
|
61 |
'statedAddressOnly' => false,
|
62 |
'countryLimitation' => 'NL',
|
63 |
),
|
@@ -67,6 +69,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
67 |
'isExtraCover' => true,
|
68 |
'isAvond' => true,
|
69 |
'isCod' => false,
|
|
|
70 |
'statedAddressOnly' => false,
|
71 |
'countryLimitation' => 'NL',
|
72 |
),
|
@@ -76,6 +79,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
76 |
'isExtraCover' => false,
|
77 |
'isAvond' => false,
|
78 |
'isCod' => false,
|
|
|
79 |
'statedAddressOnly' => false,
|
80 |
'countryLimitation' => 'NL',
|
81 |
),
|
@@ -85,6 +89,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
85 |
'isExtraCover' => false,
|
86 |
'isAvond' => true,
|
87 |
'isCod' => false,
|
|
|
88 |
'statedAddressOnly' => true,
|
89 |
'countryLimitation' => 'NL',
|
90 |
),
|
@@ -94,6 +99,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
94 |
'isExtraCover' => false,
|
95 |
'isAvond' => false,
|
96 |
'isCod' => false,
|
|
|
97 |
'statedAddressOnly' => false,
|
98 |
'countryLimitation' => 'NL',
|
99 |
),
|
@@ -103,6 +109,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
103 |
'isExtraCover' => false,
|
104 |
'isAvond' => true,
|
105 |
'isCod' => false,
|
|
|
106 |
'statedAddressOnly' => true,
|
107 |
'countryLimitation' => 'NL',
|
108 |
),
|
@@ -112,6 +119,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
112 |
'isExtraCover' => false,
|
113 |
'isAvond' => false,
|
114 |
'isCod' => false,
|
|
|
115 |
'statedAddressOnly' => false,
|
116 |
'countryLimitation' => 'NL',
|
117 |
),
|
@@ -121,6 +129,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
121 |
'isExtraCover' => false,
|
122 |
'isAvond' => true,
|
123 |
'isCod' => false,
|
|
|
124 |
'statedAddressOnly' => true,
|
125 |
'countryLimitation' => 'NL',
|
126 |
),
|
@@ -130,6 +139,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
130 |
'isExtraCover' => false,
|
131 |
'isAvond' => true,
|
132 |
'isCod' => false,
|
|
|
133 |
'statedAddressOnly' => true,
|
134 |
'countryLimitation' => 'NL',
|
135 |
),
|
@@ -139,6 +149,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
139 |
'isExtraCover' => false,
|
140 |
'isAvond' => true,
|
141 |
'isCod' => true,
|
|
|
142 |
'statedAddressOnly' => false,
|
143 |
'countryLimitation' => 'NL',
|
144 |
),
|
@@ -148,6 +159,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
148 |
'isExtraCover' => true,
|
149 |
'isAvond' => true,
|
150 |
'isCod' => true,
|
|
|
151 |
'statedAddressOnly' => false,
|
152 |
'countryLimitation' => 'NL',
|
153 |
),
|
@@ -157,6 +169,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
157 |
'isExtraCover' => false,
|
158 |
'isAvond' => true,
|
159 |
'isCod' => true,
|
|
|
160 |
'statedAddressOnly' => false,
|
161 |
'countryLimitation' => 'NL',
|
162 |
),
|
@@ -166,6 +179,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
166 |
'isExtraCover' => true,
|
167 |
'isAvond' => true,
|
168 |
'isCod' => true,
|
|
|
169 |
'statedAddressOnly' => false,
|
170 |
'countryLimitation' => 'NL',
|
171 |
),
|
@@ -175,6 +189,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
175 |
'isExtraCover' => false,
|
176 |
'isAvond' => false,
|
177 |
'isCod' => false,
|
|
|
178 |
'statedAddressOnly' => true,
|
179 |
'countryLimitation' => 'BE',
|
180 |
),
|
@@ -185,6 +200,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
185 |
'isAvond' => false,
|
186 |
'isCod' => false,
|
187 |
'statedAddressOnly' => false,
|
|
|
188 |
'countryLimitation' => 'BE',
|
189 |
),
|
190 |
array(
|
@@ -193,6 +209,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
193 |
'isExtraCover' => false,
|
194 |
'isAvond' => false,
|
195 |
'isCod' => false,
|
|
|
196 |
'statedAddressOnly' => true,
|
197 |
'countryLimitation' => 'BE',
|
198 |
),
|
@@ -202,6 +219,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
202 |
'isExtraCover' => false,
|
203 |
'isAvond' => false,
|
204 |
'isCod' => false,
|
|
|
205 |
'statedAddressOnly' => false,
|
206 |
'countryLimitation' => 'BE',
|
207 |
),
|
@@ -211,6 +229,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
211 |
'isExtraCover' => false,
|
212 |
'isAvond' => false,
|
213 |
'isCod' => true,
|
|
|
214 |
'statedAddressOnly' => false,
|
215 |
'countryLimitation' => 'BE',
|
216 |
),
|
@@ -220,6 +239,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
220 |
'isExtraCover' => true,
|
221 |
'isAvond' => false,
|
222 |
'isCod' => false,
|
|
|
223 |
'statedAddressOnly' => true,
|
224 |
'countryLimitation' => 'BE',
|
225 |
'extraCover' => 500,
|
@@ -230,6 +250,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
230 |
'isExtraCover' => true,
|
231 |
'isAvond' => false,
|
232 |
'isCod' => true,
|
|
|
233 |
'statedAddressOnly' => false,
|
234 |
'countryLimitation' => 'BE',
|
235 |
),
|
@@ -284,7 +305,9 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
284 |
);
|
285 |
|
286 |
if (!$country) {
|
287 |
-
|
|
|
|
|
288 |
}
|
289 |
|
290 |
if ($country) {
|
@@ -294,6 +317,16 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
294 |
return $this->getOptions($flags, $flat, true);
|
295 |
}
|
296 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
/**
|
298 |
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
299 |
*
|
@@ -353,7 +386,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
353 |
*/
|
354 |
public function getAvailableNlCodOptions($flat = false)
|
355 |
{
|
356 |
-
return $this->getOptions(array('isCod' => true, '
|
357 |
}
|
358 |
|
359 |
/**
|
@@ -392,6 +425,30 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
392 |
return $this->getOptions(array('isAvond' => true, 'isCod' => true), $flat, true);
|
393 |
}
|
394 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
/**
|
396 |
* Get available 'stated address only' options.
|
397 |
*
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
49 |
'isExtraCover' => false,
|
50 |
'isAvond' => false,
|
51 |
'isCod' => false,
|
52 |
+
'isSameDay' => false,
|
53 |
'statedAddressOnly' => false,
|
54 |
'countryLimitation' => 'NL',
|
55 |
),
|
59 |
'isExtraCover' => true,
|
60 |
'isAvond' => true,
|
61 |
'isCod' => false,
|
62 |
+
'isSameDay' => true,
|
63 |
'statedAddressOnly' => false,
|
64 |
'countryLimitation' => 'NL',
|
65 |
),
|
69 |
'isExtraCover' => true,
|
70 |
'isAvond' => true,
|
71 |
'isCod' => false,
|
72 |
+
'isSameDay' => true,
|
73 |
'statedAddressOnly' => false,
|
74 |
'countryLimitation' => 'NL',
|
75 |
),
|
79 |
'isExtraCover' => false,
|
80 |
'isAvond' => false,
|
81 |
'isCod' => false,
|
82 |
+
'isSameDay' => false,
|
83 |
'statedAddressOnly' => false,
|
84 |
'countryLimitation' => 'NL',
|
85 |
),
|
89 |
'isExtraCover' => false,
|
90 |
'isAvond' => true,
|
91 |
'isCod' => false,
|
92 |
+
'isSameDay' => true,
|
93 |
'statedAddressOnly' => true,
|
94 |
'countryLimitation' => 'NL',
|
95 |
),
|
99 |
'isExtraCover' => false,
|
100 |
'isAvond' => false,
|
101 |
'isCod' => false,
|
102 |
+
'isSameDay' => false,
|
103 |
'statedAddressOnly' => false,
|
104 |
'countryLimitation' => 'NL',
|
105 |
),
|
109 |
'isExtraCover' => false,
|
110 |
'isAvond' => true,
|
111 |
'isCod' => false,
|
112 |
+
'isSameDay' => true,
|
113 |
'statedAddressOnly' => true,
|
114 |
'countryLimitation' => 'NL',
|
115 |
),
|
119 |
'isExtraCover' => false,
|
120 |
'isAvond' => false,
|
121 |
'isCod' => false,
|
122 |
+
'isSameDay' => false,
|
123 |
'statedAddressOnly' => false,
|
124 |
'countryLimitation' => 'NL',
|
125 |
),
|
129 |
'isExtraCover' => false,
|
130 |
'isAvond' => true,
|
131 |
'isCod' => false,
|
132 |
+
'isSameDay' => true,
|
133 |
'statedAddressOnly' => true,
|
134 |
'countryLimitation' => 'NL',
|
135 |
),
|
139 |
'isExtraCover' => false,
|
140 |
'isAvond' => true,
|
141 |
'isCod' => false,
|
142 |
+
'isSameDay' => true,
|
143 |
'statedAddressOnly' => true,
|
144 |
'countryLimitation' => 'NL',
|
145 |
),
|
149 |
'isExtraCover' => false,
|
150 |
'isAvond' => true,
|
151 |
'isCod' => true,
|
152 |
+
'isSameDay' => true,
|
153 |
'statedAddressOnly' => false,
|
154 |
'countryLimitation' => 'NL',
|
155 |
),
|
159 |
'isExtraCover' => true,
|
160 |
'isAvond' => true,
|
161 |
'isCod' => true,
|
162 |
+
'isSameDay' => true,
|
163 |
'statedAddressOnly' => false,
|
164 |
'countryLimitation' => 'NL',
|
165 |
),
|
169 |
'isExtraCover' => false,
|
170 |
'isAvond' => true,
|
171 |
'isCod' => true,
|
172 |
+
'isSameDay' => true,
|
173 |
'statedAddressOnly' => false,
|
174 |
'countryLimitation' => 'NL',
|
175 |
),
|
179 |
'isExtraCover' => true,
|
180 |
'isAvond' => true,
|
181 |
'isCod' => true,
|
182 |
+
'isSameDay' => true,
|
183 |
'statedAddressOnly' => false,
|
184 |
'countryLimitation' => 'NL',
|
185 |
),
|
189 |
'isExtraCover' => false,
|
190 |
'isAvond' => false,
|
191 |
'isCod' => false,
|
192 |
+
'isSameDay' => false,
|
193 |
'statedAddressOnly' => true,
|
194 |
'countryLimitation' => 'BE',
|
195 |
),
|
200 |
'isAvond' => false,
|
201 |
'isCod' => false,
|
202 |
'statedAddressOnly' => false,
|
203 |
+
'isSameDay' => false,
|
204 |
'countryLimitation' => 'BE',
|
205 |
),
|
206 |
array(
|
209 |
'isExtraCover' => false,
|
210 |
'isAvond' => false,
|
211 |
'isCod' => false,
|
212 |
+
'isSameDay' => false,
|
213 |
'statedAddressOnly' => true,
|
214 |
'countryLimitation' => 'BE',
|
215 |
),
|
219 |
'isExtraCover' => false,
|
220 |
'isAvond' => false,
|
221 |
'isCod' => false,
|
222 |
+
'isSameDay' => false,
|
223 |
'statedAddressOnly' => false,
|
224 |
'countryLimitation' => 'BE',
|
225 |
),
|
229 |
'isExtraCover' => false,
|
230 |
'isAvond' => false,
|
231 |
'isCod' => true,
|
232 |
+
'isSameDay' => false,
|
233 |
'statedAddressOnly' => false,
|
234 |
'countryLimitation' => 'BE',
|
235 |
),
|
239 |
'isExtraCover' => true,
|
240 |
'isAvond' => false,
|
241 |
'isCod' => false,
|
242 |
+
'isSameDay' => false,
|
243 |
'statedAddressOnly' => true,
|
244 |
'countryLimitation' => 'BE',
|
245 |
'extraCover' => 500,
|
250 |
'isExtraCover' => true,
|
251 |
'isAvond' => false,
|
252 |
'isCod' => true,
|
253 |
+
'isSameDay' => false,
|
254 |
'statedAddressOnly' => false,
|
255 |
'countryLimitation' => 'BE',
|
256 |
),
|
305 |
);
|
306 |
|
307 |
if (!$country) {
|
308 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
309 |
+
$helper = Mage::helper('postnl');
|
310 |
+
$country = $helper->getDomesticCountry();
|
311 |
}
|
312 |
|
313 |
if ($country) {
|
317 |
return $this->getOptions($flags, $flat, true);
|
318 |
}
|
319 |
|
320 |
+
/**
|
321 |
+
* Get a list of available options. This is specific for the Netherlands only
|
322 |
+
*
|
323 |
+
* @return array
|
324 |
+
*/
|
325 |
+
public function getAvailableOptionsForTheNetherlands()
|
326 |
+
{
|
327 |
+
return $this->getAvailableOptions(false, 'NL');
|
328 |
+
}
|
329 |
+
|
330 |
/**
|
331 |
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
332 |
*
|
386 |
*/
|
387 |
public function getAvailableNlCodOptions($flat = false)
|
388 |
{
|
389 |
+
return $this->getOptions(array('isCod' => true, 'countryLimitation' => 'NL'), $flat, true);
|
390 |
}
|
391 |
|
392 |
/**
|
425 |
return $this->getOptions(array('isAvond' => true, 'isCod' => true), $flat, true);
|
426 |
}
|
427 |
|
428 |
+
/**
|
429 |
+
* Get available same day delivery options.
|
430 |
+
*
|
431 |
+
* @param boolean $flat
|
432 |
+
*
|
433 |
+
* @return array
|
434 |
+
*/
|
435 |
+
public function getAvailableSameDayOptions($flat = false)
|
436 |
+
{
|
437 |
+
return $this->getOptions(array('isSameDay' => true, 'isCod' => false), $flat, true);
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* Get available same day delivery COD options.
|
442 |
+
*
|
443 |
+
* @param boolean $flat
|
444 |
+
*
|
445 |
+
* @return array
|
446 |
+
*/
|
447 |
+
public function getAvailableSameDayCodOptions($flat = false)
|
448 |
+
{
|
449 |
+
return $this->getOptions(array('isSameDay' => true, 'isCod' => true), $flat, true);
|
450 |
+
}
|
451 |
+
|
452 |
/**
|
453 |
* Get available 'stated address only' options.
|
454 |
*
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_StaticBlocks
|
@@ -114,6 +114,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StaticBlocks
|
|
114 |
|
115 |
$blocksCollection->addStoreFilter($store);
|
116 |
} elseif ($request->getParam('website')) {
|
|
|
117 |
$website = Mage::getModel('core/website')->load($request->getParam('website'));
|
118 |
$stores = $website->getStoreIds();
|
119 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_StaticBlocks
|
114 |
|
115 |
$blocksCollection->addStoreFilter($store);
|
116 |
} elseif ($request->getParam('website')) {
|
117 |
+
/** @var Mage_Core_Model_Website $website */
|
118 |
$website = Mage::getModel('core/website')->load($request->getParam('website'));
|
119 |
$stores = $website->getStoreIds();
|
120 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_StreetField
|
@@ -54,6 +54,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StreetField
|
|
54 |
return $this->_options;
|
55 |
}
|
56 |
|
|
|
57 |
$helper = Mage::helper('postnl/addressValidation');
|
58 |
$lineCount = $helper->getAddressLineCount();
|
59 |
|
@@ -71,4 +72,4 @@ class TIG_PostNL_Model_Core_System_Config_Source_StreetField
|
|
71 |
$this->_options = $array;
|
72 |
return $array;
|
73 |
}
|
74 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_StreetField
|
54 |
return $this->_options;
|
55 |
}
|
56 |
|
57 |
+
/** @var TIG_PostNL_Helper_AddressValidation $helper */
|
58 |
$helper = Mage::helper('postnl/addressValidation');
|
59 |
$lineCount = $helper->getAddressLineCount();
|
60 |
|
72 |
$this->_options = $array;
|
73 |
return $array;
|
74 |
}
|
75 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
@@ -57,4 +57,4 @@ class TIG_PostNL_Model_Core_System_Config_Source_StreetFieldWithDefault extends
|
|
57 |
|
58 |
return $options;
|
59 |
}
|
60 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
57 |
|
58 |
return $options;
|
59 |
}
|
60 |
+
}
|
@@ -53,7 +53,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_SundayProductOptions
|
|
53 |
),
|
54 |
array(
|
55 |
'value' => '3089',
|
56 |
-
'label' => 'Signature on delivery +
|
57 |
'isExtraCover' => false,
|
58 |
'isSunday' => true,
|
59 |
'statedAddressOnly' => true,
|
53 |
),
|
54 |
array(
|
55 |
'value' => '3089',
|
56 |
+
'label' => 'Signature on delivery + Delivery to stated address only',
|
57 |
'isExtraCover' => false,
|
58 |
'isSunday' => true,
|
59 |
'statedAddressOnly' => true,
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_WeightUnit
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Core_System_Config_Source_WeightUnit
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_DeliveryOptions_Cif setStoreId(int $value)
|
@@ -50,16 +50,19 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
50 |
const DOMESTIC_DELIVERY_OPTION = 'Daytime';
|
51 |
const EVENING_DELIVERY_OPTION = 'Evening';
|
52 |
const SUNDAY_DELIVERY_OPTION = 'Sunday';
|
|
|
53 |
|
54 |
/**
|
55 |
* Config options used by the getDeliveryDate service.
|
56 |
*/
|
57 |
-
const XPATH_SHIPPING_DURATION
|
58 |
-
const XPATH_CUTOFF_TIME
|
59 |
-
const XPATH_ALLOW_SUNDAY_SORTING
|
60 |
-
const
|
61 |
-
const
|
62 |
-
const
|
|
|
|
|
63 |
|
64 |
/**
|
65 |
* Check if the module is set to test mode
|
@@ -72,7 +75,9 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
72 |
*/
|
73 |
public function isTestMode($storeId = false)
|
74 |
{
|
75 |
-
|
|
|
|
|
76 |
|
77 |
return $testMode;
|
78 |
}
|
@@ -97,9 +102,11 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
97 |
);
|
98 |
}
|
99 |
|
100 |
-
|
|
|
|
|
101 |
|
102 |
-
$date = new DateTime('now',
|
103 |
$date->setTimezone(new DateTimeZone('Europe/Berlin'));
|
104 |
|
105 |
/**
|
@@ -118,14 +125,14 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
118 |
)
|
119 |
);
|
120 |
|
121 |
-
$options = $this->_getDeliveryDateOptionsArray();
|
122 |
|
123 |
$soapParams = array(
|
124 |
'GetDeliveryDate' => array(
|
125 |
'PostalCode' => $postcode,
|
126 |
'ShippingDate' => $date->format('d-m-Y H:i:s'),
|
127 |
'ShippingDuration' => $shippingDuration,
|
128 |
-
'AllowSundaySorting' => $this->_getSundaySortingAllowed(),
|
129 |
'CutOffTimes' => $CutOffTimes,
|
130 |
'Options' => $options,
|
131 |
'CountryCode' => $country,
|
@@ -160,7 +167,7 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
160 |
*
|
161 |
* @param array $data
|
162 |
*
|
163 |
-
* @return StdClass[]
|
164 |
*
|
165 |
* @throws TIG_PostNL_Exception
|
166 |
*/
|
@@ -176,16 +183,25 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
176 |
$startDate = $data['deliveryDate'];
|
177 |
|
178 |
/**
|
179 |
-
* To calculate the end date we need to number of days we want to display
|
180 |
*/
|
181 |
$storeId = Mage::app()->getStore()->getId();
|
182 |
-
|
183 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
$endDate = new DateTime($startDate, new DateTimeZone('UTC'));
|
186 |
$endDate->add(new DateInterval("P{$maximumNumberOfDeliveryDays}D"));
|
187 |
|
188 |
-
$options = $this->_getDeliveryTimeframesOptionsArray();
|
189 |
|
190 |
$soapParams = array(
|
191 |
'Timeframe' => array(
|
@@ -194,7 +210,7 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
194 |
'CountryCode' => $data['country'],
|
195 |
'StartDate' => $startDate,
|
196 |
'EndDate' => $endDate->format('d-m-Y'),
|
197 |
-
'SundaySorting' => $this->_getSundaySortingAllowed(),
|
198 |
'Options' => $options
|
199 |
),
|
200 |
'Message' => $this->_getMessage('')
|
@@ -209,11 +225,16 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
209 |
$soapParams
|
210 |
);
|
211 |
|
212 |
-
if (
|
213 |
-
|
214 |
-
|
|
|
|
|
215 |
throw new TIG_PostNL_Exception(
|
216 |
-
Mage::helper('postnl')->__(
|
|
|
|
|
|
|
217 |
'POSTNL-0122'
|
218 |
);
|
219 |
}
|
@@ -339,13 +360,19 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
339 |
/**
|
340 |
* Checks whether sunday sorting is allowed for this storeview.
|
341 |
*
|
|
|
|
|
342 |
* @return string
|
343 |
*/
|
344 |
-
protected function _getSundaySortingAllowed()
|
345 |
{
|
346 |
$storeId = $this->getStoreId();
|
347 |
|
348 |
$allowSundaySorting = Mage::getStoreConfigFlag(self::XPATH_ALLOW_SUNDAY_SORTING, $storeId);
|
|
|
|
|
|
|
|
|
349 |
if ($allowSundaySorting === true) {
|
350 |
return 'true';
|
351 |
}
|
@@ -392,7 +419,9 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
392 |
if (isset($data['deliveryDate'])) {
|
393 |
$location['DeliveryDate'] = $data['deliveryDate'];
|
394 |
} else {
|
395 |
-
|
|
|
|
|
396 |
$location['DeliveryDate'] = date('d-m-Y', $tomorrow);
|
397 |
}
|
398 |
|
@@ -410,6 +439,13 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
410 |
$location['Postalcode'] = $data['postcode'];
|
411 |
}
|
412 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
/**
|
414 |
* Add coordinates if both a latitude and longitude are available.
|
415 |
*/
|
@@ -449,7 +485,7 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
449 |
/**
|
450 |
* Add flag to identify if Sunday Sorting is allowed
|
451 |
*/
|
452 |
-
$location['AllowSundaySorting'] = $this->_getSundaySortingAllowed();
|
453 |
|
454 |
return $location;
|
455 |
}
|
@@ -463,6 +499,7 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
463 |
{
|
464 |
$deliveryOptions = array();
|
465 |
|
|
|
466 |
$helper = Mage::helper('postnl/deliveryOptions');
|
467 |
if ($helper->canUsePakjeGemak()) {
|
468 |
$deliveryOptions[] = self::PAKJEGEMAK_DELIVERY_OPTION;
|
@@ -483,22 +520,41 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
483 |
* Builds array of time frame options, to be sent in the GetTimeframes request.
|
484 |
* These options determine which delivery timeframes should be requested.
|
485 |
*
|
|
|
|
|
486 |
* @return array
|
487 |
*/
|
488 |
-
protected function _getDeliveryTimeframesOptionsArray()
|
489 |
{
|
490 |
$storeId = $this->getStoreId();
|
491 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
$options = array(self::DOMESTIC_DELIVERY_OPTION);
|
493 |
|
494 |
-
$
|
|
|
|
|
495 |
|
496 |
-
if ($helper->canUseEveningTimeframes()) {
|
497 |
$options[] = self::EVENING_DELIVERY_OPTION;
|
498 |
}
|
499 |
|
500 |
$sundayDelivery = Mage::getStoreConfig($helper::XPATH_ENABLE_SUNDAY_DELIVERY, $storeId);
|
501 |
-
if ($sundayDelivery) {
|
502 |
$options[] = self::SUNDAY_DELIVERY_OPTION;
|
503 |
}
|
504 |
|
@@ -511,23 +567,37 @@ class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
|
511 |
* important to prevent certain dates from being unavailable. The order used in this method is (depending on the
|
512 |
* extension's config): sunday > daytime > evening.
|
513 |
*
|
|
|
|
|
|
|
514 |
* @return array
|
515 |
*/
|
516 |
-
protected function _getDeliveryDateOptionsArray()
|
517 |
{
|
518 |
$storeId = $this->getStoreId();
|
519 |
|
|
|
520 |
$helper = Mage::helper('postnl/deliveryOptions');
|
521 |
|
522 |
$options = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
$sundayDelivery = Mage::getStoreConfig($helper::XPATH_ENABLE_SUNDAY_DELIVERY, $storeId);
|
524 |
-
if ($sundayDelivery) {
|
525 |
$options[] = self::SUNDAY_DELIVERY_OPTION;
|
526 |
}
|
527 |
|
528 |
$options[] = self::DOMESTIC_DELIVERY_OPTION;
|
529 |
|
530 |
-
if ($helper->canUseEveningTimeframes()) {
|
531 |
$options[] = self::EVENING_DELIVERY_OPTION;
|
532 |
}
|
533 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_DeliveryOptions_Cif setStoreId(int $value)
|
50 |
const DOMESTIC_DELIVERY_OPTION = 'Daytime';
|
51 |
const EVENING_DELIVERY_OPTION = 'Evening';
|
52 |
const SUNDAY_DELIVERY_OPTION = 'Sunday';
|
53 |
+
const SAMEDAY_DELIVERY_OPTION = 'Sameday';
|
54 |
|
55 |
/**
|
56 |
* Config options used by the getDeliveryDate service.
|
57 |
*/
|
58 |
+
const XPATH_SHIPPING_DURATION = 'postnl/cif_labels_and_confirming/shipping_duration';
|
59 |
+
const XPATH_CUTOFF_TIME = 'postnl/cif_labels_and_confirming/cutoff_time';
|
60 |
+
const XPATH_ALLOW_SUNDAY_SORTING = 'postnl/delivery_options/allow_sunday_sorting';
|
61 |
+
const XPATH_ALLOW_SUNDAY_SORTING_BE = 'postnl/delivery_options/allow_sunday_sorting_be';
|
62 |
+
const XPATH_SUNDAY_CUTOFF_TIME = 'postnl/cif_labels_and_confirming/sunday_cutoff_time';
|
63 |
+
const XPATH_DELIVERY_DAYS_NUMBER = 'postnl/delivery_options/delivery_days_number';
|
64 |
+
const XPATH_DELIVERY_DAYS_NUMBER_BE = 'postnl/delivery_options/delivery_days_number_be';
|
65 |
+
const XPATH_ENABLE_SUNDAY_DELIVERY = 'postnl/delivery_options/enable_sunday_delivery';
|
66 |
|
67 |
/**
|
68 |
* Check if the module is set to test mode
|
75 |
*/
|
76 |
public function isTestMode($storeId = false)
|
77 |
{
|
78 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
79 |
+
$helper = Mage::helper('postnl');
|
80 |
+
$testMode = $helper->isTestMode($storeId);
|
81 |
|
82 |
return $testMode;
|
83 |
}
|
102 |
);
|
103 |
}
|
104 |
|
105 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
106 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
107 |
+
$shippingDuration = $helper->getQuoteShippingDuration($quote);
|
108 |
|
109 |
+
$date = new DateTime('now', $helper->getStoreTimeZone($quote->getStoreId(), true));
|
110 |
$date->setTimezone(new DateTimeZone('Europe/Berlin'));
|
111 |
|
112 |
/**
|
125 |
)
|
126 |
);
|
127 |
|
128 |
+
$options = $this->_getDeliveryDateOptionsArray($shippingDuration, $country);
|
129 |
|
130 |
$soapParams = array(
|
131 |
'GetDeliveryDate' => array(
|
132 |
'PostalCode' => $postcode,
|
133 |
'ShippingDate' => $date->format('d-m-Y H:i:s'),
|
134 |
'ShippingDuration' => $shippingDuration,
|
135 |
+
'AllowSundaySorting' => $this->_getSundaySortingAllowed($country),
|
136 |
'CutOffTimes' => $CutOffTimes,
|
137 |
'Options' => $options,
|
138 |
'CountryCode' => $country,
|
167 |
*
|
168 |
* @param array $data
|
169 |
*
|
170 |
+
* @return StdClass[]|false
|
171 |
*
|
172 |
* @throws TIG_PostNL_Exception
|
173 |
*/
|
183 |
$startDate = $data['deliveryDate'];
|
184 |
|
185 |
/**
|
186 |
+
* To calculate the end date we need to number of days we want to display.
|
187 |
*/
|
188 |
$storeId = Mage::app()->getStore()->getId();
|
189 |
+
|
190 |
+
if ($data['country'] == 'BE') {
|
191 |
+
$maximumNumberOfDeliveryDays = (int) Mage::getStoreConfig(self::XPATH_DELIVERY_DAYS_NUMBER_BE, $storeId);
|
192 |
+
} else {
|
193 |
+
$maximumNumberOfDeliveryDays = (int) Mage::getStoreConfig(self::XPATH_DELIVERY_DAYS_NUMBER, $storeId);
|
194 |
+
|
195 |
+
/**
|
196 |
+
* For other countries we need the days minus 1.
|
197 |
+
*/
|
198 |
+
$maximumNumberOfDeliveryDays--;
|
199 |
+
}
|
200 |
|
201 |
$endDate = new DateTime($startDate, new DateTimeZone('UTC'));
|
202 |
$endDate->add(new DateInterval("P{$maximumNumberOfDeliveryDays}D"));
|
203 |
|
204 |
+
$options = $this->_getDeliveryTimeframesOptionsArray($data['country']);
|
205 |
|
206 |
$soapParams = array(
|
207 |
'Timeframe' => array(
|
210 |
'CountryCode' => $data['country'],
|
211 |
'StartDate' => $startDate,
|
212 |
'EndDate' => $endDate->format('d-m-Y'),
|
213 |
+
'SundaySorting' => $this->_getSundaySortingAllowed($data['country']),
|
214 |
'Options' => $options
|
215 |
),
|
216 |
'Message' => $this->_getMessage('')
|
225 |
$soapParams
|
226 |
);
|
227 |
|
228 |
+
if (empty($response->Timeframes)) {
|
229 |
+
return false;
|
230 |
+
}
|
231 |
+
|
232 |
+
if (!isset($response->Timeframes->Timeframe)) {
|
233 |
throw new TIG_PostNL_Exception(
|
234 |
+
Mage::helper('postnl')->__(
|
235 |
+
'Invalid response for getDeliveryTimeframes request: %s',
|
236 |
+
var_export($response, true)
|
237 |
+
),
|
238 |
'POSTNL-0122'
|
239 |
);
|
240 |
}
|
360 |
/**
|
361 |
* Checks whether sunday sorting is allowed for this storeview.
|
362 |
*
|
363 |
+
* @param $country
|
364 |
+
*
|
365 |
* @return string
|
366 |
*/
|
367 |
+
protected function _getSundaySortingAllowed($country)
|
368 |
{
|
369 |
$storeId = $this->getStoreId();
|
370 |
|
371 |
$allowSundaySorting = Mage::getStoreConfigFlag(self::XPATH_ALLOW_SUNDAY_SORTING, $storeId);
|
372 |
+
if ($country == 'BE') {
|
373 |
+
$allowSundaySorting = Mage::getStoreConfigFlag(self::XPATH_ALLOW_SUNDAY_SORTING_BE, $storeId);
|
374 |
+
}
|
375 |
+
|
376 |
if ($allowSundaySorting === true) {
|
377 |
return 'true';
|
378 |
}
|
419 |
if (isset($data['deliveryDate'])) {
|
420 |
$location['DeliveryDate'] = $data['deliveryDate'];
|
421 |
} else {
|
422 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
423 |
+
$dateModel = Mage::getModel('core/date');
|
424 |
+
$tomorrow = strtotime('tomorrow', $dateModel->timestamp());
|
425 |
$location['DeliveryDate'] = date('d-m-Y', $tomorrow);
|
426 |
}
|
427 |
|
439 |
$location['Postalcode'] = $data['postcode'];
|
440 |
}
|
441 |
|
442 |
+
/**
|
443 |
+
* Add the street if available.
|
444 |
+
*/
|
445 |
+
if (isset($data['street'])) {
|
446 |
+
$location['Street'] = $data['street'];
|
447 |
+
}
|
448 |
+
|
449 |
/**
|
450 |
* Add coordinates if both a latitude and longitude are available.
|
451 |
*/
|
485 |
/**
|
486 |
* Add flag to identify if Sunday Sorting is allowed
|
487 |
*/
|
488 |
+
$location['AllowSundaySorting'] = $this->_getSundaySortingAllowed($data['country']);
|
489 |
|
490 |
return $location;
|
491 |
}
|
499 |
{
|
500 |
$deliveryOptions = array();
|
501 |
|
502 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
503 |
$helper = Mage::helper('postnl/deliveryOptions');
|
504 |
if ($helper->canUsePakjeGemak()) {
|
505 |
$deliveryOptions[] = self::PAKJEGEMAK_DELIVERY_OPTION;
|
520 |
* Builds array of time frame options, to be sent in the GetTimeframes request.
|
521 |
* These options determine which delivery timeframes should be requested.
|
522 |
*
|
523 |
+
* @param $country
|
524 |
+
*
|
525 |
* @return array
|
526 |
*/
|
527 |
+
protected function _getDeliveryTimeframesOptionsArray($country)
|
528 |
{
|
529 |
$storeId = $this->getStoreId();
|
530 |
|
531 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
532 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
533 |
+
|
534 |
+
/**
|
535 |
+
* In the case of a food delivery, only sameday and evening delivery timeframes should be shown.
|
536 |
+
*/
|
537 |
+
if ($country == 'NL' && $helper->canUseFoodDelivery(true)) {
|
538 |
+
$options = array(
|
539 |
+
self::SAMEDAY_DELIVERY_OPTION,
|
540 |
+
self::EVENING_DELIVERY_OPTION,
|
541 |
+
);
|
542 |
+
|
543 |
+
return $options;
|
544 |
+
}
|
545 |
+
|
546 |
$options = array(self::DOMESTIC_DELIVERY_OPTION);
|
547 |
|
548 |
+
if ($country == 'NL' && $helper->canUseSameDayDelivery()) {
|
549 |
+
$options[] = self::SAMEDAY_DELIVERY_OPTION;
|
550 |
+
}
|
551 |
|
552 |
+
if ($country == 'NL' && $helper->canUseEveningTimeframes()) {
|
553 |
$options[] = self::EVENING_DELIVERY_OPTION;
|
554 |
}
|
555 |
|
556 |
$sundayDelivery = Mage::getStoreConfig($helper::XPATH_ENABLE_SUNDAY_DELIVERY, $storeId);
|
557 |
+
if ($country == 'NL' && $sundayDelivery) {
|
558 |
$options[] = self::SUNDAY_DELIVERY_OPTION;
|
559 |
}
|
560 |
|
567 |
* important to prevent certain dates from being unavailable. The order used in this method is (depending on the
|
568 |
* extension's config): sunday > daytime > evening.
|
569 |
*
|
570 |
+
* @param null $shippingDuration
|
571 |
+
* @param string $country
|
572 |
+
*
|
573 |
* @return array
|
574 |
*/
|
575 |
+
protected function _getDeliveryDateOptionsArray($shippingDuration = null, $country = 'NL')
|
576 |
{
|
577 |
$storeId = $this->getStoreId();
|
578 |
|
579 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
580 |
$helper = Mage::helper('postnl/deliveryOptions');
|
581 |
|
582 |
$options = array();
|
583 |
+
$sameDayDelivery = Mage::getStoreConfig($helper::XPATH_ENABLE_SAMEDAY_DELIVERY, $storeId);
|
584 |
+
|
585 |
+
if ($shippingDuration == null) {
|
586 |
+
$shippingDuration = Mage::getStoreConfig($helper::XPATH_SHIPPING_DURATION, $storeId);
|
587 |
+
}
|
588 |
+
|
589 |
+
if ($country == 'NL' && $sameDayDelivery && $shippingDuration == 0) {
|
590 |
+
$options[] = self::SAMEDAY_DELIVERY_OPTION;
|
591 |
+
}
|
592 |
+
|
593 |
$sundayDelivery = Mage::getStoreConfig($helper::XPATH_ENABLE_SUNDAY_DELIVERY, $storeId);
|
594 |
+
if ($country == 'NL' && $sundayDelivery) {
|
595 |
$options[] = self::SUNDAY_DELIVERY_OPTION;
|
596 |
}
|
597 |
|
598 |
$options[] = self::DOMESTIC_DELIVERY_OPTION;
|
599 |
|
600 |
+
if ($country == 'NL' && $helper->canUseEveningTimeframes()) {
|
601 |
$options[] = self::EVENING_DELIVERY_OPTION;
|
602 |
}
|
603 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_Observer_GoMage_LightCheckout_Ajax
|
@@ -63,4 +63,4 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_GoMage_LightCheckout_Ajax
|
|
63 |
|
64 |
return $this;
|
65 |
}
|
66 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_Observer_GoMage_LightCheckout_Ajax
|
63 |
|
64 |
return $this;
|
65 |
}
|
66 |
+
}
|
@@ -79,8 +79,13 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_ShippingMethodAvailable extends
|
|
79 |
/**
|
80 |
* Check if delivery options are available for the current quote.
|
81 |
*/
|
82 |
-
|
83 |
-
$
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
$this->setCanUseDeliveryOptions($canUseDeliveryOptions);
|
86 |
return $this->_canUseDeliveryOptions;
|
@@ -216,14 +221,16 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_ShippingMethodAvailable extends
|
|
216 |
*/
|
217 |
protected function _resetPostnlOrder()
|
218 |
{
|
219 |
-
|
|
|
|
|
220 |
|
221 |
/**
|
222 |
* Remove shipment costs from the PostNL order associated with the current quote.
|
223 |
-
*
|
224 |
-
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
225 |
*/
|
226 |
-
$postnlOrder
|
|
|
|
|
227 |
if ($postnlOrder->getId() && !$postnlOrder->hasOrderId()) {
|
228 |
$postnlOrder->setIsActive(false)
|
229 |
->setShipmentCosts(0)
|
@@ -259,27 +266,21 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_ShippingMethodAvailable extends
|
|
259 |
*/
|
260 |
protected function _addDeliveryOptionBlocks(Mage_Checkout_Block_Onepage_Shipping_Method_Available $block)
|
261 |
{
|
262 |
-
/**
|
263 |
-
* @var TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions $firstChild
|
264 |
-
*/
|
265 |
$deliveryOptionsBlock = $block->getLayout()->createBlock(
|
266 |
'postnl_deliveryoptions/checkout_deliveryOptions',
|
267 |
'postnl.osc.delivery.options'
|
268 |
);
|
269 |
$deliveryOptionsBlock->setTemplate('TIG/PostNL/delivery_options/onestepcheckout/deliveryoptions.phtml');
|
270 |
|
271 |
-
/**
|
272 |
-
* @var Mage_Core_Block_Template $addLocationBlock
|
273 |
-
*/
|
274 |
$addLocationBlock = $block->getLayout()->createBlock(
|
275 |
'core/template',
|
276 |
'postnl.osc.add.location'
|
277 |
);
|
278 |
$addLocationBlock->setTemplate('TIG/PostNL/delivery_options/addlocation.phtml');
|
279 |
|
280 |
-
/**
|
281 |
-
* @var TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber $addPhoneNumberBlock
|
282 |
-
*/
|
283 |
$addPhoneNumberBlock = $block->getLayout()->createBlock(
|
284 |
'postnl_deliveryoptions/checkout_addPhoneNumber',
|
285 |
'postnl.add.phonenumber'
|
@@ -409,4 +410,4 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_ShippingMethodAvailable extends
|
|
409 |
|
410 |
return $this;
|
411 |
}
|
412 |
-
}
|
79 |
/**
|
80 |
* Check if delivery options are available for the current quote.
|
81 |
*/
|
82 |
+
/** @var Mage_Checkout_Model_Session $session */
|
83 |
+
$session = Mage::getSingleton('checkout/session');
|
84 |
+
$quote = $session->getQuote();
|
85 |
+
|
86 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
87 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
88 |
+
$canUseDeliveryOptions = $helper->canUseDeliveryOptions($quote);
|
89 |
|
90 |
$this->setCanUseDeliveryOptions($canUseDeliveryOptions);
|
91 |
return $this->_canUseDeliveryOptions;
|
221 |
*/
|
222 |
protected function _resetPostnlOrder()
|
223 |
{
|
224 |
+
/** @var Mage_Checkout_Model_Session $session */
|
225 |
+
$session = Mage::getSingleton('checkout/session');
|
226 |
+
$quote = $session->getQuote();
|
227 |
|
228 |
/**
|
229 |
* Remove shipment costs from the PostNL order associated with the current quote.
|
|
|
|
|
230 |
*/
|
231 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
232 |
+
$postnlOrder = Mage::getModel('postnl_core/order');
|
233 |
+
$postnlOrder->loadByQuote($quote);
|
234 |
if ($postnlOrder->getId() && !$postnlOrder->hasOrderId()) {
|
235 |
$postnlOrder->setIsActive(false)
|
236 |
->setShipmentCosts(0)
|
266 |
*/
|
267 |
protected function _addDeliveryOptionBlocks(Mage_Checkout_Block_Onepage_Shipping_Method_Available $block)
|
268 |
{
|
269 |
+
/** @var TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions $deliveryOptionsBlock */
|
|
|
|
|
270 |
$deliveryOptionsBlock = $block->getLayout()->createBlock(
|
271 |
'postnl_deliveryoptions/checkout_deliveryOptions',
|
272 |
'postnl.osc.delivery.options'
|
273 |
);
|
274 |
$deliveryOptionsBlock->setTemplate('TIG/PostNL/delivery_options/onestepcheckout/deliveryoptions.phtml');
|
275 |
|
276 |
+
/** @var Mage_Core_Block_Template $addLocationBlock */
|
|
|
|
|
277 |
$addLocationBlock = $block->getLayout()->createBlock(
|
278 |
'core/template',
|
279 |
'postnl.osc.add.location'
|
280 |
);
|
281 |
$addLocationBlock->setTemplate('TIG/PostNL/delivery_options/addlocation.phtml');
|
282 |
|
283 |
+
/** @var TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber $addPhoneNumberBlock */
|
|
|
|
|
284 |
$addPhoneNumberBlock = $block->getLayout()->createBlock(
|
285 |
'postnl_deliveryoptions/checkout_addPhoneNumber',
|
286 |
'postnl.add.phonenumber'
|
410 |
|
411 |
return $this;
|
412 |
}
|
413 |
+
}
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@totalinternetgroup.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Model_DeliveryOptions_Observer_UpdateConfig {
|
40 |
+
/**
|
41 |
+
* Xpaths for the required config options.
|
42 |
+
*/
|
43 |
+
const XPATH_POSTNL_CIF_ADDRESS_COUNTRY = 'postnl/cif_address/country';
|
44 |
+
const XPATH_POSTNL_CIF_LABELS_AND_CONFIRMING_USE_DUTCH_PRODUCTS = 'postnl/cif_labels_and_confirming/use_dutch_products';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* The required attributes codes.
|
48 |
+
*/
|
49 |
+
const ATTRIBUTE_CODE_POSTNL_MAX_QTY_FOR_BUSPAKJE = 'postnl_max_qty_for_buspakje';
|
50 |
+
const ATTRIBUTE_CODE_POSTNL_PRODUCT_TYPE = 'postnl_product_type';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* The array that holds the attributes models.
|
54 |
+
*
|
55 |
+
* @var array
|
56 |
+
*/
|
57 |
+
protected $attributes = array();
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Check if we need to show some product attributes. If not, hide them.
|
61 |
+
*
|
62 |
+
* @return $this
|
63 |
+
* @throws Exception
|
64 |
+
* @throws Mage_Core_Exception
|
65 |
+
*/
|
66 |
+
public function updateAttributes()
|
67 |
+
{
|
68 |
+
$country = Mage::getStoreConfig(self::XPATH_POSTNL_CIF_ADDRESS_COUNTRY);
|
69 |
+
$use_dutch_products = Mage::getStoreConfig(self::XPATH_POSTNL_CIF_LABELS_AND_CONFIRMING_USE_DUTCH_PRODUCTS);
|
70 |
+
|
71 |
+
$xpaths = array(self::ATTRIBUTE_CODE_POSTNL_MAX_QTY_FOR_BUSPAKJE, self::ATTRIBUTE_CODE_POSTNL_PRODUCT_TYPE);
|
72 |
+
foreach ($xpaths as $xpath) {
|
73 |
+
$model = $this->getModel($xpath);
|
74 |
+
|
75 |
+
if ($model->getId() !== null) {
|
76 |
+
$this->attributes[] = $model;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* If the domestic country is NL, always show the options.
|
82 |
+
*/
|
83 |
+
if ($country == 'NL') {
|
84 |
+
$this->setIsVisible(true);
|
85 |
+
} else {
|
86 |
+
/**
|
87 |
+
* The country is not NL, and the option use_dutch_products is disabled. So hide this options.
|
88 |
+
*/
|
89 |
+
if ($use_dutch_products == '0') {
|
90 |
+
$this->setIsVisible(false);
|
91 |
+
} else {
|
92 |
+
$this->setIsVisible(true);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Too bad dataHasChangedFor returns false when setIsVisible is false.
|
98 |
+
*/
|
99 |
+
foreach ($this->attributes as $attribute) {
|
100 |
+
$attribute->save();
|
101 |
+
}
|
102 |
+
|
103 |
+
return $this;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Load a model by the xpath.
|
108 |
+
*
|
109 |
+
* @param $xpath
|
110 |
+
*
|
111 |
+
* @return Mage_Eav_Model_Entity_Attribute
|
112 |
+
* @throws Mage_Core_Exception
|
113 |
+
*/
|
114 |
+
protected function getModel($xpath) {
|
115 |
+
/** @var Mage_Eav_Model_Entity_Attribute $model */
|
116 |
+
$model = Mage::getModel('eav/entity_attribute');
|
117 |
+
$model->loadByCode(Mage_Catalog_Model_Product::ENTITY, $xpath);
|
118 |
+
|
119 |
+
return $model;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Loop over the models and set the isVisible value.
|
124 |
+
*
|
125 |
+
* @param $value
|
126 |
+
*
|
127 |
+
* @return $this
|
128 |
+
*/
|
129 |
+
protected function setIsVisible($value) {
|
130 |
+
foreach ($this->attributes as $attribute) {
|
131 |
+
$attribute->setIsVisible($value);
|
132 |
+
}
|
133 |
+
|
134 |
+
return $this;
|
135 |
+
}
|
136 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
@@ -55,6 +55,7 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
55 |
/**
|
56 |
* @var Mage_Sales_Model_Order $order
|
57 |
*/
|
|
|
58 |
$order = $observer->getOrder();
|
59 |
|
60 |
/**
|
@@ -67,7 +68,9 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
67 |
/**
|
68 |
* Check if the order was placed using a PostNL shipping method.
|
69 |
*/
|
70 |
-
|
|
|
|
|
71 |
|
72 |
/**
|
73 |
* If the order was placed using a PostNL shipping method, yet does not have a PostNL order object; create one.
|
@@ -136,7 +139,9 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
136 |
* Check whether the shipping prices are entered with or without tax.
|
137 |
*/
|
138 |
$includingTax = false;
|
139 |
-
|
|
|
|
|
140 |
$includingTax = true;
|
141 |
}
|
142 |
|
@@ -144,14 +149,17 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
144 |
* Calculate the correct fee based on the order type.
|
145 |
*/
|
146 |
if ($type == $postnlOrder::TYPE_PGE) {
|
147 |
-
|
148 |
-
|
|
|
149 |
} elseif ($type == $postnlOrder::TYPE_AVOND) {
|
150 |
-
|
151 |
-
|
|
|
152 |
} elseif ($type == $postnlOrder::TYPE_SUNDAY) {
|
153 |
-
|
154 |
-
|
|
|
155 |
}
|
156 |
}
|
157 |
|
@@ -162,7 +170,6 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
162 |
$this->_setDates($postnlOrder, $order);
|
163 |
}
|
164 |
|
165 |
-
|
166 |
/**
|
167 |
* Update the PostNL order.
|
168 |
*/
|
@@ -195,6 +202,7 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
195 |
*/
|
196 |
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
197 |
if (!$quote || !$quote->getId()) {
|
|
|
198 |
$quote = $order->getQuote();
|
199 |
}
|
200 |
|
@@ -227,7 +235,9 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
227 |
* Convert the quote address to an order address and add it to the order.
|
228 |
*/
|
229 |
$pakjeGemakAddress->load($pakjeGemakAddress->getId());
|
230 |
-
|
|
|
|
|
231 |
|
232 |
$order->addAddress($orderAddress)
|
233 |
->save();
|
@@ -256,8 +266,7 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
256 |
*
|
257 |
* @return $this
|
258 |
*
|
259 |
-
* @event controller_action_postdispatch_checkout_onepage_saveShippingMethod
|
260 |
-
* |controller_action_predispatch_onestepcheckout_ajax_set_methods_separate
|
261 |
*
|
262 |
* @observer checkout_shipping_method_save_options
|
263 |
*
|
@@ -265,7 +274,9 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
265 |
*/
|
266 |
public function saveOptions(Varien_Event_Observer $observer)
|
267 |
{
|
268 |
-
|
|
|
|
|
269 |
|
270 |
/**
|
271 |
* Get the PostNL order associated with this quote.
|
@@ -287,9 +298,12 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
287 |
* may have been saved.
|
288 |
*/
|
289 |
$shippingAddress = $quote->getShippingAddress();
|
|
|
|
|
|
|
290 |
if (!$shippingAddress
|
291 |
-
|| $shippingAddress->getCountryId() !=
|
292 |
-
||
|
293 |
|
294 |
) {
|
295 |
$postnlOrder->setOptions(false)
|
@@ -298,9 +312,8 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
298 |
return $this;
|
299 |
}
|
300 |
|
301 |
-
/**
|
302 |
-
|
303 |
-
*/
|
304 |
$controller = $observer->getControllerAction();
|
305 |
$options = $controller->getRequest()->getParam('s_method_' . $shippingMethod, array());
|
306 |
if (empty($options['postnl'])) {
|
@@ -337,6 +350,7 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
337 |
return false;
|
338 |
}
|
339 |
|
|
|
340 |
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
341 |
|
342 |
$utcTimeZone = new DateTimeZone('UTC');
|
@@ -360,17 +374,35 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
360 |
$domesticCountry = Mage::helper('postnl')->getDomesticCountry();
|
361 |
$shippingAddress = $order->getShippingAddress();
|
362 |
|
363 |
-
if (
|
364 |
-
|
|
|
365 |
) {
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
}
|
368 |
|
369 |
/**
|
370 |
* Check if the shipping method is a PostNL shipping method.
|
371 |
*/
|
372 |
$shippingMethod = $order->getShippingMethod();
|
373 |
-
|
|
|
|
|
374 |
return false;
|
375 |
}
|
376 |
|
@@ -390,7 +422,7 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
390 |
{
|
391 |
$postnlOrder->setQuoteId($order->getQuoteId())
|
392 |
->setOrderId($order->getId())
|
393 |
-
->setType($postnlOrder
|
394 |
->setIsActive(0)
|
395 |
->setIsCanceled(0)
|
396 |
->setShipmentCosts(0)
|
@@ -404,6 +436,31 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
404 |
return $this;
|
405 |
}
|
406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
/**
|
408 |
* Set the confirm and delivery dates for a given PostNl order.
|
409 |
*
|
@@ -416,13 +473,28 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
416 |
{
|
417 |
/** @var TIG_PostNL_Helper_Date $helper */
|
418 |
$helper = Mage::helper('postnl/date');
|
|
|
|
|
419 |
|
420 |
$dateObject = new DateTime($order->getCreatedAt(), new DateTimeZone('UTC'));
|
421 |
$deliveryDate = clone $dateObject;
|
422 |
$confirmDate = clone $dateObject;
|
423 |
|
424 |
-
|
425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
|
427 |
$postnlOrder->setDeliveryDate($deliveryDate->getTimestamp())
|
428 |
->setConfirmDate($confirmDate->getTimestamp());
|
@@ -451,4 +523,4 @@ class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
|
451 |
|
452 |
return $this;
|
453 |
}
|
454 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_Observer_UpdatePostnlOrder
|
55 |
/**
|
56 |
* @var Mage_Sales_Model_Order $order
|
57 |
*/
|
58 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
59 |
$order = $observer->getOrder();
|
60 |
|
61 |
/**
|
68 |
/**
|
69 |
* Check if the order was placed using a PostNL shipping method.
|
70 |
*/
|
71 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
72 |
+
$helper = Mage::helper('postnl/carrier');
|
73 |
+
$orderIsPostnl = $helper->isPostnlShippingMethod($order->getShippingMethod());
|
74 |
|
75 |
/**
|
76 |
* If the order was placed using a PostNL shipping method, yet does not have a PostNL order object; create one.
|
139 |
* Check whether the shipping prices are entered with or without tax.
|
140 |
*/
|
141 |
$includingTax = false;
|
142 |
+
/** @var Mage_Tax_Model_Config $config */
|
143 |
+
$config = Mage::getSingleton('tax/config');
|
144 |
+
if ($config->shippingPriceIncludesTax()) {
|
145 |
$includingTax = true;
|
146 |
}
|
147 |
|
149 |
* Calculate the correct fee based on the order type.
|
150 |
*/
|
151 |
if ($type == $postnlOrder::TYPE_PGE) {
|
152 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
153 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
154 |
+
$fee = $helper->getExpressFee(false, $includingTax, false);
|
155 |
} elseif ($type == $postnlOrder::TYPE_AVOND) {
|
156 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
157 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
158 |
+
$fee = $helper->getEveningFee(false, $includingTax, false);
|
159 |
} elseif ($type == $postnlOrder::TYPE_SUNDAY) {
|
160 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
161 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
162 |
+
$fee = $helper->getSundayFee(false, $includingTax, false);
|
163 |
}
|
164 |
}
|
165 |
|
170 |
$this->_setDates($postnlOrder, $order);
|
171 |
}
|
172 |
|
|
|
173 |
/**
|
174 |
* Update the PostNL order.
|
175 |
*/
|
202 |
*/
|
203 |
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
204 |
if (!$quote || !$quote->getId()) {
|
205 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
206 |
$quote = $order->getQuote();
|
207 |
}
|
208 |
|
235 |
* Convert the quote address to an order address and add it to the order.
|
236 |
*/
|
237 |
$pakjeGemakAddress->load($pakjeGemakAddress->getId());
|
238 |
+
/** @var Mage_Sales_Model_Convert_Quote $converter */
|
239 |
+
$converter = Mage::getModel('sales/convert_quote');
|
240 |
+
$orderAddress = $converter->addressToOrderAddress($pakjeGemakAddress);
|
241 |
|
242 |
$order->addAddress($orderAddress)
|
243 |
->save();
|
266 |
*
|
267 |
* @return $this
|
268 |
*
|
269 |
+
* @event controller_action_postdispatch_checkout_onepage_saveShippingMethod|controller_action_predispatch_onestepcheckout_ajax_set_methods_separate
|
|
|
270 |
*
|
271 |
* @observer checkout_shipping_method_save_options
|
272 |
*
|
274 |
*/
|
275 |
public function saveOptions(Varien_Event_Observer $observer)
|
276 |
{
|
277 |
+
/** @var Mage_Checkout_Model_Session $session */
|
278 |
+
$session = Mage::getSingleton('checkout/session');
|
279 |
+
$quote = $session->getQuote();
|
280 |
|
281 |
/**
|
282 |
* Get the PostNL order associated with this quote.
|
298 |
* may have been saved.
|
299 |
*/
|
300 |
$shippingAddress = $quote->getShippingAddress();
|
301 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
302 |
+
$helper = Mage::helper('postnl/carrier');
|
303 |
+
$domesticCountry = $helper->getDomesticCountry();
|
304 |
if (!$shippingAddress
|
305 |
+
|| $shippingAddress->getCountryId() != $domesticCountry
|
306 |
+
|| !$helper->isPostnlShippingMethod($shippingMethod)
|
307 |
|
308 |
) {
|
309 |
$postnlOrder->setOptions(false)
|
312 |
return $this;
|
313 |
}
|
314 |
|
315 |
+
/** @var Mage_Core_Controller_Varien_Front $controller */
|
316 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
|
|
317 |
$controller = $observer->getControllerAction();
|
318 |
$options = $controller->getRequest()->getParam('s_method_' . $shippingMethod, array());
|
319 |
if (empty($options['postnl'])) {
|
350 |
return false;
|
351 |
}
|
352 |
|
353 |
+
/** @var Mage_Sales_Model_Quote $quote */
|
354 |
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
355 |
|
356 |
$utcTimeZone = new DateTimeZone('UTC');
|
374 |
$domesticCountry = Mage::helper('postnl')->getDomesticCountry();
|
375 |
$shippingAddress = $order->getShippingAddress();
|
376 |
|
377 |
+
if (
|
378 |
+
!$shippingAddress ||
|
379 |
+
$shippingAddress->getCountryId() != $domesticCountry
|
380 |
) {
|
381 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
382 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
383 |
+
$helper->setDomesticCountry($domesticCountry);
|
384 |
+
$canUseDutchProducts = $helper->canUseDutchProducts();
|
385 |
+
|
386 |
+
if (
|
387 |
+
$domesticCountry != 'BE' ||
|
388 |
+
$shippingAddress->getCountryId() != 'NL' ||
|
389 |
+
(
|
390 |
+
$domesticCountry == 'BE' &&
|
391 |
+
$shippingAddress->getCountryId() == 'NL' &&
|
392 |
+
!$canUseDutchProducts
|
393 |
+
)
|
394 |
+
) {
|
395 |
+
return false;
|
396 |
+
}
|
397 |
}
|
398 |
|
399 |
/**
|
400 |
* Check if the shipping method is a PostNL shipping method.
|
401 |
*/
|
402 |
$shippingMethod = $order->getShippingMethod();
|
403 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
404 |
+
$helper = Mage::helper('postnl/carrier');
|
405 |
+
if (!$helper->isPostnlShippingMethod($shippingMethod)) {
|
406 |
return false;
|
407 |
}
|
408 |
|
422 |
{
|
423 |
$postnlOrder->setQuoteId($order->getQuoteId())
|
424 |
->setOrderId($order->getId())
|
425 |
+
->setType($this->_getOrderType($postnlOrder, $order))
|
426 |
->setIsActive(0)
|
427 |
->setIsCanceled(0)
|
428 |
->setShipmentCosts(0)
|
436 |
return $this;
|
437 |
}
|
438 |
|
439 |
+
/**
|
440 |
+
* @param TIG_PostNL_Model_Core_Order $postnlOrder
|
441 |
+
* @param Mage_Sales_Model_Order $order
|
442 |
+
*
|
443 |
+
* @return mixed
|
444 |
+
*/
|
445 |
+
protected function _getOrderType(TIG_PostNL_Model_Core_Order $postnlOrder, Mage_Sales_Model_Order $order)
|
446 |
+
{
|
447 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
448 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
449 |
+
|
450 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
451 |
+
if ($helper->canUseFoodDelivery(false) && $helper->quoteIsFood($order->getQuote())) {
|
452 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
453 |
+
switch ($helper->getQuoteFoodType($order->getQuote())) {
|
454 |
+
case 1:
|
455 |
+
return $postnlOrder::TYPE_FOOD;
|
456 |
+
case 2:
|
457 |
+
return $postnlOrder::TYPE_COOLED_FOOD;
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
return $postnlOrder::TYPE_OVERDAG;
|
462 |
+
}
|
463 |
+
|
464 |
/**
|
465 |
* Set the confirm and delivery dates for a given PostNl order.
|
466 |
*
|
473 |
{
|
474 |
/** @var TIG_PostNL_Helper_Date $helper */
|
475 |
$helper = Mage::helper('postnl/date');
|
476 |
+
/** @var TIG_PostNL_Helper_Data $postnlHelper */
|
477 |
+
$postnlHelper = Mage::helper('postnl');
|
478 |
|
479 |
$dateObject = new DateTime($order->getCreatedAt(), new DateTimeZone('UTC'));
|
480 |
$deliveryDate = clone $dateObject;
|
481 |
$confirmDate = clone $dateObject;
|
482 |
|
483 |
+
if ($postnlOrder->isSameDayDelivery()) {
|
484 |
+
$helper->setPostnlDeliveryDelay(0);
|
485 |
+
}
|
486 |
+
|
487 |
+
$domesticCountry = $postnlHelper->getDomesticCountry();
|
488 |
+
$orderCountry = $order->getShippingAddress()->getCountryId();
|
489 |
+
|
490 |
+
if ($domesticCountry == $orderCountry) {
|
491 |
+
$allowSameDay = ($postnlOrder->isSameDayDelivery() || $postnlOrder->isFood());
|
492 |
+
|
493 |
+
$helper->setUseFoodCutOffTime($postnlOrder->isFood());
|
494 |
+
|
495 |
+
$deliveryDate = $helper->getDeliveryDate($deliveryDate, $order->getStoreId(), $allowSameDay);
|
496 |
+
$confirmDate = $helper->getShippingDateFromDeliveryDate(clone $deliveryDate, $order->getStoreId());
|
497 |
+
}
|
498 |
|
499 |
$postnlOrder->setDeliveryDate($deliveryDate->getTimestamp())
|
500 |
->setConfirmDate($confirmDate->getTimestamp());
|
523 |
|
524 |
return $this;
|
525 |
}
|
526 |
+
}
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Model_DeliveryOptions_Product_Attribute_Source_ProductType
|
40 |
+
extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* Retrieve all attribute options
|
44 |
+
*
|
45 |
+
* @return array
|
46 |
+
*/
|
47 |
+
public function getAllOptions()
|
48 |
+
{
|
49 |
+
if ($this->_options) {
|
50 |
+
return $this->_options;
|
51 |
+
}
|
52 |
+
|
53 |
+
$helper = Mage::helper('postnl');
|
54 |
+
|
55 |
+
$options = array(
|
56 |
+
array(
|
57 |
+
'label' => $helper->__('Non-Food'),
|
58 |
+
'value' => 0,
|
59 |
+
),
|
60 |
+
array(
|
61 |
+
'value' => 1,
|
62 |
+
'label' => $helper->__('Dry & Groceries'),
|
63 |
+
),
|
64 |
+
array(
|
65 |
+
'value' => 2,
|
66 |
+
'label' => $helper->__('Cooled Products'),
|
67 |
+
),
|
68 |
+
);
|
69 |
+
|
70 |
+
$this->_options = $options;
|
71 |
+
|
72 |
+
return $options;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Function referencing getAllOptions to be used in the PostNL configuration.
|
77 |
+
*
|
78 |
+
* @return array
|
79 |
+
*/
|
80 |
+
public function toOptionArray()
|
81 |
+
{
|
82 |
+
return $this->getAllOptions();
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* {@inheritdoc}
|
87 |
+
*/
|
88 |
+
public function getFlatColums()
|
89 |
+
{
|
90 |
+
$attributeCode = $this->getAttribute()->getAttributeCode();
|
91 |
+
$column = array(
|
92 |
+
'unsigned' => false,
|
93 |
+
'default' => null,
|
94 |
+
'extra' => null
|
95 |
+
);
|
96 |
+
|
97 |
+
if (Mage::helper('core')->useDbCompatibleMode()) {
|
98 |
+
$column['type'] = 'int(11)';
|
99 |
+
$column['is_null'] = true;
|
100 |
+
} else {
|
101 |
+
$column['type'] = Varien_Db_Ddl_Table::TYPE_INTEGER;
|
102 |
+
$column['length'] = 1;
|
103 |
+
$column['nullable'] = true;
|
104 |
+
$column['comment'] = $attributeCode . ' column';
|
105 |
+
}
|
106 |
+
|
107 |
+
return array($attributeCode => $column);
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* {@inheritdoc}
|
112 |
+
*/
|
113 |
+
public function getFlatUpdateSelect($store)
|
114 |
+
{
|
115 |
+
return Mage::getResourceModel('eav/entity_attribute')
|
116 |
+
->getFlatUpdateSelect($this->getAttribute(), $store);
|
117 |
+
}
|
118 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_Product_Attribute_Source_ShippingDuration
|
@@ -55,7 +55,11 @@ class TIG_PostNL_Model_DeliveryOptions_Product_Attribute_Source_ShippingDuration
|
|
55 |
$options = array(
|
56 |
array(
|
57 |
'label' => $helper->__('Use configuration value'),
|
58 |
-
'value' => ''
|
|
|
|
|
|
|
|
|
59 |
),
|
60 |
array(
|
61 |
'value' => 1,
|
@@ -170,4 +174,4 @@ class TIG_PostNL_Model_DeliveryOptions_Product_Attribute_Source_ShippingDuration
|
|
170 |
|
171 |
return $select;
|
172 |
}
|
173 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_Product_Attribute_Source_ShippingDuration
|
55 |
$options = array(
|
56 |
array(
|
57 |
'label' => $helper->__('Use configuration value'),
|
58 |
+
'value' => '-1'
|
59 |
+
),
|
60 |
+
array(
|
61 |
+
'value' => 0,
|
62 |
+
'label' => '0 ' . $helper->__('days'),
|
63 |
),
|
64 |
array(
|
65 |
'value' => 1,
|
174 |
|
175 |
return $select;
|
176 |
}
|
177 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasQuote()
|
@@ -73,6 +73,7 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
73 |
|
74 |
$quote = $this->getQuote();
|
75 |
|
|
|
76 |
$postnlOrder = Mage::getModel('postnl_core/order');
|
77 |
$postnlOrder->load($quote->getId(), 'quote_id');
|
78 |
|
@@ -93,7 +94,9 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
93 |
return $quote;
|
94 |
}
|
95 |
|
96 |
-
|
|
|
|
|
97 |
|
98 |
$this->setQuote($quote);
|
99 |
return $quote;
|
@@ -113,7 +116,9 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
113 |
}
|
114 |
|
115 |
$shippingDuration = Mage::getStoreConfig(self::XPATH_SHIPPING_DURATION);
|
116 |
-
|
|
|
|
|
117 |
$shippingDuration++;
|
118 |
}
|
119 |
|
@@ -123,10 +128,11 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
123 |
|
124 |
/**
|
125 |
* @param StdClass[] $timeframes
|
|
|
126 |
*
|
127 |
-
* @return StdClass[]
|
128 |
*/
|
129 |
-
public function filterTimeframes($timeframes)
|
130 |
{
|
131 |
/**
|
132 |
* If the time frames are not an array, something has gone wrong.
|
@@ -135,40 +141,10 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
135 |
return false;
|
136 |
}
|
137 |
|
|
|
138 |
$helper = Mage::helper('postnl/deliveryOptions');
|
139 |
|
140 |
-
return $helper->filterTimeFrames($timeframes, Mage::app()->getStore()->getId());
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Validate if saturday shipping is allowed for the specified shipping date when taking the earliest possible
|
145 |
-
* shipping date into consideration.
|
146 |
-
*
|
147 |
-
* @param array $shippingDays
|
148 |
-
* @param DateTime $shippingDate
|
149 |
-
* @param DateTime $earliestShippingDate
|
150 |
-
*
|
151 |
-
* @return bool
|
152 |
-
*/
|
153 |
-
protected function _validateSaturdayShipping($shippingDays, DateTime $shippingDate, DateTime $earliestShippingDate)
|
154 |
-
{
|
155 |
-
$shippingDate->modify('last saturday ' . $shippingDate->format('H:i:s'));
|
156 |
-
$shippingDay = 6;
|
157 |
-
|
158 |
-
if (!in_array($shippingDay, $shippingDays)) {
|
159 |
-
return false;
|
160 |
-
}
|
161 |
-
|
162 |
-
$cutOffTime = Mage::helper('postnl/deliveryOptions')->getCutOffTime(null, true, $shippingDate);
|
163 |
-
$cutOffTime = explode(':', $cutOffTime);
|
164 |
-
|
165 |
-
$shippingDate->setTime($cutOffTime[0], $cutOffTime[1], $cutOffTime[2]);
|
166 |
-
|
167 |
-
if ($shippingDate < $earliestShippingDate) {
|
168 |
-
return false;
|
169 |
-
}
|
170 |
-
|
171 |
-
return true;
|
172 |
}
|
173 |
|
174 |
/**
|
@@ -225,6 +201,10 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
225 |
/** @var TIG_PostNL_Helper_Date $helper */
|
226 |
$helper = Mage::helper('postnl/date');
|
227 |
|
|
|
|
|
|
|
|
|
228 |
$quote = $this->getQuote();
|
229 |
|
230 |
$amsterdamTimeZone = new DateTimeZone('Europe/Amsterdam');
|
@@ -233,8 +213,12 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
233 |
$deliveryDate = DateTime::createFromFormat('d-m-Y', $data['date'], $amsterdamTimeZone);
|
234 |
$deliveryDate->setTimezone($utcTimeZone);
|
235 |
|
236 |
-
$
|
237 |
-
|
|
|
|
|
|
|
|
|
238 |
|
239 |
/**
|
240 |
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
@@ -259,7 +243,9 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
259 |
->setProductCode(3553)
|
260 |
->setMobilePhoneNumber($data['number']);
|
261 |
} elseif ($data['type'] == 'PG' || $data['type'] == 'PGE') {
|
262 |
-
$postnlOrder->setIsPakjeGemak(true)
|
|
|
|
|
263 |
}
|
264 |
|
265 |
/**
|
@@ -308,7 +294,9 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
308 |
$phoneNumber = $address['telephone'];
|
309 |
}
|
310 |
|
|
|
311 |
$pakjeGemakAddress = Mage::getModel('sales/quote_address');
|
|
|
312 |
$pakjeGemakAddress->setAddressType(self::ADDRESS_TYPE_PAKJEGEMAK)
|
313 |
->setCity($address['city'])
|
314 |
->setCountryId($address['countryCode'])
|
@@ -327,4 +315,4 @@ class TIG_PostNL_Model_DeliveryOptions_Service extends Varien_Object
|
|
327 |
|
328 |
return $this;
|
329 |
}
|
330 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method boolean hasQuote()
|
73 |
|
74 |
$quote = $this->getQuote();
|
75 |
|
76 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
77 |
$postnlOrder = Mage::getModel('postnl_core/order');
|
78 |
$postnlOrder->load($quote->getId(), 'quote_id');
|
79 |
|
94 |
return $quote;
|
95 |
}
|
96 |
|
97 |
+
/** @var Mage_Checkout_Model_Session $session */
|
98 |
+
$session = Mage::getSingleton('checkout/session');
|
99 |
+
$quote = $session->getQuote();
|
100 |
|
101 |
$this->setQuote($quote);
|
102 |
return $quote;
|
116 |
}
|
117 |
|
118 |
$shippingDuration = Mage::getStoreConfig(self::XPATH_SHIPPING_DURATION);
|
119 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
120 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
121 |
+
if ($deliveryDay == 1 && !$helper->canUseSundaySorting()) {
|
122 |
$shippingDuration++;
|
123 |
}
|
124 |
|
128 |
|
129 |
/**
|
130 |
* @param StdClass[] $timeframes
|
131 |
+
* @param string $destinationCountry
|
132 |
*
|
133 |
+
* @return false|StdClass[]
|
134 |
*/
|
135 |
+
public function filterTimeframes($timeframes, $destinationCountry = 'NL')
|
136 |
{
|
137 |
/**
|
138 |
* If the time frames are not an array, something has gone wrong.
|
141 |
return false;
|
142 |
}
|
143 |
|
144 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions $helper */
|
145 |
$helper = Mage::helper('postnl/deliveryOptions');
|
146 |
|
147 |
+
return $helper->filterTimeFrames($timeframes, Mage::app()->getStore()->getId(), $destinationCountry);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
149 |
|
150 |
/**
|
201 |
/** @var TIG_PostNL_Helper_Date $helper */
|
202 |
$helper = Mage::helper('postnl/date');
|
203 |
|
204 |
+
if ($data['type'] == 'Sameday') {
|
205 |
+
$helper->setPostnlDeliveryDelay(0);
|
206 |
+
}
|
207 |
+
|
208 |
$quote = $this->getQuote();
|
209 |
|
210 |
$amsterdamTimeZone = new DateTimeZone('Europe/Amsterdam');
|
213 |
$deliveryDate = DateTime::createFromFormat('d-m-Y', $data['date'], $amsterdamTimeZone);
|
214 |
$deliveryDate->setTimezone($utcTimeZone);
|
215 |
|
216 |
+
if ($data['type'] == 'Food' || $data['type'] == 'Cooledfood') {
|
217 |
+
$confirmDate = $deliveryDate;
|
218 |
+
} else {
|
219 |
+
$deliveryDateClone = clone $deliveryDate;
|
220 |
+
$confirmDate = $helper->getShippingDateFromDeliveryDate($deliveryDateClone, $quote->getStoreId());
|
221 |
+
}
|
222 |
|
223 |
/**
|
224 |
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
243 |
->setProductCode(3553)
|
244 |
->setMobilePhoneNumber($data['number']);
|
245 |
} elseif ($data['type'] == 'PG' || $data['type'] == 'PGE') {
|
246 |
+
$postnlOrder->setIsPakjeGemak(true)
|
247 |
+
->setPgLocationCode($data['locationCode'])
|
248 |
+
->setPgRetailNetworkId($data['retailNetworkId']);
|
249 |
}
|
250 |
|
251 |
/**
|
294 |
$phoneNumber = $address['telephone'];
|
295 |
}
|
296 |
|
297 |
+
/** @var Mage_Sales_Model_Quote_Address $pakjeGemakAddress */
|
298 |
$pakjeGemakAddress = Mage::getModel('sales/quote_address');
|
299 |
+
/** @noinspection PhpParamsInspection */
|
300 |
$pakjeGemakAddress->setAddressType(self::ADDRESS_TYPE_PAKJEGEMAK)
|
301 |
->setCity($address['city'])
|
302 |
->setCountryId($address['countryCode'])
|
315 |
|
316 |
return $this;
|
317 |
}
|
318 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
*/
|
@@ -69,9 +69,11 @@ class TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee extends
|
|
69 |
*/
|
70 |
protected function _getMinFeeAmount()
|
71 |
{
|
72 |
-
|
|
|
|
|
73 |
$this->_feeType,
|
74 |
-
|
75 |
);
|
76 |
|
77 |
return $feeLimit;
|
@@ -82,9 +84,11 @@ class TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee extends
|
|
82 |
*/
|
83 |
protected function _getMaxFeeAmount()
|
84 |
{
|
85 |
-
|
|
|
|
|
86 |
$this->_feeType,
|
87 |
-
|
88 |
);
|
89 |
|
90 |
return $feeLimit;
|
@@ -99,7 +103,9 @@ class TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee extends
|
|
99 |
return $this->_getData('is_including_tax');
|
100 |
}
|
101 |
|
102 |
-
$
|
|
|
|
|
103 |
|
104 |
$this->setIsIncludingTax($includingTax);
|
105 |
return $includingTax;
|
@@ -173,7 +179,9 @@ class TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee extends
|
|
173 |
*/
|
174 |
$shippingAddress = $this->getMockShippingAddress();
|
175 |
|
176 |
-
|
|
|
|
|
177 |
if ($feeIncludingTax > $maxFeeAmount || $feeIncludingTax < $minFeeAmount) {
|
178 |
throw new TIG_PostNL_Exception(
|
179 |
Mage::helper('postnl')->__(
|
@@ -201,4 +209,4 @@ class TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee extends
|
|
201 |
|
202 |
return parent::_beforeSave();
|
203 |
}
|
204 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
*/
|
69 |
*/
|
70 |
protected function _getMinFeeAmount()
|
71 |
{
|
72 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
73 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
74 |
+
$feeLimit = $helper->getFeeLimit(
|
75 |
$this->_feeType,
|
76 |
+
$helper::FEE_LIMIT_MIN
|
77 |
);
|
78 |
|
79 |
return $feeLimit;
|
84 |
*/
|
85 |
protected function _getMaxFeeAmount()
|
86 |
{
|
87 |
+
/** @var TIG_PostNL_Helper_DeliveryOptions_Fee $helper */
|
88 |
+
$helper = Mage::helper('postnl/deliveryOptions_fee');
|
89 |
+
$feeLimit = $helper->getFeeLimit(
|
90 |
$this->_feeType,
|
91 |
+
$helper::FEE_LIMIT_MAX
|
92 |
);
|
93 |
|
94 |
return $feeLimit;
|
103 |
return $this->_getData('is_including_tax');
|
104 |
}
|
105 |
|
106 |
+
/** @var Mage_Tax_Model_Config $taxConfig */
|
107 |
+
$taxConfig = Mage::getSingleton('tax/config');
|
108 |
+
$includingTax = $taxConfig->shippingPriceIncludesTax();
|
109 |
|
110 |
$this->setIsIncludingTax($includingTax);
|
111 |
return $includingTax;
|
179 |
*/
|
180 |
$shippingAddress = $this->getMockShippingAddress();
|
181 |
|
182 |
+
/** @var Mage_Tax_Helper_Data $taxHelper */
|
183 |
+
$taxHelper = Mage::helper('tax');
|
184 |
+
$feeIncludingTax = $taxHelper->getShippingPrice($fee, true, $shippingAddress, null, 0);
|
185 |
if ($feeIncludingTax > $maxFeeAmount || $feeIncludingTax < $minFeeAmount) {
|
186 |
throw new TIG_PostNL_Exception(
|
187 |
Mage::helper('postnl')->__(
|
209 |
|
210 |
return parent::_beforeSave();
|
211 |
}
|
212 |
+
}
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee_SameDayDeliveryFee
|
40 |
+
extends TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_feeType = TIG_PostNL_Helper_DeliveryOptions_fee::FEE_TYPE_SAMEDAY;
|
46 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee_SundayDeliveryFee
|
@@ -43,4 +43,4 @@ class TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee_SundayD
|
|
43 |
* @var string
|
44 |
*/
|
45 |
protected $_feeType = TIG_PostNL_Helper_DeliveryOptions_fee::FEE_TYPE_SUNDAY;
|
46 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee_SundayDeliveryFee
|
43 |
* @var string
|
44 |
*/
|
45 |
protected $_feeType = TIG_PostNL_Helper_DeliveryOptions_fee::FEE_TYPE_SUNDAY;
|
46 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_System_Config_Source_DeliveryDaysNumber
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_System_Config_Source_DeliveryDaysNumber
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_System_Config_Source_StockOptions
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_System_Config_Source_StockOptions
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_System_Config_Source_Themes extends Varien_Object
|
@@ -58,6 +58,7 @@ class TIG_PostNL_Model_DeliveryOptions_System_Config_Source_Themes extends Varie
|
|
58 |
foreach ($config->children() as $name => $child) {
|
59 |
$child = $this->_translateConfig($child);
|
60 |
|
|
|
61 |
$themes[] = array(
|
62 |
'label' => (string) $child->label,
|
63 |
'value' => $name,
|
@@ -108,4 +109,4 @@ class TIG_PostNL_Model_DeliveryOptions_System_Config_Source_Themes extends Varie
|
|
108 |
|
109 |
return $config;
|
110 |
}
|
111 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_DeliveryOptions_System_Config_Source_Themes extends Varien_Object
|
58 |
foreach ($config->children() as $name => $child) {
|
59 |
$child = $this->_translateConfig($child);
|
60 |
|
61 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
62 |
$themes[] = array(
|
63 |
'label' => (string) $child->label,
|
64 |
'value' => $name,
|
109 |
|
110 |
return $config;
|
111 |
}
|
112 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_ExtensionControl_Config
|
@@ -142,6 +142,7 @@ class TIG_PostNL_Model_ExtensionControl_Config
|
|
142 |
);
|
143 |
}
|
144 |
|
|
|
145 |
$configData = Mage::getModel('core/config_data')
|
146 |
->load($xpath, 'path');
|
147 |
|
@@ -151,4 +152,4 @@ class TIG_PostNL_Model_ExtensionControl_Config
|
|
151 |
|
152 |
return $this;
|
153 |
}
|
154 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_ExtensionControl_Config
|
142 |
);
|
143 |
}
|
144 |
|
145 |
+
/** @var Mage_Core_Model_Config_Data $configData */
|
146 |
$configData = Mage::getModel('core/config_data')
|
147 |
->load($xpath, 'path');
|
148 |
|
152 |
|
153 |
return $this;
|
154 |
}
|
155 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_ExtensionControl_Feed extends Mage_AdminNotification_Model_Feed
|
@@ -99,7 +99,9 @@ class TIG_PostNL_Model_ExtensionControl_Feed extends Mage_AdminNotification_Mode
|
|
99 |
|
100 |
$feedXml = $this->getFeedData();
|
101 |
|
|
|
102 |
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
|
|
|
103 |
foreach ($feedXml->channel->item as $item) {
|
104 |
$feedData[] = array(
|
105 |
'severity' => (int) $item->severity,
|
@@ -111,7 +113,9 @@ class TIG_PostNL_Model_ExtensionControl_Feed extends Mage_AdminNotification_Mode
|
|
111 |
}
|
112 |
|
113 |
if ($feedData) {
|
114 |
-
|
|
|
|
|
115 |
}
|
116 |
|
117 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_ExtensionControl_Feed extends Mage_AdminNotification_Model_Feed
|
99 |
|
100 |
$feedXml = $this->getFeedData();
|
101 |
|
102 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
103 |
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
|
104 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
105 |
foreach ($feedXml->channel->item as $item) {
|
106 |
$feedData[] = array(
|
107 |
'severity' => (int) $item->severity,
|
113 |
}
|
114 |
|
115 |
if ($feedData) {
|
116 |
+
/** @var Mage_AdminNotification_Model_Inbox $inbox */
|
117 |
+
$inbox = Mage::getModel('adminnotification/inbox');
|
118 |
+
$inbox->parse(array_reverse($feedData));
|
119 |
}
|
120 |
|
121 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
@@ -45,7 +45,8 @@ class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
|
45 |
*/
|
46 |
public function updateStatistics()
|
47 |
{
|
48 |
-
$helper
|
|
|
49 |
|
50 |
/**
|
51 |
* Check if the PostNL module is active.
|
@@ -57,7 +58,7 @@ class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
|
57 |
/**
|
58 |
* Check if the extension may send statistics to the extension control system.
|
59 |
*/
|
60 |
-
if (
|
61 |
return $this;
|
62 |
}
|
63 |
|
@@ -69,6 +70,7 @@ class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
|
69 |
try {
|
70 |
$helper->cronLog('Updating shop statistics.');
|
71 |
|
|
|
72 |
$webservices = Mage::getModel('postnl_extensioncontrol/webservices');
|
73 |
$webservices->updateStatistics();
|
74 |
} catch (Exception $e) {
|
@@ -87,7 +89,8 @@ class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
|
87 |
*/
|
88 |
public function checkFeedUpdate()
|
89 |
{
|
90 |
-
$helper
|
|
|
91 |
|
92 |
/**
|
93 |
* Check if the PostNL module is active.
|
@@ -99,7 +102,7 @@ class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
|
99 |
/**
|
100 |
* Check if the extension may send statistics to the extension control system.
|
101 |
*/
|
102 |
-
if (
|
103 |
return $this;
|
104 |
}
|
105 |
|
@@ -110,13 +113,16 @@ class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
|
110 |
/**
|
111 |
* Get the feed.
|
112 |
*/
|
|
|
113 |
$feed = Mage::getModel('postnl_extensioncontrol/feed');
|
114 |
$feedXml = $feed->getFeedData();
|
115 |
|
116 |
/**
|
117 |
* Parse the feed.
|
118 |
*/
|
|
|
119 |
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
|
|
|
120 |
$items = (array) $feedXml->channel;
|
121 |
$items = array_reverse((array) $items['item']);
|
122 |
|
@@ -140,7 +146,9 @@ class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
|
140 |
|
141 |
$helper->cronLog('Parsing retrieved data.');
|
142 |
if ($feedData) {
|
143 |
-
|
|
|
|
|
144 |
}
|
145 |
|
146 |
}
|
@@ -159,7 +167,8 @@ class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
|
159 |
*/
|
160 |
public function updateSettings()
|
161 |
{
|
162 |
-
$helper
|
|
|
163 |
|
164 |
/**
|
165 |
* Check if the PostNL module is active.
|
@@ -176,10 +185,13 @@ class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
|
176 |
try {
|
177 |
$helper->cronLog('Updating shop config settings.');
|
178 |
|
|
|
179 |
$webservices = Mage::getModel('postnl_extensioncontrol/webservices');
|
180 |
$settings = $webservices->updateConfigSettings();
|
181 |
|
182 |
-
|
|
|
|
|
183 |
} catch (Exception $e) {
|
184 |
$helper->cronLog('An error occurred: ' . $e->getMessage());
|
185 |
$helper->logException($e);
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_ExtensionControl_Observer_Cron
|
45 |
*/
|
46 |
public function updateStatistics()
|
47 |
{
|
48 |
+
/** @var TIG_PostNL_Helper_Webservices $helper */
|
49 |
+
$helper = Mage::helper('postnl/webservices');
|
50 |
|
51 |
/**
|
52 |
* Check if the PostNL module is active.
|
58 |
/**
|
59 |
* Check if the extension may send statistics to the extension control system.
|
60 |
*/
|
61 |
+
if (!$helper->canSendStatistics()) {
|
62 |
return $this;
|
63 |
}
|
64 |
|
70 |
try {
|
71 |
$helper->cronLog('Updating shop statistics.');
|
72 |
|
73 |
+
/** @var TIG_PostNL_Model_ExtensionControl_Webservices $webservices */
|
74 |
$webservices = Mage::getModel('postnl_extensioncontrol/webservices');
|
75 |
$webservices->updateStatistics();
|
76 |
} catch (Exception $e) {
|
89 |
*/
|
90 |
public function checkFeedUpdate()
|
91 |
{
|
92 |
+
/** @var TIG_PostNL_Helper_Webservices $helper */
|
93 |
+
$helper = Mage::helper('postnl/webservices');
|
94 |
|
95 |
/**
|
96 |
* Check if the PostNL module is active.
|
102 |
/**
|
103 |
* Check if the extension may send statistics to the extension control system.
|
104 |
*/
|
105 |
+
if (!$helper->canReceiveUpdates()) {
|
106 |
return $this;
|
107 |
}
|
108 |
|
113 |
/**
|
114 |
* Get the feed.
|
115 |
*/
|
116 |
+
/** @var TIG_PostNL_Model_ExtensionControl_Feed $feed */
|
117 |
$feed = Mage::getModel('postnl_extensioncontrol/feed');
|
118 |
$feedXml = $feed->getFeedData();
|
119 |
|
120 |
/**
|
121 |
* Parse the feed.
|
122 |
*/
|
123 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
124 |
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
|
125 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
126 |
$items = (array) $feedXml->channel;
|
127 |
$items = array_reverse((array) $items['item']);
|
128 |
|
146 |
|
147 |
$helper->cronLog('Parsing retrieved data.');
|
148 |
if ($feedData) {
|
149 |
+
/** @var Mage_AdminNotification_Model_Inbox $inbox */
|
150 |
+
$inbox = Mage::getModel('adminnotification/inbox');
|
151 |
+
$inbox->parse(array_reverse($feedData));
|
152 |
}
|
153 |
|
154 |
}
|
167 |
*/
|
168 |
public function updateSettings()
|
169 |
{
|
170 |
+
/** @var TIG_PostNL_Helper_Webservices $helper */
|
171 |
+
$helper = Mage::helper('postnl/webservices');
|
172 |
|
173 |
/**
|
174 |
* Check if the PostNL module is active.
|
185 |
try {
|
186 |
$helper->cronLog('Updating shop config settings.');
|
187 |
|
188 |
+
/** @var TIG_PostNL_Model_ExtensionControl_Webservices $webservices */
|
189 |
$webservices = Mage::getModel('postnl_extensioncontrol/webservices');
|
190 |
$settings = $webservices->updateConfigSettings();
|
191 |
|
192 |
+
/** @var TIG_PostNL_Model_ExtensionControl_Config $config */
|
193 |
+
$config = Mage::getModel('postnl_extensioncontrol/config');
|
194 |
+
$config->saveConfigSettings($settings);
|
195 |
} catch (Exception $e) {
|
196 |
$helper->cronLog('An error occurred: ' . $e->getMessage());
|
197 |
$helper->logException($e);
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Primary webservices class. Contains all methods used to communicate with the extensioncontrol webservice.
|
@@ -149,7 +149,9 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
149 |
*/
|
150 |
public function updateStatistics($forceUpdate = false)
|
151 |
{
|
152 |
-
|
|
|
|
|
153 |
if ($forceUpdate !== true && !$canSendStatictics) {
|
154 |
throw new TIG_PostNL_Exception(
|
155 |
Mage::helper('postnl')->__('Unable to update statistics. This feature has been disabled.'),
|
@@ -207,7 +209,7 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
207 |
*/
|
208 |
$encryptedData = mcrypt_encrypt(
|
209 |
MCRYPT_RIJNDAEL_256,
|
210 |
-
$mcryptKey,
|
211 |
$serializedData,
|
212 |
MCRYPT_MODE_CBC,
|
213 |
$iv
|
@@ -253,7 +255,9 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
253 |
*/
|
254 |
$isActivated = Mage::getStoreConfig(self::XPATH_IS_ACTIVATED, Mage_Core_Model_App::ADMIN_STORE_ID);
|
255 |
if (!$isActivated || $isActivated == '1') {
|
256 |
-
|
|
|
|
|
257 |
}
|
258 |
|
259 |
return $result;
|
@@ -296,6 +300,7 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
296 |
*/
|
297 |
$magentoVersion = Mage::getVersion();
|
298 |
$moduleConfig = Mage::getConfig()->getModuleConfig('TIG_PostNL');
|
|
|
299 |
$moduleVersion = (string) $moduleConfig->version;
|
300 |
|
301 |
/**
|
@@ -303,7 +308,9 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
303 |
*
|
304 |
* N.B. Professional and Go editions are not supported at this time
|
305 |
*/
|
306 |
-
|
|
|
|
|
307 |
if ($isEnterprise === true) {
|
308 |
$magentoEdition = 'Enterprise';
|
309 |
} else {
|
@@ -412,14 +419,16 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
412 |
* environment.
|
413 |
*/
|
414 |
if ($website === null) {
|
415 |
-
|
|
|
|
|
416 |
return $hostName;
|
417 |
}
|
418 |
|
419 |
/**
|
420 |
* Get the website's base URL
|
421 |
*/
|
422 |
-
$baseUrl = $website->getConfig(self::XPATH_UNSECURE_BASE_URL
|
423 |
|
424 |
/**
|
425 |
* Parse the URL and get the host name
|
@@ -438,7 +447,9 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
438 |
protected function _getUniqueKey()
|
439 |
{
|
440 |
$uniqueKey = Mage::getStoreConfig(self::XPATH_EXTENSIONCONTROL_UNIQUE_KEY, Mage_Core_Model_App::ADMIN_STORE_ID);
|
441 |
-
|
|
|
|
|
442 |
|
443 |
$uniqueKey = trim($uniqueKey);
|
444 |
|
@@ -456,7 +467,9 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
456 |
self::XPATH_EXTENSIONCONTROL_PRIVATE_KEY,
|
457 |
Mage_Core_Model_App::ADMIN_STORE_ID
|
458 |
);
|
459 |
-
|
|
|
|
|
460 |
|
461 |
$privateKey = trim($privateKey);
|
462 |
|
@@ -509,11 +522,13 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
509 |
}
|
510 |
}
|
511 |
|
|
|
512 |
$resource = Mage::getSingleton('core/resource');
|
513 |
|
514 |
/**
|
515 |
* Get the shipment collection.
|
516 |
*/
|
|
|
517 |
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection');
|
518 |
$shipmentCollection->addFieldToSelect('entity_id');
|
519 |
|
@@ -541,7 +556,9 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
541 |
)
|
542 |
);
|
543 |
|
544 |
-
|
|
|
|
|
545 |
$postnlShippingMethodsRegex = '';
|
546 |
foreach ($postnlShippingMethods as $method) {
|
547 |
if ($postnlShippingMethodsRegex) {
|
@@ -638,7 +655,9 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
638 |
$lastOrder = $orderCollection->getFirstItem();
|
639 |
// @codingStandardsIgnoreEnd
|
640 |
$createdAt = $lastOrder->getCreatedAt();
|
641 |
-
|
|
|
|
|
642 |
|
643 |
return $createdAt;
|
644 |
}
|
@@ -672,7 +691,9 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
672 |
$supportedProductOptions = $website->getConfig(self::XPATH_SUPPORTED_PRODUCT_OPTIONS);
|
673 |
$supportedProductOptions = explode(',', $supportedProductOptions);
|
674 |
|
675 |
-
|
|
|
|
|
676 |
|
677 |
/**
|
678 |
* Check each global product option if it's supported.
|
@@ -724,7 +745,9 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
724 |
protected function _getCheckoutWebshopId($website)
|
725 |
{
|
726 |
$webshopId = $website->getConfig(self::XPATH_CHECKOUT_WEBSHOP_ID);
|
727 |
-
|
|
|
|
|
728 |
|
729 |
return $webshopId;
|
730 |
}
|
@@ -1012,4 +1035,44 @@ class TIG_PostNL_Model_ExtensionControl_Webservices extends TIG_PostNL_Model_Ext
|
|
1012 |
|
1013 |
return $showShippingLabel;
|
1014 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1015 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* Primary webservices class. Contains all methods used to communicate with the extensioncontrol webservice.
|
149 |
*/
|
150 |
public function updateStatistics($forceUpdate = false)
|
151 |
{
|
152 |
+
/** @var TIG_PostNL_Helper_Webservices $helper */
|
153 |
+
$helper = Mage::helper('postnl/webservices');
|
154 |
+
$canSendStatictics = $helper->canSendStatistics();
|
155 |
if ($forceUpdate !== true && !$canSendStatictics) {
|
156 |
throw new TIG_PostNL_Exception(
|
157 |
Mage::helper('postnl')->__('Unable to update statistics. This feature has been disabled.'),
|
209 |
*/
|
210 |
$encryptedData = mcrypt_encrypt(
|
211 |
MCRYPT_RIJNDAEL_256,
|
212 |
+
$this->_padKey($mcryptKey),
|
213 |
$serializedData,
|
214 |
MCRYPT_MODE_CBC,
|
215 |
$iv
|
255 |
*/
|
256 |
$isActivated = Mage::getStoreConfig(self::XPATH_IS_ACTIVATED, Mage_Core_Model_App::ADMIN_STORE_ID);
|
257 |
if (!$isActivated || $isActivated == '1') {
|
258 |
+
/** @var Mage_Core_Model_Config $config */
|
259 |
+
$config = Mage::getModel('core/config');
|
260 |
+
$config->saveConfig(self::XPATH_IS_ACTIVATED, 2);
|
261 |
}
|
262 |
|
263 |
return $result;
|
300 |
*/
|
301 |
$magentoVersion = Mage::getVersion();
|
302 |
$moduleConfig = Mage::getConfig()->getModuleConfig('TIG_PostNL');
|
303 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
304 |
$moduleVersion = (string) $moduleConfig->version;
|
305 |
|
306 |
/**
|
308 |
*
|
309 |
* N.B. Professional and Go editions are not supported at this time
|
310 |
*/
|
311 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
312 |
+
$helper = Mage::helper('postnl');
|
313 |
+
$isEnterprise = $helper->isEnterprise();
|
314 |
if ($isEnterprise === true) {
|
315 |
$magentoEdition = 'Enterprise';
|
316 |
} else {
|
419 |
* environment.
|
420 |
*/
|
421 |
if ($website === null) {
|
422 |
+
/** @var Mage_Core_Helper_Http $helper */
|
423 |
+
$helper = Mage::helper('core/http');
|
424 |
+
$hostName = $helper->getHttpHost();
|
425 |
return $hostName;
|
426 |
}
|
427 |
|
428 |
/**
|
429 |
* Get the website's base URL
|
430 |
*/
|
431 |
+
$baseUrl = $website->getConfig(self::XPATH_UNSECURE_BASE_URL);
|
432 |
|
433 |
/**
|
434 |
* Parse the URL and get the host name
|
447 |
protected function _getUniqueKey()
|
448 |
{
|
449 |
$uniqueKey = Mage::getStoreConfig(self::XPATH_EXTENSIONCONTROL_UNIQUE_KEY, Mage_Core_Model_App::ADMIN_STORE_ID);
|
450 |
+
/** @var Mage_Core_Helper_Data $helper */
|
451 |
+
$helper = Mage::helper('core');
|
452 |
+
$uniqueKey = $helper->decrypt($uniqueKey);
|
453 |
|
454 |
$uniqueKey = trim($uniqueKey);
|
455 |
|
467 |
self::XPATH_EXTENSIONCONTROL_PRIVATE_KEY,
|
468 |
Mage_Core_Model_App::ADMIN_STORE_ID
|
469 |
);
|
470 |
+
/** @var Mage_Core_Helper_Data $helper */
|
471 |
+
$helper = Mage::helper('core');
|
472 |
+
$privateKey = $helper->decrypt($privateKey);
|
473 |
|
474 |
$privateKey = trim($privateKey);
|
475 |
|
522 |
}
|
523 |
}
|
524 |
|
525 |
+
/** @var Mage_Core_Model_Resource $resource */
|
526 |
$resource = Mage::getSingleton('core/resource');
|
527 |
|
528 |
/**
|
529 |
* Get the shipment collection.
|
530 |
*/
|
531 |
+
/** @var Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection */
|
532 |
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection');
|
533 |
$shipmentCollection->addFieldToSelect('entity_id');
|
534 |
|
556 |
)
|
557 |
);
|
558 |
|
559 |
+
/** @var TIG_PostNL_Helper_Carrier $helper */
|
560 |
+
$helper = Mage::helper('postnl/carrier');
|
561 |
+
$postnlShippingMethods = $helper->getPostnlShippingMethods();
|
562 |
$postnlShippingMethodsRegex = '';
|
563 |
foreach ($postnlShippingMethods as $method) {
|
564 |
if ($postnlShippingMethodsRegex) {
|
655 |
$lastOrder = $orderCollection->getFirstItem();
|
656 |
// @codingStandardsIgnoreEnd
|
657 |
$createdAt = $lastOrder->getCreatedAt();
|
658 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
659 |
+
$dateModel = Mage::getModel('core/date');
|
660 |
+
$createdAt = $dateModel->date('Y-m-d H:i:s', $createdAt);
|
661 |
|
662 |
return $createdAt;
|
663 |
}
|
691 |
$supportedProductOptions = $website->getConfig(self::XPATH_SUPPORTED_PRODUCT_OPTIONS);
|
692 |
$supportedProductOptions = explode(',', $supportedProductOptions);
|
693 |
|
694 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
695 |
+
$helper = Mage::helper('postnl/cif');
|
696 |
+
$globalProductOptions = $helper->getGlobalProductCodes();
|
697 |
|
698 |
/**
|
699 |
* Check each global product option if it's supported.
|
745 |
protected function _getCheckoutWebshopId($website)
|
746 |
{
|
747 |
$webshopId = $website->getConfig(self::XPATH_CHECKOUT_WEBSHOP_ID);
|
748 |
+
/** @var Mage_Core_Helper_Data $helper */
|
749 |
+
$helper = Mage::helper('core');
|
750 |
+
$webshopId = $helper->decrypt($webshopId);
|
751 |
|
752 |
return $webshopId;
|
753 |
}
|
1035 |
|
1036 |
return $showShippingLabel;
|
1037 |
}
|
1038 |
+
|
1039 |
+
/**
|
1040 |
+
* Pad the mcrypt key with zeros. Before PHP 5.6 this was the default. This is to provide backwards compatibility.
|
1041 |
+
*
|
1042 |
+
* @param $key
|
1043 |
+
*
|
1044 |
+
* @return bool|string
|
1045 |
+
*/
|
1046 |
+
protected function _padKey($key){
|
1047 |
+
if(strlen($key) > 32) {
|
1048 |
+
return $key;
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
/**
|
1052 |
+
* Valid key sizes.
|
1053 |
+
*/
|
1054 |
+
$sizes = array(
|
1055 |
+
16,
|
1056 |
+
24,
|
1057 |
+
32
|
1058 |
+
);
|
1059 |
+
|
1060 |
+
/**
|
1061 |
+
* loop through sizes and pad key
|
1062 |
+
*/
|
1063 |
+
foreach($sizes as $s) {
|
1064 |
+
while(strlen($key) < $s) {
|
1065 |
+
$key = $key."\0";
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
/**
|
1069 |
+
* Finish if the key matches a size
|
1070 |
+
*/
|
1071 |
+
if(strlen($key) == $s) {
|
1072 |
+
break;
|
1073 |
+
}
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
return $key;
|
1077 |
+
}
|
1078 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_ExtensionControl_Webservices_Abstract extends Varien_Object
|
@@ -134,13 +134,17 @@ abstract class TIG_PostNL_Model_ExtensionControl_Webservices_Abstract extends Va
|
|
134 |
$response = $client->$method();
|
135 |
}
|
136 |
|
137 |
-
|
|
|
|
|
138 |
return $response;
|
139 |
} catch(SoapFault $e) {
|
140 |
/**
|
141 |
* Only Soap exceptions are caught. Other exceptions must be caught by the caller.
|
142 |
*/
|
143 |
-
|
|
|
|
|
144 |
|
145 |
throw $e;
|
146 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_ExtensionControl_Webservices_Abstract extends Varien_Object
|
134 |
$response = $client->$method();
|
135 |
}
|
136 |
|
137 |
+
/** @var TIG_PostNL_Helper_Webservices $helper */
|
138 |
+
$helper = Mage::helper('postnl/webservices');
|
139 |
+
$helper->logWebserviceCall($client);
|
140 |
return $response;
|
141 |
} catch(SoapFault $e) {
|
142 |
/**
|
143 |
* Only Soap exceptions are caught. Other exceptions must be caught by the caller.
|
144 |
*/
|
145 |
+
/** @var TIG_PostNL_Helper_Webservices $helper */
|
146 |
+
$helper = Mage::helper('postnl/webservices');
|
147 |
+
$helper->logWebserviceException($e);
|
148 |
|
149 |
throw $e;
|
150 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated 1.3.0 This class has been moved to TIG_PostNL_Model_Admin_Inbox. A dummy class has been left behind to
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @deprecated 1.3.0 This class has been moved to TIG_PostNL_Model_Admin_Inbox. A dummy class has been left behind to
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Mijnpakket_Cif extends TIG_PostNL_Model_Checkout_Cif
|
@@ -72,4 +72,4 @@ class TIG_PostNL_Model_Mijnpakket_Cif extends TIG_PostNL_Model_Checkout_Cif
|
|
72 |
|
73 |
return $response;
|
74 |
}
|
75 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Mijnpakket_Cif extends TIG_PostNL_Model_Checkout_Cif
|
72 |
|
73 |
return $response;
|
74 |
}
|
75 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Mijnpakket_Service extends Varien_Object
|
@@ -73,4 +73,4 @@ class TIG_PostNL_Model_Mijnpakket_Service extends Varien_Object
|
|
73 |
|
74 |
return $billingData;
|
75 |
}
|
76 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Mijnpakket_Service extends Varien_Object
|
73 |
|
74 |
return $billingData;
|
75 |
}
|
76 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Parcelware_Export setIsGlobal(boolean $value)
|
@@ -48,6 +48,11 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
48 |
const XPATH_CONTRACT_NAME = 'postnl/parcelware_export/contract_name';
|
49 |
const XPATH_SENDER_REF_NR = 'postnl/parcelware_export/sender_ref_nr';
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
/**
|
52 |
* @var Mage_Core_Model_Resource_Transaction|void
|
53 |
*/
|
@@ -116,6 +121,7 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
116 |
/**
|
117 |
* Prepare to create a new export file.
|
118 |
*/
|
|
|
119 |
$io = Mage::getModel('varien/io_file');
|
120 |
|
121 |
/**
|
@@ -137,16 +143,16 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
137 |
/**
|
138 |
* Write the CSV headers and then each row of data.
|
139 |
*/
|
140 |
-
$io->streamWrite(implode(
|
141 |
foreach ($content as $item) {
|
142 |
/**
|
143 |
-
* Remove any comma's as these will break Parcelware's import.
|
144 |
*/
|
145 |
foreach ($item as &$value) {
|
146 |
-
$value = str_replace(',', '', $value);
|
147 |
}
|
148 |
|
149 |
-
$io->streamWrite(PHP_EOL . implode(
|
150 |
}
|
151 |
|
152 |
/**
|
@@ -175,6 +181,7 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
175 |
*/
|
176 |
public function getCsvData($postnlShipments)
|
177 |
{
|
|
|
178 |
$helper = Mage::helper('postnl/parcelware');
|
179 |
$autoConfirmEnabled = $helper->isAutoConfirmEnabled();
|
180 |
|
@@ -244,6 +251,7 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
244 |
*/
|
245 |
protected function _getShipmentData($postnlShipment, $parcelCount = false, $count = false)
|
246 |
{
|
|
|
247 |
$helper = Mage::helper('postnl/parcelware');
|
248 |
|
249 |
/**
|
@@ -259,7 +267,7 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
259 |
$addressData = $this->_getAddressData($shipment);
|
260 |
$addressData['SMSnr'] = $this->_getMobilePhoneNumber($postnlShipment);
|
261 |
|
262 |
-
$pakjeGemakData = $this->_getPakjeGemakAddressData($postnlShipment
|
263 |
$referenceData = $this->_getReferenceData();
|
264 |
$extraCover = array($postnlShipment->getExtraCoverAmount());
|
265 |
$productOptions = $this->_getProductOptions($postnlShipment);
|
@@ -267,7 +275,9 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
267 |
/**
|
268 |
* Get the current GMT timestamp as a point of reference
|
269 |
*/
|
270 |
-
$
|
|
|
|
|
271 |
|
272 |
/**
|
273 |
* Get the confirm and delivery dates for this shipment
|
@@ -478,7 +488,9 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
478 |
{
|
479 |
$productCode = $postnlShipment->getProductCode();
|
480 |
|
481 |
-
|
|
|
|
|
482 |
if (in_array($productCode, $combiLabelProductCodes)) {
|
483 |
$productCode = array_search($productCode, $combiLabelProductCodes);
|
484 |
}
|
@@ -550,8 +562,10 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
550 |
* Add information about the contents of the shipment
|
551 |
*/
|
552 |
$itemCount = 0;
|
|
|
553 |
$items = $this->_sortCustomsItems($shipment->getAllItems());
|
554 |
|
|
|
555 |
$helper = Mage::helper('postnl');
|
556 |
|
557 |
/**
|
@@ -605,7 +619,9 @@ class TIG_PostNL_Model_Parcelware_Export extends TIG_PostNL_Model_Core_Cif
|
|
605 |
protected function _getParcelwareShipmentType(TIG_PostnL_Model_Core_Shipment $postnlShipment)
|
606 |
{
|
607 |
$shipmentType = $postnlShipment->getGlobalpackShipmentType();
|
608 |
-
|
|
|
|
|
609 |
|
610 |
if (array_key_exists($shipmentType, $numericShipmentTypes)) {
|
611 |
$shipmentType = $numericShipmentTypes[$shipmentType];
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method TIG_PostNL_Model_Parcelware_Export setIsGlobal(boolean $value)
|
48 |
const XPATH_CONTRACT_NAME = 'postnl/parcelware_export/contract_name';
|
49 |
const XPATH_SENDER_REF_NR = 'postnl/parcelware_export/sender_ref_nr';
|
50 |
|
51 |
+
/**
|
52 |
+
* The separator used for the Parcelware export.
|
53 |
+
*/
|
54 |
+
const CSV_SEPARATOR = ';';
|
55 |
+
|
56 |
/**
|
57 |
* @var Mage_Core_Model_Resource_Transaction|void
|
58 |
*/
|
121 |
/**
|
122 |
* Prepare to create a new export file.
|
123 |
*/
|
124 |
+
/** @var Varien_Io_File $io */
|
125 |
$io = Mage::getModel('varien/io_file');
|
126 |
|
127 |
/**
|
143 |
/**
|
144 |
* Write the CSV headers and then each row of data.
|
145 |
*/
|
146 |
+
$io->streamWrite(implode(self::CSV_SEPARATOR, $csvHeaders));
|
147 |
foreach ($content as $item) {
|
148 |
/**
|
149 |
+
* Remove any comma's and semicolon as these will break Parcelware's import.
|
150 |
*/
|
151 |
foreach ($item as &$value) {
|
152 |
+
$value = str_replace(array(',', self::CSV_SEPARATOR), '', $value);
|
153 |
}
|
154 |
|
155 |
+
$io->streamWrite(PHP_EOL . implode(self::CSV_SEPARATOR, $item));
|
156 |
}
|
157 |
|
158 |
/**
|
181 |
*/
|
182 |
public function getCsvData($postnlShipments)
|
183 |
{
|
184 |
+
/** @var TIG_PostNL_Helper_Parcelware $helper */
|
185 |
$helper = Mage::helper('postnl/parcelware');
|
186 |
$autoConfirmEnabled = $helper->isAutoConfirmEnabled();
|
187 |
|
251 |
*/
|
252 |
protected function _getShipmentData($postnlShipment, $parcelCount = false, $count = false)
|
253 |
{
|
254 |
+
/** @var TIG_PostNL_Helper_Parcelware $helper */
|
255 |
$helper = Mage::helper('postnl/parcelware');
|
256 |
|
257 |
/**
|
267 |
$addressData = $this->_getAddressData($shipment);
|
268 |
$addressData['SMSnr'] = $this->_getMobilePhoneNumber($postnlShipment);
|
269 |
|
270 |
+
$pakjeGemakData = $this->_getPakjeGemakAddressData($postnlShipment);
|
271 |
$referenceData = $this->_getReferenceData();
|
272 |
$extraCover = array($postnlShipment->getExtraCoverAmount());
|
273 |
$productOptions = $this->_getProductOptions($postnlShipment);
|
275 |
/**
|
276 |
* Get the current GMT timestamp as a point of reference
|
277 |
*/
|
278 |
+
/** @var Mage_Core_Model_Date $dateModel */
|
279 |
+
$dateModel = Mage::getModel('core/date');
|
280 |
+
$now = $dateModel->gmtTimestamp();
|
281 |
|
282 |
/**
|
283 |
* Get the confirm and delivery dates for this shipment
|
488 |
{
|
489 |
$productCode = $postnlShipment->getProductCode();
|
490 |
|
491 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
492 |
+
$helper = Mage::helper('postnl/cif');
|
493 |
+
$combiLabelProductCodes = $helper->getCombiLabelProductCodes();
|
494 |
if (in_array($productCode, $combiLabelProductCodes)) {
|
495 |
$productCode = array_search($productCode, $combiLabelProductCodes);
|
496 |
}
|
562 |
* Add information about the contents of the shipment
|
563 |
*/
|
564 |
$itemCount = 0;
|
565 |
+
/** @noinspection PhpParamsInspection */
|
566 |
$items = $this->_sortCustomsItems($shipment->getAllItems());
|
567 |
|
568 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
569 |
$helper = Mage::helper('postnl');
|
570 |
|
571 |
/**
|
619 |
protected function _getParcelwareShipmentType(TIG_PostnL_Model_Core_Shipment $postnlShipment)
|
620 |
{
|
621 |
$shipmentType = $postnlShipment->getGlobalpackShipmentType();
|
622 |
+
/** @var TIG_PostNL_Helper_Cif $helper */
|
623 |
+
$helper = Mage::helper('postnl/cif');
|
624 |
+
$numericShipmentTypes = $helper->getNumericShipmentTypes();
|
625 |
|
626 |
if (array_key_exists($shipmentType, $numericShipmentTypes)) {
|
627 |
$shipmentType = $numericShipmentTypes[$shipmentType];
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Cod extends Mage_Payment_Model_Method_Abstract
|
@@ -181,6 +181,7 @@ class TIG_PostNL_Model_Payment_Cod extends Mage_Payment_Model_Method_Abstract
|
|
181 |
*/
|
182 |
public function isAvailable($quote = null)
|
183 |
{
|
|
|
184 |
$helper = Mage::helper('postnl/payment');
|
185 |
|
186 |
/**
|
@@ -193,6 +194,13 @@ class TIG_PostNL_Model_Payment_Cod extends Mage_Payment_Model_Method_Abstract
|
|
193 |
return false;
|
194 |
}
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
/**
|
197 |
* COD is not available for virtual shipments.
|
198 |
*/
|
@@ -203,13 +211,29 @@ class TIG_PostNL_Model_Payment_Cod extends Mage_Payment_Model_Method_Abstract
|
|
203 |
return false;
|
204 |
}
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
/**
|
207 |
* If COD is only available for PostNL shipping methods, we need to check if the shipping method is PostNL.
|
208 |
*/
|
209 |
if (!(bool) $this->getConfigData('allow_for_non_postnl', $quote->getStoreId())) {
|
210 |
$shippingMethod = $quote->getShippingAddress()->getShippingMethod();
|
211 |
|
212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
$helper->log(
|
214 |
$helper->__('PostNL COD is not available, because the chosen shipping method is not PostNL.')
|
215 |
);
|
@@ -258,6 +282,7 @@ class TIG_PostNL_Model_Payment_Cod extends Mage_Payment_Model_Method_Abstract
|
|
258 |
/**
|
259 |
* Check if the delivery type is not a Sunday Delivery, since COD is not available for Sunday delivery
|
260 |
*/
|
|
|
261 |
$postnlOrder = Mage::getModel('postnl_core/order')->load($quote->getId(), 'quote_id');
|
262 |
if ($postnlOrder->getType() == 'Sunday') {
|
263 |
$helper->log(
|
@@ -350,7 +375,10 @@ class TIG_PostNL_Model_Payment_Cod extends Mage_Payment_Model_Method_Abstract
|
|
350 |
{
|
351 |
$title = parent::getTitle();
|
352 |
|
353 |
-
|
|
|
|
|
|
|
354 |
$adminSession = Mage::getSingleton('adminhtml/session_quote');
|
355 |
if ($adminSession && $adminSession->getStore() !== null) {
|
356 |
$store = $adminSession->getStore();
|
@@ -358,6 +386,7 @@ class TIG_PostNL_Model_Payment_Cod extends Mage_Payment_Model_Method_Abstract
|
|
358 |
$store = Mage::app()->getStore();
|
359 |
}
|
360 |
} else {
|
|
|
361 |
$checkoutSession = Mage::getSingleton('checkout/session');
|
362 |
if ($checkoutSession && $checkoutSession->getQuote()) {
|
363 |
$store = $checkoutSession->getQuote()->getStore();
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Cod extends Mage_Payment_Model_Method_Abstract
|
181 |
*/
|
182 |
public function isAvailable($quote = null)
|
183 |
{
|
184 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
185 |
$helper = Mage::helper('postnl/payment');
|
186 |
|
187 |
/**
|
194 |
return false;
|
195 |
}
|
196 |
|
197 |
+
/**
|
198 |
+
* Check if this payment method is active.
|
199 |
+
*/
|
200 |
+
if (!(bool)$this->getConfigData('active', $quote->getStoreId())) {
|
201 |
+
return false;
|
202 |
+
}
|
203 |
+
|
204 |
/**
|
205 |
* COD is not available for virtual shipments.
|
206 |
*/
|
211 |
return false;
|
212 |
}
|
213 |
|
214 |
+
/**
|
215 |
+
* COD is not available for Food shipments.
|
216 |
+
*/
|
217 |
+
if ($helper->quoteIsFood($quote)) {
|
218 |
+
return false;
|
219 |
+
}
|
220 |
+
|
221 |
/**
|
222 |
* If COD is only available for PostNL shipping methods, we need to check if the shipping method is PostNL.
|
223 |
*/
|
224 |
if (!(bool) $this->getConfigData('allow_for_non_postnl', $quote->getStoreId())) {
|
225 |
$shippingMethod = $quote->getShippingAddress()->getShippingMethod();
|
226 |
|
227 |
+
/**
|
228 |
+
* If the shipping method is not set, we won't check it.
|
229 |
+
*/
|
230 |
+
if ($shippingMethod === null) {
|
231 |
+
return false;
|
232 |
+
}
|
233 |
+
|
234 |
+
/** @var TIG_PostNL_Helper_Carrier $carrierHelper */
|
235 |
+
$carrierHelper = Mage::helper('postnl/carrier');
|
236 |
+
if (!$carrierHelper->isPostnlShippingMethod($shippingMethod)) {
|
237 |
$helper->log(
|
238 |
$helper->__('PostNL COD is not available, because the chosen shipping method is not PostNL.')
|
239 |
);
|
282 |
/**
|
283 |
* Check if the delivery type is not a Sunday Delivery, since COD is not available for Sunday delivery
|
284 |
*/
|
285 |
+
/** @var TIG_PostNL_Model_Core_Order $postnlOrder */
|
286 |
$postnlOrder = Mage::getModel('postnl_core/order')->load($quote->getId(), 'quote_id');
|
287 |
if ($postnlOrder->getType() == 'Sunday') {
|
288 |
$helper->log(
|
375 |
{
|
376 |
$title = parent::getTitle();
|
377 |
|
378 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
379 |
+
$helper = Mage::helper('postnl');
|
380 |
+
if ($helper->isAdmin()) {
|
381 |
+
/** @var Mage_Adminhtml_Model_Session_Quote $adminSession */
|
382 |
$adminSession = Mage::getSingleton('adminhtml/session_quote');
|
383 |
if ($adminSession && $adminSession->getStore() !== null) {
|
384 |
$store = $adminSession->getStore();
|
386 |
$store = Mage::app()->getStore();
|
387 |
}
|
388 |
} else {
|
389 |
+
/** @var Mage_Checkout_Model_Session $checkoutSession */
|
390 |
$checkoutSession = Mage::getSingleton('checkout/session');
|
391 |
if ($checkoutSession && $checkoutSession->getQuote()) {
|
392 |
$store = $checkoutSession->getQuote()->getStore();
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Observer_Cod
|
@@ -59,6 +59,7 @@ class TIG_PostNL_Model_Payment_Observer_Cod
|
|
59 |
/**
|
60 |
* @var TIG_PostNL_Model_Core_Shipment $shipment
|
61 |
*/
|
|
|
62 |
$shipment = $observer->getShipment();
|
63 |
|
64 |
/**
|
@@ -81,6 +82,7 @@ class TIG_PostNL_Model_Payment_Observer_Cod
|
|
81 |
*/
|
82 |
$paymentMethod = $order->getPayment()->getMethod();
|
83 |
|
|
|
84 |
$helper = Mage::helper('postnl/payment');
|
85 |
$codPaymentMethods = $helper->getCodPaymentMethods();
|
86 |
if (!in_array($paymentMethod, $codPaymentMethods)) {
|
@@ -96,7 +98,9 @@ class TIG_PostNL_Model_Payment_Observer_Cod
|
|
96 |
}
|
97 |
|
98 |
try {
|
99 |
-
|
|
|
|
|
100 |
$order->addStatusHistoryComment(
|
101 |
$helper->__("This order has been automatically invoiced by the PostNL COD payment method.")
|
102 |
);
|
@@ -128,14 +132,16 @@ class TIG_PostNL_Model_Payment_Observer_Cod
|
|
128 |
* @var Mage_Sales_Model_Order_Shipment $shipment
|
129 |
* @var Mage_Sales_Model_Order $order
|
130 |
*/
|
|
|
131 |
$shipment = $observer->getShipment();
|
132 |
-
$order
|
133 |
|
134 |
/**
|
135 |
* Check if the order was placed using a PostNL COD payment method.
|
136 |
*/
|
137 |
$paymentMethod = $order->getPayment()->getMethod();
|
138 |
|
|
|
139 |
$helper = Mage::helper('postnl/payment');
|
140 |
$codPaymentMethods = $helper->getCodPaymentMethods();
|
141 |
if (!in_array($paymentMethod, $codPaymentMethods)) {
|
@@ -168,4 +174,4 @@ class TIG_PostNL_Model_Payment_Observer_Cod
|
|
168 |
|
169 |
return $this;
|
170 |
}
|
171 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Observer_Cod
|
59 |
/**
|
60 |
* @var TIG_PostNL_Model_Core_Shipment $shipment
|
61 |
*/
|
62 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
63 |
$shipment = $observer->getShipment();
|
64 |
|
65 |
/**
|
82 |
*/
|
83 |
$paymentMethod = $order->getPayment()->getMethod();
|
84 |
|
85 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
86 |
$helper = Mage::helper('postnl/payment');
|
87 |
$codPaymentMethods = $helper->getCodPaymentMethods();
|
88 |
if (!in_array($paymentMethod, $codPaymentMethods)) {
|
98 |
}
|
99 |
|
100 |
try {
|
101 |
+
/** @var TIG_PostNL_Model_Core_Service $serviceModel */
|
102 |
+
$serviceModel = Mage::getModel('postnl_core/service');
|
103 |
+
$serviceModel->registerInvoiceFromShipment($shipment->getShipment());
|
104 |
$order->addStatusHistoryComment(
|
105 |
$helper->__("This order has been automatically invoiced by the PostNL COD payment method.")
|
106 |
);
|
132 |
* @var Mage_Sales_Model_Order_Shipment $shipment
|
133 |
* @var Mage_Sales_Model_Order $order
|
134 |
*/
|
135 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
136 |
$shipment = $observer->getShipment();
|
137 |
+
$order = $shipment->getOrder();
|
138 |
|
139 |
/**
|
140 |
* Check if the order was placed using a PostNL COD payment method.
|
141 |
*/
|
142 |
$paymentMethod = $order->getPayment()->getMethod();
|
143 |
|
144 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
145 |
$helper = Mage::helper('postnl/payment');
|
146 |
$codPaymentMethods = $helper->getCodPaymentMethods();
|
147 |
if (!in_array($paymentMethod, $codPaymentMethods)) {
|
174 |
|
175 |
return $this;
|
176 |
}
|
177 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee
|
@@ -57,7 +57,9 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee
|
|
57 |
{
|
58 |
$order = $creditmemo->getOrder();
|
59 |
|
|
|
60 |
$fee = $creditmemo->getPostnlCodFee();
|
|
|
61 |
$baseFee = $creditmemo->getBasePostnlCodFee();
|
62 |
|
63 |
/**
|
@@ -74,7 +76,11 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee
|
|
74 |
* If we are currently in the backend and logged in, we need to check the POST parameters to see if any fee
|
75 |
* amount is to be refunded.
|
76 |
*/
|
77 |
-
|
|
|
|
|
|
|
|
|
78 |
/**
|
79 |
* This is unfortunately the only way to determine the fee amount that needs to be refunded without
|
80 |
* rewriting a core class. If anybody knows of a better way, please let us know at
|
@@ -97,7 +103,9 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee
|
|
97 |
* If none of the above are true, we are creating a new creditmemo and need to show the fee amounts that may be
|
98 |
* refunded (if any).
|
99 |
*/
|
|
|
100 |
$fee = $order->getPostnlCodFee() - $order->getPostnlCodFeeRefunded();
|
|
|
101 |
$baseFee = $order->getBasePostnlCodFee() - $order->getBasePostnlCodFeeRefunded();
|
102 |
|
103 |
if ($fee && $baseFee) {
|
@@ -120,11 +128,13 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee
|
|
120 |
protected function _updateCreditmemoTotals(Mage_Sales_Model_Order_Creditmemo $creditmemo,
|
121 |
Mage_Sales_Model_Order $order, $fee, $baseFee)
|
122 |
{
|
|
|
123 |
$creditmemo->setPostnlCodFee($fee)
|
124 |
->setBasePostnlCodFee($baseFee)
|
125 |
->setGrandTotal($creditmemo->getGrandTotal() + $fee)
|
126 |
->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseFee);
|
127 |
|
|
|
128 |
$order->setPostnlCodFeeRefunded($order->getPostnlCodFeeRefunded() + $fee)
|
129 |
->setBasePostnlCodFeeRefunded($order->getBasePostnlCodFeeRefunded() + $baseFee);
|
130 |
|
@@ -160,9 +170,13 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee
|
|
160 |
/**
|
161 |
* Get the order's COD fee amounts.
|
162 |
*/
|
|
|
163 |
$orderFee = $order->getPostnlCodFee();
|
|
|
164 |
$orderFeeRefunded = $order->getPostnlCodFeeRefunded();
|
|
|
165 |
$orderBaseFee = $order->getBasePostnlCodFee();
|
|
|
166 |
$orderBaseFeeRefunded = $order->getBasePostnlCodFeeRefunded();
|
167 |
|
168 |
/**
|
@@ -196,11 +210,13 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee
|
|
196 |
/**
|
197 |
* Update the creditmemo totals with the new amounts.
|
198 |
*/
|
|
|
199 |
$creditmemo->setPostnlCodFee($fee)
|
200 |
->setBasePostnlCodFee($baseFee)
|
201 |
->setGrandTotal($creditmemo->getGrandTotal() + $fee)
|
202 |
->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseFee);
|
203 |
|
|
|
204 |
$order->setPostnlCodFeeRefunded($orderFeeRefunded + $fee)
|
205 |
->setBasePostnlCodFeeRefunded($orderBaseFeeRefunded + $baseFee);
|
206 |
|
@@ -244,4 +260,4 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee
|
|
244 |
|
245 |
return $fee;
|
246 |
}
|
247 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee
|
57 |
{
|
58 |
$order = $creditmemo->getOrder();
|
59 |
|
60 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
61 |
$fee = $creditmemo->getPostnlCodFee();
|
62 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
63 |
$baseFee = $creditmemo->getBasePostnlCodFee();
|
64 |
|
65 |
/**
|
76 |
* If we are currently in the backend and logged in, we need to check the POST parameters to see if any fee
|
77 |
* amount is to be refunded.
|
78 |
*/
|
79 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
80 |
+
$helper = Mage::helper('postnl');
|
81 |
+
/** @var Mage_Admin_Model_Session $session */
|
82 |
+
$session = Mage::getSingleton('admin/session');
|
83 |
+
if ($helper && $session->isLoggedIn()) {
|
84 |
/**
|
85 |
* This is unfortunately the only way to determine the fee amount that needs to be refunded without
|
86 |
* rewriting a core class. If anybody knows of a better way, please let us know at
|
103 |
* If none of the above are true, we are creating a new creditmemo and need to show the fee amounts that may be
|
104 |
* refunded (if any).
|
105 |
*/
|
106 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
107 |
$fee = $order->getPostnlCodFee() - $order->getPostnlCodFeeRefunded();
|
108 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
109 |
$baseFee = $order->getBasePostnlCodFee() - $order->getBasePostnlCodFeeRefunded();
|
110 |
|
111 |
if ($fee && $baseFee) {
|
128 |
protected function _updateCreditmemoTotals(Mage_Sales_Model_Order_Creditmemo $creditmemo,
|
129 |
Mage_Sales_Model_Order $order, $fee, $baseFee)
|
130 |
{
|
131 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
132 |
$creditmemo->setPostnlCodFee($fee)
|
133 |
->setBasePostnlCodFee($baseFee)
|
134 |
->setGrandTotal($creditmemo->getGrandTotal() + $fee)
|
135 |
->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseFee);
|
136 |
|
137 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
138 |
$order->setPostnlCodFeeRefunded($order->getPostnlCodFeeRefunded() + $fee)
|
139 |
->setBasePostnlCodFeeRefunded($order->getBasePostnlCodFeeRefunded() + $baseFee);
|
140 |
|
170 |
/**
|
171 |
* Get the order's COD fee amounts.
|
172 |
*/
|
173 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
174 |
$orderFee = $order->getPostnlCodFee();
|
175 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
176 |
$orderFeeRefunded = $order->getPostnlCodFeeRefunded();
|
177 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
178 |
$orderBaseFee = $order->getBasePostnlCodFee();
|
179 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
180 |
$orderBaseFeeRefunded = $order->getBasePostnlCodFeeRefunded();
|
181 |
|
182 |
/**
|
210 |
/**
|
211 |
* Update the creditmemo totals with the new amounts.
|
212 |
*/
|
213 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
214 |
$creditmemo->setPostnlCodFee($fee)
|
215 |
->setBasePostnlCodFee($baseFee)
|
216 |
->setGrandTotal($creditmemo->getGrandTotal() + $fee)
|
217 |
->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseFee);
|
218 |
|
219 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
220 |
$order->setPostnlCodFeeRefunded($orderFeeRefunded + $fee)
|
221 |
->setBasePostnlCodFeeRefunded($orderBaseFeeRefunded + $baseFee);
|
222 |
|
260 |
|
261 |
return $fee;
|
262 |
}
|
263 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee_Abstract
|
@@ -54,6 +54,11 @@ abstract class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee_Abstract
|
|
54 |
*/
|
55 |
const XPATH_COD_FEE_INCLUDING_TAX = 'tax/calculation/postnl_cod_fee_including_tax';
|
56 |
|
|
|
|
|
|
|
|
|
|
|
57 |
/**
|
58 |
* @return Mage_Tax_Model_Calculation
|
59 |
*/
|
@@ -64,6 +69,7 @@ abstract class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee_Abstract
|
|
64 |
return $taxCalculation;
|
65 |
}
|
66 |
|
|
|
67 |
$taxCalculation = Mage::getSingleton('tax/calculation');
|
68 |
|
69 |
$this->setTaxCalculation($taxCalculation);
|
@@ -122,6 +128,7 @@ abstract class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee_Abstract
|
|
122 |
}
|
123 |
|
124 |
$taxCalculation = $this->getTaxCalculation();
|
|
|
125 |
$customerTaxClass = $order->getCustomerTaxClassId();
|
126 |
$shippingAddress = $order->getShippingAddress();
|
127 |
$billingAddress = $order->getBillingAddress();
|
@@ -133,6 +140,7 @@ abstract class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee_Abstract
|
|
133 |
$store
|
134 |
);
|
135 |
|
|
|
136 |
$request->setProductClassId($codTaxClass);
|
137 |
|
138 |
return $request;
|
@@ -165,6 +173,7 @@ abstract class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee_Abstract
|
|
165 |
protected function _getCodFeeTax($address, $taxRate, $fee = null, $isInclTax = false)
|
166 |
{
|
167 |
if (is_null($fee)) {
|
|
|
168 |
$fee = (float) $address->getPostnlCodFee();
|
169 |
}
|
170 |
|
@@ -193,6 +202,7 @@ abstract class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee_Abstract
|
|
193 |
protected function _getBaseCodFeeTax($address, $taxRate, $fee = null, $isInclTax = false)
|
194 |
{
|
195 |
if (is_null($fee)) {
|
|
|
196 |
$fee = (float) $address->getBasePostnlCodFee();
|
197 |
}
|
198 |
|
@@ -207,4 +217,4 @@ abstract class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee_Abstract
|
|
207 |
|
208 |
return $baseFeeTax;
|
209 |
}
|
210 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFee_Abstract
|
54 |
*/
|
55 |
const XPATH_COD_FEE_INCLUDING_TAX = 'tax/calculation/postnl_cod_fee_including_tax';
|
56 |
|
57 |
+
/**
|
58 |
+
* @var Mage_Tax_Model_Calculation
|
59 |
+
*/
|
60 |
+
protected $_calculator;
|
61 |
+
|
62 |
/**
|
63 |
* @return Mage_Tax_Model_Calculation
|
64 |
*/
|
69 |
return $taxCalculation;
|
70 |
}
|
71 |
|
72 |
+
/** @var Mage_Tax_Model_Calculation $taxCalculation */
|
73 |
$taxCalculation = Mage::getSingleton('tax/calculation');
|
74 |
|
75 |
$this->setTaxCalculation($taxCalculation);
|
128 |
}
|
129 |
|
130 |
$taxCalculation = $this->getTaxCalculation();
|
131 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
132 |
$customerTaxClass = $order->getCustomerTaxClassId();
|
133 |
$shippingAddress = $order->getShippingAddress();
|
134 |
$billingAddress = $order->getBillingAddress();
|
140 |
$store
|
141 |
);
|
142 |
|
143 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
144 |
$request->setProductClassId($codTaxClass);
|
145 |
|
146 |
return $request;
|
173 |
protected function _getCodFeeTax($address, $taxRate, $fee = null, $isInclTax = false)
|
174 |
{
|
175 |
if (is_null($fee)) {
|
176 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
177 |
$fee = (float) $address->getPostnlCodFee();
|
178 |
}
|
179 |
|
202 |
protected function _getBaseCodFeeTax($address, $taxRate, $fee = null, $isInclTax = false)
|
203 |
{
|
204 |
if (is_null($fee)) {
|
205 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
206 |
$fee = (float) $address->getBasePostnlCodFee();
|
207 |
}
|
208 |
|
217 |
|
218 |
return $baseFeeTax;
|
219 |
}
|
220 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFeeTax
|
@@ -50,13 +50,16 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFeeTax
|
|
50 |
{
|
51 |
$order = $creditmemo->getOrder();
|
52 |
|
|
|
53 |
$feeTax = $creditmemo->getPostnlCodFeeTax();
|
|
|
54 |
$baseFeeTax = $creditmemo->getBasePostnlCodFeeTax();
|
55 |
|
56 |
/**
|
57 |
* If a creditmemo already has a fee tax, we only need to update the totals.
|
58 |
*/
|
59 |
if ($feeTax && $baseFeeTax) {
|
|
|
60 |
$creditmemo->setPostnlCodFeeTax($feeTax)
|
61 |
->setBasePostnlCodFeeTax($baseFeeTax)
|
62 |
->setTaxAmount($creditmemo->getTaxAmount() + $feeTax)
|
@@ -64,6 +67,7 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFeeTax
|
|
64 |
->setGrandTotal($creditmemo->getGrandTotal() + $feeTax)
|
65 |
->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseFeeTax);
|
66 |
|
|
|
67 |
$order->setPostnlCodFeeTaxRefunded($order->getPostnlCodFeeTaxRefunded() + $feeTax)
|
68 |
->setBasePostnlCodFeeTaxRefunded($order->getBasePostnlCodFeeTaxRefunded() + $baseFeeTax);
|
69 |
|
@@ -73,7 +77,9 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFeeTax
|
|
73 |
/**
|
74 |
* If the creditmemo has a fee, but no fee tax, we need to calculate the fee tax.
|
75 |
*/
|
|
|
76 |
$fee = $creditmemo->getPostnlCodFee();
|
|
|
77 |
$baseFee = $creditmemo->getBasePostnlCodFee();
|
78 |
|
79 |
if ($fee && $baseFee) {
|
@@ -81,15 +87,18 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFeeTax
|
|
81 |
* First we need to determine what percentage of the fee is being refunded. We need to refund the same
|
82 |
* percentage of fee tax.
|
83 |
*/
|
|
|
84 |
$totalBaseFee = $order->getBasePostnlCodFee();
|
85 |
$ratio = $baseFee / $totalBaseFee;
|
86 |
|
87 |
/**
|
88 |
* Calculate the fee and base fee tax based on the same ratio.
|
89 |
*/
|
|
|
90 |
$totalBaseFeeTax = $order->getBasePostnlCodFeeTax();
|
91 |
$baseFeeTax = $totalBaseFeeTax * $ratio;
|
92 |
|
|
|
93 |
$totalFeeTax = $order->getPostnlCodFeeTax();
|
94 |
$feeTax = $totalFeeTax * $ratio;
|
95 |
|
@@ -97,20 +106,26 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFeeTax
|
|
97 |
* If the total amount refunded exceeds the available fee tax amount, we have a rounding error. Modify the
|
98 |
* fee tax amounts accordingly.
|
99 |
*/
|
|
|
100 |
$totalBaseFeeTax = $baseFeeTax - $order->getBasePostnlCodFeeTax()
|
101 |
- $order->getBasePostnlCodFeeTaxRefunded();
|
|
|
102 |
if ($totalBaseFeeTax < 0.0001 && $totalBaseFeeTax > -0.0001) {
|
|
|
103 |
$baseFeeTax = $order->getBasePostnlCodFeeTax() - $order->getBasePostnlCodFeeTaxRefunded();
|
104 |
}
|
105 |
|
|
|
106 |
$totalFeeTax = $feeTax - $order->getPostnlCodFeeTax() - $order->getPostnlCodFeeTaxRefunded();
|
107 |
if ($totalFeeTax < 0.0001 && $totalFeeTax > -0.0001) {
|
|
|
108 |
$feeTax = $order->getPostnlCodFeeTax() - $order->getPostnlCodFeeTaxRefunded();
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
* Update the creditmemo totals.
|
113 |
*/
|
|
|
114 |
$creditmemo->setPostnlCodFeeTax($feeTax)
|
115 |
->setBasePostnlCodFeeTax($baseFeeTax)
|
116 |
->setTaxAmount($creditmemo->getTaxAmount() + $feeTax)
|
@@ -118,6 +133,7 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFeeTax
|
|
118 |
->setGrandTotal($creditmemo->getGrandTotal() + $feeTax)
|
119 |
->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseFeeTax);
|
120 |
|
|
|
121 |
$order->setPostnlCodFeeTaxRefunded($order->getPostnlCodFeeTaxRefunded() + $feeTax)
|
122 |
->setBasePostnlCodFeeTaxRefunded($order->getBasePostnlCodFeeTaxRefunded() + $baseFeeTax);
|
123 |
|
@@ -126,4 +142,4 @@ class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFeeTax
|
|
126 |
|
127 |
return $this;
|
128 |
}
|
129 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Creditmemo_Total_CodFeeTax
|
50 |
{
|
51 |
$order = $creditmemo->getOrder();
|
52 |
|
53 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
54 |
$feeTax = $creditmemo->getPostnlCodFeeTax();
|
55 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
56 |
$baseFeeTax = $creditmemo->getBasePostnlCodFeeTax();
|
57 |
|
58 |
/**
|
59 |
* If a creditmemo already has a fee tax, we only need to update the totals.
|
60 |
*/
|
61 |
if ($feeTax && $baseFeeTax) {
|
62 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
63 |
$creditmemo->setPostnlCodFeeTax($feeTax)
|
64 |
->setBasePostnlCodFeeTax($baseFeeTax)
|
65 |
->setTaxAmount($creditmemo->getTaxAmount() + $feeTax)
|
67 |
->setGrandTotal($creditmemo->getGrandTotal() + $feeTax)
|
68 |
->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseFeeTax);
|
69 |
|
70 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
71 |
$order->setPostnlCodFeeTaxRefunded($order->getPostnlCodFeeTaxRefunded() + $feeTax)
|
72 |
->setBasePostnlCodFeeTaxRefunded($order->getBasePostnlCodFeeTaxRefunded() + $baseFeeTax);
|
73 |
|
77 |
/**
|
78 |
* If the creditmemo has a fee, but no fee tax, we need to calculate the fee tax.
|
79 |
*/
|
80 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
81 |
$fee = $creditmemo->getPostnlCodFee();
|
82 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
83 |
$baseFee = $creditmemo->getBasePostnlCodFee();
|
84 |
|
85 |
if ($fee && $baseFee) {
|
87 |
* First we need to determine what percentage of the fee is being refunded. We need to refund the same
|
88 |
* percentage of fee tax.
|
89 |
*/
|
90 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
91 |
$totalBaseFee = $order->getBasePostnlCodFee();
|
92 |
$ratio = $baseFee / $totalBaseFee;
|
93 |
|
94 |
/**
|
95 |
* Calculate the fee and base fee tax based on the same ratio.
|
96 |
*/
|
97 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
98 |
$totalBaseFeeTax = $order->getBasePostnlCodFeeTax();
|
99 |
$baseFeeTax = $totalBaseFeeTax * $ratio;
|
100 |
|
101 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
102 |
$totalFeeTax = $order->getPostnlCodFeeTax();
|
103 |
$feeTax = $totalFeeTax * $ratio;
|
104 |
|
106 |
* If the total amount refunded exceeds the available fee tax amount, we have a rounding error. Modify the
|
107 |
* fee tax amounts accordingly.
|
108 |
*/
|
109 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
110 |
$totalBaseFeeTax = $baseFeeTax - $order->getBasePostnlCodFeeTax()
|
111 |
- $order->getBasePostnlCodFeeTaxRefunded();
|
112 |
+
|
113 |
if ($totalBaseFeeTax < 0.0001 && $totalBaseFeeTax > -0.0001) {
|
114 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
115 |
$baseFeeTax = $order->getBasePostnlCodFeeTax() - $order->getBasePostnlCodFeeTaxRefunded();
|
116 |
}
|
117 |
|
118 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
119 |
$totalFeeTax = $feeTax - $order->getPostnlCodFeeTax() - $order->getPostnlCodFeeTaxRefunded();
|
120 |
if ($totalFeeTax < 0.0001 && $totalFeeTax > -0.0001) {
|
121 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
122 |
$feeTax = $order->getPostnlCodFeeTax() - $order->getPostnlCodFeeTaxRefunded();
|
123 |
}
|
124 |
|
125 |
/**
|
126 |
* Update the creditmemo totals.
|
127 |
*/
|
128 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
129 |
$creditmemo->setPostnlCodFeeTax($feeTax)
|
130 |
->setBasePostnlCodFeeTax($baseFeeTax)
|
131 |
->setTaxAmount($creditmemo->getTaxAmount() + $feeTax)
|
133 |
->setGrandTotal($creditmemo->getGrandTotal() + $feeTax)
|
134 |
->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseFeeTax);
|
135 |
|
136 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
137 |
$order->setPostnlCodFeeTaxRefunded($order->getPostnlCodFeeTaxRefunded() + $feeTax)
|
138 |
->setBasePostnlCodFeeTaxRefunded($order->getBasePostnlCodFeeTaxRefunded() + $baseFeeTax);
|
139 |
|
142 |
|
143 |
return $this;
|
144 |
}
|
145 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFee extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
@@ -58,7 +58,9 @@ class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFee extends Mage_Sales_Mod
|
|
58 |
/**
|
59 |
* Get the COD fee amounts.
|
60 |
*/
|
|
|
61 |
$fee = $order->getPostnlCodFee();
|
|
|
62 |
$baseFee = $order->getBasePostnlCodFee();
|
63 |
|
64 |
/**
|
@@ -74,14 +76,16 @@ class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFee extends Mage_Sales_Mod
|
|
74 |
$grandTotal = $invoice->getGrandTotal();
|
75 |
$baseGrandTotal = $invoice->getBaseGrandTotal();
|
76 |
|
|
|
77 |
$invoice->setPostnlCodFee($fee)
|
78 |
->setBasePostnlCodFee($baseFee)
|
79 |
->setGrandTotal($grandTotal + $fee)
|
80 |
->setBaseGrandTotal($baseGrandTotal + $baseFee);
|
81 |
|
|
|
82 |
$order->setPostnlCodFeeInvoiced($fee)
|
83 |
->setBasePostnlCodFeeInvoiced($baseFee);
|
84 |
|
85 |
return $this;
|
86 |
}
|
87 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFee extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
58 |
/**
|
59 |
* Get the COD fee amounts.
|
60 |
*/
|
61 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
62 |
$fee = $order->getPostnlCodFee();
|
63 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
64 |
$baseFee = $order->getBasePostnlCodFee();
|
65 |
|
66 |
/**
|
76 |
$grandTotal = $invoice->getGrandTotal();
|
77 |
$baseGrandTotal = $invoice->getBaseGrandTotal();
|
78 |
|
79 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
80 |
$invoice->setPostnlCodFee($fee)
|
81 |
->setBasePostnlCodFee($baseFee)
|
82 |
->setGrandTotal($grandTotal + $fee)
|
83 |
->setBaseGrandTotal($baseGrandTotal + $baseFee);
|
84 |
|
85 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
86 |
$order->setPostnlCodFeeInvoiced($fee)
|
87 |
->setBasePostnlCodFeeInvoiced($baseFee);
|
88 |
|
89 |
return $this;
|
90 |
}
|
91 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFeeTax extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
@@ -58,7 +58,9 @@ class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFeeTax extends Mage_Sales_
|
|
58 |
/**
|
59 |
* Get the COD fee tax amounts.
|
60 |
*/
|
|
|
61 |
$feeTax = $order->getPostnlCodFeeTax();
|
|
|
62 |
$baseFeeTax = $order->getBasePostnlCodFeeTax();
|
63 |
|
64 |
/**
|
@@ -71,6 +73,7 @@ class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFeeTax extends Mage_Sales_
|
|
71 |
/**
|
72 |
* Add the COD fee tax amounts to the invoice.
|
73 |
*/
|
|
|
74 |
$invoice->setPostnlCodFeeTax($feeTax)
|
75 |
->setBasePostnlCodFeeTax($baseFeeTax)
|
76 |
->setTaxAmount($invoice->getTaxAmount() + $feeTax)
|
@@ -79,6 +82,7 @@ class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFeeTax extends Mage_Sales_
|
|
79 |
/**
|
80 |
* For all versions except 1.13.0.X and 1.8.0.X we need to add the COD fee tax to the grand total amounts.
|
81 |
*/
|
|
|
82 |
$helper = Mage::helper('postnl');
|
83 |
if (
|
84 |
($helper->isEnterprise()
|
@@ -99,9 +103,10 @@ class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFeeTax extends Mage_Sales_
|
|
99 |
/**
|
100 |
* Update the order's COD fee tax amounts.
|
101 |
*/
|
|
|
102 |
$order->setPostnlCodFeeTaxInvoiced($feeTax)
|
103 |
->setBasePostnlCodFeeTaxInvoiced($baseFeeTax);
|
104 |
|
105 |
return $this;
|
106 |
}
|
107 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Invoice_Total_CodFeeTax extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
58 |
/**
|
59 |
* Get the COD fee tax amounts.
|
60 |
*/
|
61 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
62 |
$feeTax = $order->getPostnlCodFeeTax();
|
63 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
64 |
$baseFeeTax = $order->getBasePostnlCodFeeTax();
|
65 |
|
66 |
/**
|
73 |
/**
|
74 |
* Add the COD fee tax amounts to the invoice.
|
75 |
*/
|
76 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
77 |
$invoice->setPostnlCodFeeTax($feeTax)
|
78 |
->setBasePostnlCodFeeTax($baseFeeTax)
|
79 |
->setTaxAmount($invoice->getTaxAmount() + $feeTax)
|
82 |
/**
|
83 |
* For all versions except 1.13.0.X and 1.8.0.X we need to add the COD fee tax to the grand total amounts.
|
84 |
*/
|
85 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
86 |
$helper = Mage::helper('postnl');
|
87 |
if (
|
88 |
($helper->isEnterprise()
|
103 |
/**
|
104 |
* Update the order's COD fee tax amounts.
|
105 |
*/
|
106 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
107 |
$order->setPostnlCodFeeTaxInvoiced($feeTax)
|
108 |
->setBasePostnlCodFeeTaxInvoiced($baseFeeTax);
|
109 |
|
110 |
return $this;
|
111 |
}
|
112 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Invoice_Total_Subtotal extends Mage_Sales_Model_Order_Invoice_Total_Subtotal
|
@@ -101,6 +101,7 @@ class TIG_PostNL_Model_Payment_Order_Invoice_Total_Subtotal extends Mage_Sales_M
|
|
101 |
$includeShippingTax = false;
|
102 |
}
|
103 |
|
|
|
104 |
if ($previousInvoice->getPostnlCodFeeTax()) {
|
105 |
$includeCodFeeTax = false;
|
106 |
}
|
@@ -115,7 +116,9 @@ class TIG_PostNL_Model_Payment_Order_Invoice_Total_Subtotal extends Mage_Sales_M
|
|
115 |
}
|
116 |
|
117 |
if ($includeCodFeeTax) {
|
|
|
118 |
$allowedSubtotalInclTax -= $order->getPostnlCodFeeTax();
|
|
|
119 |
$baseAllowedSubtotalInclTax -= $order->getBasePostnlCodFeeTax();
|
120 |
}
|
121 |
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Order_Invoice_Total_Subtotal extends Mage_Sales_Model_Order_Invoice_Total_Subtotal
|
101 |
$includeShippingTax = false;
|
102 |
}
|
103 |
|
104 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
105 |
if ($previousInvoice->getPostnlCodFeeTax()) {
|
106 |
$includeCodFeeTax = false;
|
107 |
}
|
116 |
}
|
117 |
|
118 |
if ($includeCodFeeTax) {
|
119 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
120 |
$allowedSubtotalInclTax -= $order->getPostnlCodFeeTax();
|
121 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
122 |
$baseAllowedSubtotalInclTax -= $order->getBasePostnlCodFeeTax();
|
123 |
}
|
124 |
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method int|string getFontSize()
|
@@ -68,7 +68,9 @@ class TIG_PostNL_Model_Payment_Order_Pdf_Total_CodFee extends Mage_Sales_Model_O
|
|
68 |
$totals = array();
|
69 |
|
70 |
$displayMode = $this->getDisplayMode();
|
71 |
-
|
|
|
|
|
72 |
|
73 |
/**
|
74 |
* Get the fee excl. tax.
|
@@ -109,7 +111,8 @@ class TIG_PostNL_Model_Payment_Order_Pdf_Total_CodFee extends Mage_Sales_Model_O
|
|
109 |
/**
|
110 |
* Get the amount incl. tax and format it.
|
111 |
*/
|
112 |
-
|
|
|
113 |
$formattedAmount = $this->getOrder()->formatPriceTxt($amount);
|
114 |
if ($this->getAmountPrefix()) {
|
115 |
$formattedAmount = $this->getAmountPrefix() . $formattedAmount;
|
@@ -158,8 +161,10 @@ class TIG_PostNL_Model_Payment_Order_Pdf_Total_CodFee extends Mage_Sales_Model_O
|
|
158 |
*/
|
159 |
public function getTaxLabel($inclTax = false)
|
160 |
{
|
161 |
-
|
|
|
|
|
162 |
|
163 |
return $taxLabel;
|
164 |
}
|
165 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method int|string getFontSize()
|
68 |
$totals = array();
|
69 |
|
70 |
$displayMode = $this->getDisplayMode();
|
71 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
72 |
+
$helper = Mage::helper('postnl/payment');
|
73 |
+
$baseLabel = $helper->getPostnlCodFeeLabel($this->getOrder()->getStoreId());
|
74 |
|
75 |
/**
|
76 |
* Get the fee excl. tax.
|
111 |
/**
|
112 |
* Get the amount incl. tax and format it.
|
113 |
*/
|
114 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
115 |
+
$amount = $this->getAmount() + $this->getSource()->getPostnlCodFeeTax();
|
116 |
$formattedAmount = $this->getOrder()->formatPriceTxt($amount);
|
117 |
if ($this->getAmountPrefix()) {
|
118 |
$formattedAmount = $this->getAmountPrefix() . $formattedAmount;
|
161 |
*/
|
162 |
public function getTaxLabel($inclTax = false)
|
163 |
{
|
164 |
+
/** @var Mage_Tax_Helper_Data $taxHelper */
|
165 |
+
$taxHelper = Mage::helper('tax');
|
166 |
+
$taxLabel = $taxHelper->getIncExcText($inclTax, $this->getOrder()->getStoreId());
|
167 |
|
168 |
return $taxLabel;
|
169 |
}
|
170 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Mage_Sales_Model_Order getOrder()
|
@@ -61,13 +61,17 @@ class TIG_PostNL_Model_Payment_Order_Pdf_Total_Grandtotal extends Mage_Tax_Model
|
|
61 |
if (method_exists($this, '_getCalculatedTaxes')) {
|
62 |
$taxClassAmount = $this->_getCalculatedTaxes();
|
63 |
} else {
|
64 |
-
|
|
|
|
|
65 |
}
|
66 |
|
67 |
if (method_exists($this, '_getShippingTax')) {
|
68 |
$shippingTax = $this->_getShippingTax();
|
69 |
} else {
|
70 |
-
|
|
|
|
|
71 |
}
|
72 |
|
73 |
$taxClassAmount = array_merge($taxClassAmount, $shippingTax);
|
@@ -75,7 +79,9 @@ class TIG_PostNL_Model_Payment_Order_Pdf_Total_Grandtotal extends Mage_Tax_Model
|
|
75 |
/**
|
76 |
* Add the COD fee tax info.
|
77 |
*/
|
78 |
-
|
|
|
|
|
79 |
$taxClassAmount,
|
80 |
$this->getSource(),
|
81 |
$this->getOrder()
|
@@ -137,7 +143,9 @@ class TIG_PostNL_Model_Payment_Order_Pdf_Total_Grandtotal extends Mage_Tax_Model
|
|
137 |
}
|
138 |
|
139 |
$rates = Mage::getModel('tax/sales_order_tax')->getCollection()->loadByOrder($this->getOrder())->toArray();
|
140 |
-
|
|
|
|
|
141 |
return $fullInfo;
|
142 |
}
|
143 |
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Mage_Sales_Model_Order getOrder()
|
61 |
if (method_exists($this, '_getCalculatedTaxes')) {
|
62 |
$taxClassAmount = $this->_getCalculatedTaxes();
|
63 |
} else {
|
64 |
+
/** @var Mage_Tax_Helper_Data $taxHelper */
|
65 |
+
$taxHelper = Mage::helper('tax');
|
66 |
+
$taxClassAmount = $taxHelper->getCalculatedTaxes($this->getOrder());
|
67 |
}
|
68 |
|
69 |
if (method_exists($this, '_getShippingTax')) {
|
70 |
$shippingTax = $this->_getShippingTax();
|
71 |
} else {
|
72 |
+
/** @var Mage_Tax_Helper_Data $taxHelper */
|
73 |
+
$taxHelper = Mage::helper('tax');
|
74 |
+
$shippingTax = $taxHelper->getShippingTax($this->getOrder());
|
75 |
}
|
76 |
|
77 |
$taxClassAmount = array_merge($taxClassAmount, $shippingTax);
|
79 |
/**
|
80 |
* Add the COD fee tax info.
|
81 |
*/
|
82 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
83 |
+
$helper = Mage::helper('postnl/payment');
|
84 |
+
$taxClassAmount = $helper->addPostnlCodFeeTaxInfo(
|
85 |
$taxClassAmount,
|
86 |
$this->getSource(),
|
87 |
$this->getOrder()
|
143 |
}
|
144 |
|
145 |
$rates = Mage::getModel('tax/sales_order_tax')->getCollection()->loadByOrder($this->getOrder())->toArray();
|
146 |
+
/** @var Mage_Tax_Model_Calculation $calculationModel */
|
147 |
+
$calculationModel = Mage::getSingleton('tax/calculation');
|
148 |
+
$fullInfo = $calculationModel->reproduceProcess($rates['items']);
|
149 |
return $fullInfo;
|
150 |
}
|
151 |
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Mage_Sales_Model_Order getOrder()
|
@@ -61,13 +61,17 @@ class TIG_PostNL_Model_Payment_Order_Pdf_Total_Tax extends Mage_Tax_Model_Sales_
|
|
61 |
if (method_exists($this, '_getCalculatedTaxes')) {
|
62 |
$taxClassAmount = $this->_getCalculatedTaxes();
|
63 |
} else {
|
64 |
-
|
|
|
|
|
65 |
}
|
66 |
|
67 |
if (method_exists($this, '_getShippingTax')) {
|
68 |
$shippingTax = $this->_getShippingTax();
|
69 |
} else {
|
70 |
-
|
|
|
|
|
71 |
}
|
72 |
|
73 |
$taxClassAmount = array_merge($taxClassAmount, $shippingTax);
|
@@ -75,7 +79,9 @@ class TIG_PostNL_Model_Payment_Order_Pdf_Total_Tax extends Mage_Tax_Model_Sales_
|
|
75 |
/**
|
76 |
* Add the COD fee tax info.
|
77 |
*/
|
78 |
-
|
|
|
|
|
79 |
$taxClassAmount,
|
80 |
$this->getSource(),
|
81 |
$this->getOrder()
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*
|
39 |
* @method Mage_Sales_Model_Order getOrder()
|
61 |
if (method_exists($this, '_getCalculatedTaxes')) {
|
62 |
$taxClassAmount = $this->_getCalculatedTaxes();
|
63 |
} else {
|
64 |
+
/** @var Mage_Tax_Helper_Data $taxHelper */
|
65 |
+
$taxHelper = Mage::helper('tax');
|
66 |
+
$taxClassAmount = $taxHelper->getCalculatedTaxes($this->getOrder());
|
67 |
}
|
68 |
|
69 |
if (method_exists($this, '_getShippingTax')) {
|
70 |
$shippingTax = $this->_getShippingTax();
|
71 |
} else {
|
72 |
+
/** @var Mage_Tax_Helper_Data $taxHelper */
|
73 |
+
$taxHelper = Mage::helper('tax');
|
74 |
+
$shippingTax = $taxHelper->getShippingTax($this->getOrder());
|
75 |
}
|
76 |
|
77 |
$taxClassAmount = array_merge($taxClassAmount, $shippingTax);
|
79 |
/**
|
80 |
* Add the COD fee tax info.
|
81 |
*/
|
82 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
83 |
+
$helper = Mage::helper('postnl/payment');
|
84 |
+
$taxClassAmount = $helper->addPostnlCodFeeTaxInfo(
|
85 |
$taxClassAmount,
|
86 |
$this->getSource(),
|
87 |
$this->getOrder()
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee
|
@@ -87,9 +87,11 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee
|
|
87 |
/**
|
88 |
* First, reset the fee amounts to 0 for this address and the quote.
|
89 |
*/
|
|
|
90 |
$address->setPostnlCodFee(0)
|
91 |
->setBasePostnlCodFee(0);
|
92 |
|
|
|
93 |
$quote->setPostnlCodFee(0)
|
94 |
->setBasePostnlCodFee(0);
|
95 |
|
@@ -98,6 +100,7 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee
|
|
98 |
*/
|
99 |
$paymentMethod = $quote->getPayment()->getMethod();
|
100 |
|
|
|
101 |
$helper = Mage::helper('postnl/payment');
|
102 |
$codPaymentMethods = $helper->getCodPaymentMethods();
|
103 |
if (!in_array($paymentMethod, $codPaymentMethods)) {
|
@@ -120,9 +123,11 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee
|
|
120 |
/**
|
121 |
* Set the fee for the address and quote.
|
122 |
*/
|
|
|
123 |
$address->setPostnlCodFee($fee)
|
124 |
->setBasePostnlCodFee($baseFee);
|
125 |
|
|
|
126 |
$quote->setPostnlCodFee($fee)
|
127 |
->setBasePostnlCodFee($baseFee);
|
128 |
|
@@ -144,6 +149,7 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee
|
|
144 |
*/
|
145 |
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
146 |
{
|
|
|
147 |
$amount = $address->getPostnlCodFee();
|
148 |
|
149 |
if ($amount <= 0) {
|
@@ -158,13 +164,16 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee
|
|
158 |
if (Mage::app()->getRequest()->getModuleName() == self::ONESTEPCHECKOUT_MODULE_NAME
|
159 |
&& Mage::getStoreConfigFlag(self::XPATH_ONESTEPCHECKOUT_DISPLAY_TAX_INCLUDED, $storeId)
|
160 |
) {
|
|
|
161 |
$amount += $address->getPostnlCodFeeTax();
|
162 |
}
|
163 |
|
|
|
|
|
164 |
$address->addTotal(
|
165 |
array(
|
166 |
'code' => $this->getCode(),
|
167 |
-
'title' =>
|
168 |
'value' => $amount,
|
169 |
)
|
170 |
);
|
@@ -225,4 +234,4 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee
|
|
225 |
|
226 |
return $fee;
|
227 |
}
|
228 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee
|
87 |
/**
|
88 |
* First, reset the fee amounts to 0 for this address and the quote.
|
89 |
*/
|
90 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
91 |
$address->setPostnlCodFee(0)
|
92 |
->setBasePostnlCodFee(0);
|
93 |
|
94 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
95 |
$quote->setPostnlCodFee(0)
|
96 |
->setBasePostnlCodFee(0);
|
97 |
|
100 |
*/
|
101 |
$paymentMethod = $quote->getPayment()->getMethod();
|
102 |
|
103 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
104 |
$helper = Mage::helper('postnl/payment');
|
105 |
$codPaymentMethods = $helper->getCodPaymentMethods();
|
106 |
if (!in_array($paymentMethod, $codPaymentMethods)) {
|
123 |
/**
|
124 |
* Set the fee for the address and quote.
|
125 |
*/
|
126 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
127 |
$address->setPostnlCodFee($fee)
|
128 |
->setBasePostnlCodFee($baseFee);
|
129 |
|
130 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
131 |
$quote->setPostnlCodFee($fee)
|
132 |
->setBasePostnlCodFee($baseFee);
|
133 |
|
149 |
*/
|
150 |
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
151 |
{
|
152 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
153 |
$amount = $address->getPostnlCodFee();
|
154 |
|
155 |
if ($amount <= 0) {
|
164 |
if (Mage::app()->getRequest()->getModuleName() == self::ONESTEPCHECKOUT_MODULE_NAME
|
165 |
&& Mage::getStoreConfigFlag(self::XPATH_ONESTEPCHECKOUT_DISPLAY_TAX_INCLUDED, $storeId)
|
166 |
) {
|
167 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
168 |
$amount += $address->getPostnlCodFeeTax();
|
169 |
}
|
170 |
|
171 |
+
/** @var TIG_PostNL_Helper_Payment $helper */
|
172 |
+
$helper = Mage::helper('postnl/payment');
|
173 |
$address->addTotal(
|
174 |
array(
|
175 |
'code' => $this->getCode(),
|
176 |
+
'title' => $helper->getPostnlCodFeeLabel($storeId),
|
177 |
'value' => $amount,
|
178 |
)
|
179 |
);
|
234 |
|
235 |
return $fee;
|
236 |
}
|
237 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee_Abstract extends Mage_Tax_Model_Sales_Total_Quote_Tax
|
@@ -63,10 +63,14 @@ abstract class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee_Abstract exte
|
|
63 |
*
|
64 |
* Sets several class variables.
|
65 |
*/
|
|
|
66 |
public function __construct()
|
67 |
{
|
68 |
$this->setCode($this->_totalCode);
|
69 |
-
|
|
|
|
|
|
|
70 |
|
71 |
$this->_helper = Mage::helper('tax');
|
72 |
$this->_config = Mage::getSingleton('tax/config');
|
@@ -83,6 +87,7 @@ abstract class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee_Abstract exte
|
|
83 |
return $taxCalculation;
|
84 |
}
|
85 |
|
|
|
86 |
$taxCalculation = Mage::getSingleton('tax/calculation');
|
87 |
|
88 |
$this->setTaxCalculation($taxCalculation);
|
@@ -152,6 +157,7 @@ abstract class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee_Abstract exte
|
|
152 |
$store
|
153 |
);
|
154 |
|
|
|
155 |
$request->setProductClassId($codTaxClass);
|
156 |
|
157 |
return $request;
|
@@ -184,6 +190,7 @@ abstract class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee_Abstract exte
|
|
184 |
protected function _getCodFeeTax($address, $taxRate, $fee = null, $isInclTax = false)
|
185 |
{
|
186 |
if (is_null($fee)) {
|
|
|
187 |
$fee = (float) $address->getPostnlCodFee();
|
188 |
}
|
189 |
|
@@ -212,6 +219,7 @@ abstract class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee_Abstract exte
|
|
212 |
protected function _getBaseCodFeeTax($address, $taxRate, $fee = null, $isInclTax = false)
|
213 |
{
|
214 |
if (is_null($fee)) {
|
|
|
215 |
$fee = (float) $address->getBasePostnlCodFee();
|
216 |
}
|
217 |
|
@@ -231,12 +239,12 @@ abstract class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee_Abstract exte
|
|
231 |
* Process model configuration array.
|
232 |
* This method can be used for changing models apply sort order
|
233 |
*
|
234 |
-
* @param array
|
235 |
-
* @param
|
236 |
* @return array
|
237 |
*/
|
238 |
public function processConfigArray($config, $store)
|
239 |
{
|
240 |
return $config;
|
241 |
}
|
242 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFee_Abstract extends Mage_Tax_Model_Sales_Total_Quote_Tax
|
63 |
*
|
64 |
* Sets several class variables.
|
65 |
*/
|
66 |
+
/** @noinspection PhpMissingParentConstructorInspection */
|
67 |
public function __construct()
|
68 |
{
|
69 |
$this->setCode($this->_totalCode);
|
70 |
+
|
71 |
+
/** @var Mage_Tax_Model_Calculation $taxCalculation */
|
72 |
+
$taxCalculation = Mage::getSingleton('tax/calculation');
|
73 |
+
$this->setTaxCalculation($taxCalculation);
|
74 |
|
75 |
$this->_helper = Mage::helper('tax');
|
76 |
$this->_config = Mage::getSingleton('tax/config');
|
87 |
return $taxCalculation;
|
88 |
}
|
89 |
|
90 |
+
/** @var Mage_Tax_Model_Calculation $taxCalculation */
|
91 |
$taxCalculation = Mage::getSingleton('tax/calculation');
|
92 |
|
93 |
$this->setTaxCalculation($taxCalculation);
|
157 |
$store
|
158 |
);
|
159 |
|
160 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
161 |
$request->setProductClassId($codTaxClass);
|
162 |
|
163 |
return $request;
|
190 |
protected function _getCodFeeTax($address, $taxRate, $fee = null, $isInclTax = false)
|
191 |
{
|
192 |
if (is_null($fee)) {
|
193 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
194 |
$fee = (float) $address->getPostnlCodFee();
|
195 |
}
|
196 |
|
219 |
protected function _getBaseCodFeeTax($address, $taxRate, $fee = null, $isInclTax = false)
|
220 |
{
|
221 |
if (is_null($fee)) {
|
222 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
223 |
$fee = (float) $address->getBasePostnlCodFee();
|
224 |
}
|
225 |
|
239 |
* Process model configuration array.
|
240 |
* This method can be used for changing models apply sort order
|
241 |
*
|
242 |
+
* @param array $config
|
243 |
+
* @param null|int|string|Mage_Core_Model_Store $store
|
244 |
* @return array
|
245 |
*/
|
246 |
public function processConfigArray($config, $store)
|
247 |
{
|
248 |
return $config;
|
249 |
}
|
250 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFeeTax
|
@@ -72,9 +72,11 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFeeTax
|
|
72 |
/**
|
73 |
* First, reset the fee amounts to 0 for this address and the quote.
|
74 |
*/
|
|
|
75 |
$address->setPostnlCodFeeTax(0)
|
76 |
->setBasePostnlCodFeeTax(0);
|
77 |
|
|
|
78 |
$quote->setPostnlCodFeeTax(0)
|
79 |
->setBasePostnlCodFeeTax(0);
|
80 |
|
@@ -83,6 +85,7 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFeeTax
|
|
83 |
return $this;
|
84 |
}
|
85 |
|
|
|
86 |
if ($address->getPostnlCodFee() < 0.0001 || $address->getBasePostnlCodFee() < 0.0001) {
|
87 |
return $this;
|
88 |
}
|
@@ -120,8 +123,9 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFeeTax
|
|
120 |
/**
|
121 |
* Get all taxes that were applied for this tax request.
|
122 |
*/
|
123 |
-
$
|
124 |
-
|
|
|
125 |
|
126 |
/**
|
127 |
* Save the newly applied taxes.
|
@@ -137,14 +141,20 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFeeTax
|
|
137 |
/**
|
138 |
* Update the total amounts.
|
139 |
*/
|
|
|
140 |
$address->setTaxAmount($address->getTaxAmount() + $feeTax)
|
141 |
->setBaseTaxAmount($address->getBaseTaxAmount() + $baseFeeTax)
|
142 |
->setPostnlCodFeeTax($feeTax)
|
143 |
->setBasePostnlCodFeeTax($baseFeeTax);
|
144 |
|
145 |
-
|
146 |
-
|
147 |
|
|
|
|
|
|
|
|
|
|
|
148 |
$quote->setPostnlCodFeeTax($feeTax)
|
149 |
->setBasePostnlCodFeeTax($baseFeeTax);
|
150 |
|
@@ -163,4 +173,4 @@ class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFeeTax
|
|
163 |
{
|
164 |
return $this;
|
165 |
}
|
166 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Quote_Address_Total_CodFeeTax
|
72 |
/**
|
73 |
* First, reset the fee amounts to 0 for this address and the quote.
|
74 |
*/
|
75 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
76 |
$address->setPostnlCodFeeTax(0)
|
77 |
->setBasePostnlCodFeeTax(0);
|
78 |
|
79 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
80 |
$quote->setPostnlCodFeeTax(0)
|
81 |
->setBasePostnlCodFeeTax(0);
|
82 |
|
85 |
return $this;
|
86 |
}
|
87 |
|
88 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
89 |
if ($address->getPostnlCodFee() < 0.0001 || $address->getBasePostnlCodFee() < 0.0001) {
|
90 |
return $this;
|
91 |
}
|
123 |
/**
|
124 |
* Get all taxes that were applied for this tax request.
|
125 |
*/
|
126 |
+
/** @var Mage_Tax_Model_Calculation $taxCalculation */
|
127 |
+
$taxCalculation = Mage::getSingleton('tax/calculation');
|
128 |
+
$appliedRates = $taxCalculation->getAppliedRates($taxRequest);
|
129 |
|
130 |
/**
|
131 |
* Save the newly applied taxes.
|
141 |
/**
|
142 |
* Update the total amounts.
|
143 |
*/
|
144 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
145 |
$address->setTaxAmount($address->getTaxAmount() + $feeTax)
|
146 |
->setBaseTaxAmount($address->getBaseTaxAmount() + $baseFeeTax)
|
147 |
->setPostnlCodFeeTax($feeTax)
|
148 |
->setBasePostnlCodFeeTax($baseFeeTax);
|
149 |
|
150 |
+
if (!Mage::registry('postnl_cod_fee_tax_added')) {
|
151 |
+
Mage::register('postnl_cod_fee_tax_added', true);
|
152 |
|
153 |
+
$address->addTotalAmount('postnl_cod_fee_tax', $feeTax);
|
154 |
+
$address->addBaseTotalAmount('postnl_base_cod_fee_tax', $baseFeeTax);
|
155 |
+
}
|
156 |
+
|
157 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
158 |
$quote->setPostnlCodFeeTax($feeTax)
|
159 |
->setBasePostnlCodFeeTax($baseFeeTax);
|
160 |
|
173 |
{
|
174 |
return $this;
|
175 |
}
|
176 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Service
|
@@ -61,45 +61,24 @@ class TIG_PostNL_Model_Payment_Service
|
|
61 |
*/
|
62 |
public function addPostnlCodFeeTaxInfo($fullInfo, $source, Mage_Sales_Model_Order $order)
|
63 |
{
|
|
|
64 |
$feeTax = (float) $order->getPostnlCodFeeTax();
|
65 |
if ($feeTax <= 0) {
|
66 |
return $fullInfo;
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
-
* There are
|
71 |
* - Go through all tax info records of an order and add the COD fee info to the record with the same title and
|
72 |
* a discrepancy in the recorded and expected amount.
|
73 |
-
* - Add a missing tax info record.
|
74 |
* - Recalculate the tax info for the COD fee and update the amount of the tax record with the same title.
|
75 |
*/
|
|
|
76 |
$orderClassName = Mage::getConfig()->getModelClassName('sales/order');
|
77 |
if ($source instanceof $orderClassName) {
|
78 |
$fullInfo = $this->_updateTaxAmountForTaxInfo($order, $fullInfo);
|
79 |
} else {
|
80 |
-
|
81 |
-
* Try to find a tax record that does not have a corresponding tax item record.
|
82 |
-
*/
|
83 |
-
$taxItemCollection = Mage::getResourceModel('tax/sales_order_tax_item_collection');
|
84 |
-
$taxItemCollection->addFieldToSelect('tax_id');
|
85 |
-
$taxItemCollection->getSelect()->distinct();
|
86 |
-
|
87 |
-
$taxItemIds = $taxItemCollection->getColumnValues('tax_id');
|
88 |
-
|
89 |
-
$taxCollection = Mage::getResourceModel('sales/order_tax_collection')
|
90 |
-
->addFieldToFilter('order_id', array('eq' => $order->getId()))
|
91 |
-
->addFieldToFilter('tax_id', array('nin' => $taxItemIds));
|
92 |
-
|
93 |
-
/**
|
94 |
-
* If we have found a missing record, we need to add it with the COD fee tax info. Otherwise we need to
|
95 |
-
* recreate the entire tax request for the COD fee tax so we can match the title to an existing tax item
|
96 |
-
* record.
|
97 |
-
*/
|
98 |
-
if ($taxCollection->getSize()) {
|
99 |
-
$fullInfo = $this->_addPostnlCodFeeTaxInfoFromCollection($taxCollection, $fullInfo, $source);
|
100 |
-
} else {
|
101 |
-
$fullInfo = $this->_addPostnlCodFeeTaxInfoFromRequest($order, $fullInfo, $source);
|
102 |
-
}
|
103 |
}
|
104 |
|
105 |
return $fullInfo;
|
@@ -124,11 +103,14 @@ class TIG_PostNL_Model_Payment_Service
|
|
124 |
*/
|
125 |
foreach ($taxCollection as $tax) {
|
126 |
foreach ($fullInfo as $key => $taxInfo) {
|
|
|
127 |
if ($tax->getTitle() == $taxInfo['title'] && $tax->getAmount() != $taxInfo['tax_amount']) {
|
128 |
/**
|
129 |
* Update the amounts.
|
130 |
*/
|
|
|
131 |
$fullInfo[$key]['tax_amount'] = $tax->getAmount();
|
|
|
132 |
$fullInfo[$key]['base_tax_amount'] = $tax->getBaseAmount();
|
133 |
}
|
134 |
}
|
@@ -157,8 +139,11 @@ class TIG_PostNL_Model_Payment_Service
|
|
157 |
/**
|
158 |
* Update an existing entry.
|
159 |
*/
|
|
|
160 |
if ($taxInfo['title'] == $tax->getTitle()) {
|
|
|
161 |
$fullInfo[$key]['tax_amount'] += $source->getPostnlCodFeeTax();
|
|
|
162 |
$fullInfo[$key]['base_tax_amount'] += $source->getBasePostnlCodFeeTax();
|
163 |
|
164 |
break(2);
|
@@ -168,6 +153,7 @@ class TIG_PostNL_Model_Payment_Service
|
|
168 |
/**
|
169 |
* Add a missing entry.
|
170 |
*/
|
|
|
171 |
$fullInfo[] = array(
|
172 |
'tax_amount' => $source->getPostnlCodFeeTax(),
|
173 |
'base_tax_amount' => $source->getBasePostnlCodFeeTax(),
|
@@ -191,11 +177,13 @@ class TIG_PostNL_Model_Payment_Service
|
|
191 |
protected function _addPostnlCodFeeTaxInfoFromRequest($order, $fullInfo, $source)
|
192 |
{
|
193 |
$store = $order->getStore();
|
|
|
194 |
$taxCalculation = Mage::getSingleton('tax/calculation');
|
195 |
|
196 |
/**
|
197 |
* Recalculate the tax request.
|
198 |
*/
|
|
|
199 |
$customerTaxClass = $order->getCustomerTaxClassId();
|
200 |
$shippingAddress = $order->getShippingAddress();
|
201 |
$billingAddress = $order->getBillingAddress();
|
@@ -208,6 +196,7 @@ class TIG_PostNL_Model_Payment_Service
|
|
208 |
$store
|
209 |
);
|
210 |
|
|
|
211 |
$taxRequest->setProductClassId($codTaxClass);
|
212 |
|
213 |
/**
|
@@ -221,8 +210,9 @@ class TIG_PostNL_Model_Payment_Service
|
|
221 |
/**
|
222 |
* Get the applied rates.
|
223 |
*/
|
224 |
-
$
|
225 |
-
|
|
|
226 |
|
227 |
if (!isset($appliedRates[0]['rates'][0]['title'])) {
|
228 |
return $fullInfo;
|
@@ -241,7 +231,9 @@ class TIG_PostNL_Model_Payment_Service
|
|
241 |
/**
|
242 |
* Update the tax info entry with the COD fee tax.
|
243 |
*/
|
|
|
244 |
$fullInfo[$key]['tax_amount'] += $source->getPostnlCodFeeTax();
|
|
|
245 |
$fullInfo[$key]['base_tax_amount'] += $source->getBasePostnlCodFeeTax();
|
246 |
break;
|
247 |
}
|
@@ -249,4 +241,4 @@ class TIG_PostNL_Model_Payment_Service
|
|
249 |
|
250 |
return $fullInfo;
|
251 |
}
|
252 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_Service
|
61 |
*/
|
62 |
public function addPostnlCodFeeTaxInfo($fullInfo, $source, Mage_Sales_Model_Order $order)
|
63 |
{
|
64 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
65 |
$feeTax = (float) $order->getPostnlCodFeeTax();
|
66 |
if ($feeTax <= 0) {
|
67 |
return $fullInfo;
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* There are 2 possible ways to add the COD fee tax info:
|
72 |
* - Go through all tax info records of an order and add the COD fee info to the record with the same title and
|
73 |
* a discrepancy in the recorded and expected amount.
|
|
|
74 |
* - Recalculate the tax info for the COD fee and update the amount of the tax record with the same title.
|
75 |
*/
|
76 |
+
/** @noinspection PhpParamsInspection */
|
77 |
$orderClassName = Mage::getConfig()->getModelClassName('sales/order');
|
78 |
if ($source instanceof $orderClassName) {
|
79 |
$fullInfo = $this->_updateTaxAmountForTaxInfo($order, $fullInfo);
|
80 |
} else {
|
81 |
+
$fullInfo = $this->_addPostnlCodFeeTaxInfoFromRequest($order, $fullInfo, $source);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
|
84 |
return $fullInfo;
|
103 |
*/
|
104 |
foreach ($taxCollection as $tax) {
|
105 |
foreach ($fullInfo as $key => $taxInfo) {
|
106 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
107 |
if ($tax->getTitle() == $taxInfo['title'] && $tax->getAmount() != $taxInfo['tax_amount']) {
|
108 |
/**
|
109 |
* Update the amounts.
|
110 |
*/
|
111 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
112 |
$fullInfo[$key]['tax_amount'] = $tax->getAmount();
|
113 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
114 |
$fullInfo[$key]['base_tax_amount'] = $tax->getBaseAmount();
|
115 |
}
|
116 |
}
|
139 |
/**
|
140 |
* Update an existing entry.
|
141 |
*/
|
142 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
143 |
if ($taxInfo['title'] == $tax->getTitle()) {
|
144 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
145 |
$fullInfo[$key]['tax_amount'] += $source->getPostnlCodFeeTax();
|
146 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
147 |
$fullInfo[$key]['base_tax_amount'] += $source->getBasePostnlCodFeeTax();
|
148 |
|
149 |
break(2);
|
153 |
/**
|
154 |
* Add a missing entry.
|
155 |
*/
|
156 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
157 |
$fullInfo[] = array(
|
158 |
'tax_amount' => $source->getPostnlCodFeeTax(),
|
159 |
'base_tax_amount' => $source->getBasePostnlCodFeeTax(),
|
177 |
protected function _addPostnlCodFeeTaxInfoFromRequest($order, $fullInfo, $source)
|
178 |
{
|
179 |
$store = $order->getStore();
|
180 |
+
/** @var Mage_Tax_Model_Calculation $taxCalculation */
|
181 |
$taxCalculation = Mage::getSingleton('tax/calculation');
|
182 |
|
183 |
/**
|
184 |
* Recalculate the tax request.
|
185 |
*/
|
186 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
187 |
$customerTaxClass = $order->getCustomerTaxClassId();
|
188 |
$shippingAddress = $order->getShippingAddress();
|
189 |
$billingAddress = $order->getBillingAddress();
|
196 |
$store
|
197 |
);
|
198 |
|
199 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
200 |
$taxRequest->setProductClassId($codTaxClass);
|
201 |
|
202 |
/**
|
210 |
/**
|
211 |
* Get the applied rates.
|
212 |
*/
|
213 |
+
/** @var Mage_Tax_Model_Calculation $taxCalculation */
|
214 |
+
$taxCalculation = Mage::getSingleton('tax/calculation');
|
215 |
+
$appliedRates = $taxCalculation->getAppliedRates($taxRequest);
|
216 |
|
217 |
if (!isset($appliedRates[0]['rates'][0]['title'])) {
|
218 |
return $fullInfo;
|
231 |
/**
|
232 |
* Update the tax info entry with the COD fee tax.
|
233 |
*/
|
234 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
235 |
$fullInfo[$key]['tax_amount'] += $source->getPostnlCodFeeTax();
|
236 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
237 |
$fullInfo[$key]['base_tax_amount'] += $source->getBasePostnlCodFeeTax();
|
238 |
break;
|
239 |
}
|
241 |
|
242 |
return $fullInfo;
|
243 |
}
|
244 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_System_Config_Source_CodFeeTaxClass
|
@@ -46,8 +46,10 @@ class TIG_PostNL_Model_Payment_System_Config_Source_CodFeeTaxClass
|
|
46 |
*/
|
47 |
public function toOptionArray()
|
48 |
{
|
49 |
-
$
|
|
|
|
|
50 |
|
51 |
return $options;
|
52 |
}
|
53 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Payment_System_Config_Source_CodFeeTaxClass
|
46 |
*/
|
47 |
public function toOptionArray()
|
48 |
{
|
49 |
+
/** @var Mage_Tax_Model_Class_Source_Product $source */
|
50 |
+
$source = Mage::getModel('tax/class_source_product');
|
51 |
+
$options = $source->toOptionArray();
|
52 |
|
53 |
return $options;
|
54 |
}
|
55 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Catalog_Product extends Mage_Catalog_Model_Resource_Product
|
@@ -160,4 +160,4 @@ class TIG_PostNL_Model_Resource_Catalog_Product extends Mage_Catalog_Model_Resou
|
|
160 |
|
161 |
return $attributesData;
|
162 |
}
|
163 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Catalog_Product extends Mage_Catalog_Model_Resource_Product
|
160 |
|
161 |
return $attributesData;
|
162 |
}
|
163 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_Resource_Db_Abstract extends Mage_Core_Model_Resource_Db_Abstract
|
@@ -48,14 +48,17 @@ abstract class TIG_PostNL_Model_Resource_Db_Abstract extends Mage_Core_Model_Res
|
|
48 |
protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
|
49 |
{
|
50 |
$currentTime = Varien_Date::now();
|
|
|
51 |
if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) {
|
|
|
52 |
$object->setCreatedAt($currentTime);
|
53 |
}
|
54 |
|
|
|
55 |
$object->setUpdatedAt($currentTime);
|
56 |
|
57 |
$data = parent::_prepareDataForSave($object);
|
58 |
|
59 |
return $data;
|
60 |
}
|
61 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
abstract class TIG_PostNL_Model_Resource_Db_Abstract extends Mage_Core_Model_Resource_Db_Abstract
|
48 |
protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
|
49 |
{
|
50 |
$currentTime = Varien_Date::now();
|
51 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
52 |
if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) {
|
53 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
54 |
$object->setCreatedAt($currentTime);
|
55 |
}
|
56 |
|
57 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
58 |
$object->setUpdatedAt($currentTime);
|
59 |
|
60 |
$data = parent::_prepareDataForSave($object);
|
61 |
|
62 |
return $data;
|
63 |
}
|
64 |
+
}
|
@@ -33,11 +33,12 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Db_Collection_Postnl extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
40 |
{
|
|
|
41 |
/**
|
42 |
* Fix for grid pager count believing there is only 1 item when $collection->getSelect()->groupBy() has been used.
|
43 |
*
|
@@ -50,14 +51,21 @@ class TIG_PostNL_Model_Resource_Db_Collection_Postnl extends Mage_Core_Model_Res
|
|
50 |
$this->_renderFilters();
|
51 |
|
52 |
$countSelect = clone $this->getSelect();
|
|
|
53 |
$countSelect->reset(Zend_Db_Select::ORDER);
|
|
|
54 |
$countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
|
|
|
55 |
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
|
|
|
56 |
$countSelect->reset(Zend_Db_Select::COLUMNS);
|
57 |
|
|
|
58 |
if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
|
|
|
59 |
$countSelect->reset(Zend_Db_Select::GROUP);
|
60 |
$countSelect->distinct(true);
|
|
|
61 |
$group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
|
62 |
$countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
|
63 |
} else {
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Db_Collection_Postnl extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
40 |
{
|
41 |
+
/** @noinspection PhpUndefinedClassInspection */
|
42 |
/**
|
43 |
* Fix for grid pager count believing there is only 1 item when $collection->getSelect()->groupBy() has been used.
|
44 |
*
|
51 |
$this->_renderFilters();
|
52 |
|
53 |
$countSelect = clone $this->getSelect();
|
54 |
+
/** @noinspection PhpUndefinedClassInspection */
|
55 |
$countSelect->reset(Zend_Db_Select::ORDER);
|
56 |
+
/** @noinspection PhpUndefinedClassInspection */
|
57 |
$countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
|
58 |
+
/** @noinspection PhpUndefinedClassInspection */
|
59 |
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
|
60 |
+
/** @noinspection PhpUndefinedClassInspection */
|
61 |
$countSelect->reset(Zend_Db_Select::COLUMNS);
|
62 |
|
63 |
+
/** @noinspection PhpUndefinedClassInspection */
|
64 |
if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
|
65 |
+
/** @noinspection PhpUndefinedClassInspection */
|
66 |
$countSelect->reset(Zend_Db_Select::GROUP);
|
67 |
$countSelect->distinct(true);
|
68 |
+
/** @noinspection PhpUndefinedClassInspection */
|
69 |
$group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
|
70 |
$countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
|
71 |
} else {
|
@@ -33,11 +33,12 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Order_Grid_Collection extends Mage_Sales_Model_Resource_Order_Grid_Collection
|
40 |
{
|
|
|
41 |
/**
|
42 |
* Fix for grid pager count believing there is only 1 item when $collection->getSelect()->groupBy() has been used
|
43 |
*
|
@@ -50,14 +51,21 @@ class TIG_PostNL_Model_Resource_Order_Grid_Collection extends Mage_Sales_Model_R
|
|
50 |
$this->_renderFilters();
|
51 |
|
52 |
$countSelect = clone $this->getSelect();
|
|
|
53 |
$countSelect->reset(Zend_Db_Select::ORDER);
|
|
|
54 |
$countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
|
|
|
55 |
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
|
|
|
56 |
$countSelect->reset(Zend_Db_Select::COLUMNS);
|
57 |
|
|
|
58 |
if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
|
|
|
59 |
$countSelect->reset(Zend_Db_Select::GROUP);
|
60 |
$countSelect->distinct(true);
|
|
|
61 |
$group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
|
62 |
$countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
|
63 |
} else {
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Order_Grid_Collection extends Mage_Sales_Model_Resource_Order_Grid_Collection
|
40 |
{
|
41 |
+
/** @noinspection PhpUndefinedClassInspection */
|
42 |
/**
|
43 |
* Fix for grid pager count believing there is only 1 item when $collection->getSelect()->groupBy() has been used
|
44 |
*
|
51 |
$this->_renderFilters();
|
52 |
|
53 |
$countSelect = clone $this->getSelect();
|
54 |
+
/** @noinspection PhpUndefinedClassInspection */
|
55 |
$countSelect->reset(Zend_Db_Select::ORDER);
|
56 |
+
/** @noinspection PhpUndefinedClassInspection */
|
57 |
$countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
|
58 |
+
/** @noinspection PhpUndefinedClassInspection */
|
59 |
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
|
60 |
+
/** @noinspection PhpUndefinedClassInspection */
|
61 |
$countSelect->reset(Zend_Db_Select::COLUMNS);
|
62 |
|
63 |
+
/** @noinspection PhpUndefinedClassInspection */
|
64 |
if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
|
65 |
+
/** @noinspection PhpUndefinedClassInspection */
|
66 |
$countSelect->reset(Zend_Db_Select::GROUP);
|
67 |
$countSelect->distinct(true);
|
68 |
+
/** @noinspection PhpUndefinedClassInspection */
|
69 |
$group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
|
70 |
$countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
|
71 |
} else {
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Order_Shipment extends Mage_Sales_Model_Resource_Order_Shipment
|
@@ -55,4 +55,4 @@ class TIG_PostNL_Model_Resource_Order_Shipment extends Mage_Sales_Model_Resource
|
|
55 |
|
56 |
return $adapter->fetchOne($select, $bind);
|
57 |
}
|
58 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Order_Shipment extends Mage_Sales_Model_Resource_Order_Shipment
|
55 |
|
56 |
return $adapter->fetchOne($select, $bind);
|
57 |
}
|
58 |
+
}
|
@@ -33,11 +33,12 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection extends Mage_Sales_Model_Resource_Order_Shipment_Grid_Collection
|
40 |
{
|
|
|
41 |
/**
|
42 |
* Fix for grid pager count believing there is only 1 item when $collection->getSelect()->groupBy() has been used
|
43 |
*
|
@@ -50,14 +51,21 @@ class TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection extends Mage_Sale
|
|
50 |
$this->_renderFilters();
|
51 |
|
52 |
$countSelect = clone $this->getSelect();
|
|
|
53 |
$countSelect->reset(Zend_Db_Select::ORDER);
|
|
|
54 |
$countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
|
|
|
55 |
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
|
|
|
56 |
$countSelect->reset(Zend_Db_Select::COLUMNS);
|
57 |
|
|
|
58 |
if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
|
|
|
59 |
$countSelect->reset(Zend_Db_Select::GROUP);
|
60 |
$countSelect->distinct(true);
|
|
|
61 |
$group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
|
62 |
$countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
|
63 |
} else {
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection extends Mage_Sales_Model_Resource_Order_Shipment_Grid_Collection
|
40 |
{
|
41 |
+
/** @noinspection PhpUndefinedClassInspection */
|
42 |
/**
|
43 |
* Fix for grid pager count believing there is only 1 item when $collection->getSelect()->groupBy() has been used
|
44 |
*
|
51 |
$this->_renderFilters();
|
52 |
|
53 |
$countSelect = clone $this->getSelect();
|
54 |
+
/** @noinspection PhpUndefinedClassInspection */
|
55 |
$countSelect->reset(Zend_Db_Select::ORDER);
|
56 |
+
/** @noinspection PhpUndefinedClassInspection */
|
57 |
$countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
|
58 |
+
/** @noinspection PhpUndefinedClassInspection */
|
59 |
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
|
60 |
+
/** @noinspection PhpUndefinedClassInspection */
|
61 |
$countSelect->reset(Zend_Db_Select::COLUMNS);
|
62 |
|
63 |
+
/** @noinspection PhpUndefinedClassInspection */
|
64 |
if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
|
65 |
+
/** @noinspection PhpUndefinedClassInspection */
|
66 |
$countSelect->reset(Zend_Db_Select::GROUP);
|
67 |
$countSelect->distinct(true);
|
68 |
+
/** @noinspection PhpUndefinedClassInspection */
|
69 |
$group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
|
70 |
$countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
|
71 |
} else {
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
@@ -235,6 +235,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
235 |
$moduleConfig = $this->_moduleConfig;
|
236 |
|
237 |
$dbVer = $resource->getDbVersion($this->_resourceName);
|
|
|
238 |
$configVer = (string) $moduleConfig->version;
|
239 |
|
240 |
$this->setDbVer($dbVer);
|
@@ -251,6 +252,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
251 |
public function applyDataUninstall()
|
252 |
{
|
253 |
$dataVer = $this->_getResource()->getDataVersion($this->_resourceName);
|
|
|
254 |
$configVer = (string)$this->_moduleConfig->version;
|
255 |
|
256 |
if ($dataVer !== false) {
|
@@ -276,8 +278,10 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
276 |
$this->_checkVersionCompatibility();
|
277 |
$this->_checkMemoryRequirement();
|
278 |
|
|
|
279 |
$helper = Mage::helper('postnl');
|
280 |
|
|
|
281 |
$inbox = Mage::getModel('postnl_admin/inbox');
|
282 |
if ($dbVer) {
|
283 |
$title = '['
|
@@ -295,6 +299,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
295 |
$url = $helper->getErrorUrl(self::SUCCESSFUL_INSTALL_ERROR_CODE );
|
296 |
}
|
297 |
|
|
|
298 |
$message = $helper->__(
|
299 |
'You can read the release notes in the <a href="%s" target="_blank" title="TIG knowledgebase">TIG ' .
|
300 |
'knowledgebase</a>.',
|
@@ -385,7 +390,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
385 |
try {
|
386 |
switch ($fileType) {
|
387 |
case 'php':
|
388 |
-
|
389 |
$result = include $fileName;
|
390 |
break;
|
391 |
case 'sql':
|
@@ -514,16 +519,16 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
514 |
* Store the cron expression in core_config_data.
|
515 |
*/
|
516 |
try {
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
} catch (Exception $e) {
|
528 |
throw new TIG_PostNL_Exception(
|
529 |
Mage::helper('postnl')->__('Unable to save shipping_status cron expression: %s', $cronExpr),
|
@@ -561,16 +566,16 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
561 |
* Store the cron expression in core_config_data
|
562 |
*/
|
563 |
try {
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
} catch (Exception $e) {
|
575 |
throw new TIG_PostNL_Exception(
|
576 |
Mage::helper('postnl')->__('Unable to save update_statistics cron expression: %s', $cronExpr),
|
@@ -594,6 +599,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
594 |
return $this;
|
595 |
}
|
596 |
|
|
|
597 |
$helper = Mage::helper('postnl');
|
598 |
if ($helper->isEnterprise()) {
|
599 |
$edition = 'enterprise';
|
@@ -601,7 +607,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
601 |
$edition = 'community';
|
602 |
}
|
603 |
|
604 |
-
$supportedVersions = Mage::getConfig()->getNode('tig/compatibility/postnl/' . $edition);
|
605 |
if ($supportedVersions === false) {
|
606 |
$this->_addUnsupportedVersionMessage();
|
607 |
|
@@ -633,6 +639,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
633 |
*/
|
634 |
protected function _addUnsupportedVersionMessage()
|
635 |
{
|
|
|
636 |
$helper = Mage::helper('postnl');
|
637 |
|
638 |
$title = '['
|
@@ -647,6 +654,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
647 |
|
648 |
$url = $helper->getErrorUrl(self::UNSUPPORTED_MAGENTO_VERSION_ERROR_CODE );
|
649 |
|
|
|
650 |
$inbox = Mage::getModel('postnl_admin/inbox');
|
651 |
$inbox->addCritical(
|
652 |
$title,
|
@@ -670,6 +678,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
670 |
return $this;
|
671 |
}
|
672 |
|
|
|
673 |
$helper = Mage::helper('postnl');
|
674 |
|
675 |
if ($helper->getMemoryLimit() < self::MIN_SERVER_MEMORY) {
|
@@ -685,6 +694,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
685 |
$memoryMb
|
686 |
);
|
687 |
|
|
|
688 |
$inbox = Mage::getModel('postnl_admin/inbox');
|
689 |
$inbox->addCritical(
|
690 |
$title,
|
@@ -756,7 +766,9 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
756 |
try {
|
757 |
$adminUser->saveExtra($extra);
|
758 |
} catch (Exception $e) {
|
759 |
-
|
|
|
|
|
760 |
}
|
761 |
|
762 |
return $this;
|
@@ -822,11 +834,11 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
822 |
public function installTestPassword()
|
823 |
{
|
824 |
$testPassword = self::DEFAULT_TEST_PASSWORD;
|
825 |
-
|
|
|
|
|
826 |
|
827 |
-
/**
|
828 |
-
* @var Mage_Core_Model_Config_Data $config
|
829 |
-
*/
|
830 |
$config = Mage::getModel('core/config_data')
|
831 |
->load(self::XPATH_TEST_PASSWORD, 'path');
|
832 |
|
@@ -845,11 +857,11 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
845 |
public function installWebshopId()
|
846 |
{
|
847 |
$testWebshopId = self::DEFAULT_WEBSHOP_ID;
|
848 |
-
|
|
|
|
|
849 |
|
850 |
-
/**
|
851 |
-
* @var Mage_Core_Model_Config_Data $config
|
852 |
-
*/
|
853 |
$config = Mage::getModel('core/config_data')
|
854 |
->load(self::XPATH_WEBSHOP_ID, 'path');
|
855 |
|
@@ -891,6 +903,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
891 |
foreach ($stores as $store) {
|
892 |
$scopeId = $store->getId();
|
893 |
|
|
|
894 |
$this->moveConfigSettingForScope($fromXpath, $toXpath, $scope, $scopeId, $removeOldValue, $defaultValue);
|
895 |
}
|
896 |
|
@@ -904,12 +917,14 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
904 |
foreach ($websites as $website) {
|
905 |
$scopeId = $website->getId();
|
906 |
|
|
|
907 |
$this->moveConfigSettingForScope($fromXpath, $toXpath, $scope, $scopeId, $removeOldValue, $defaultValue);
|
908 |
}
|
909 |
|
910 |
/**
|
911 |
* Finally, try to move the config setting for the default scope.
|
912 |
*/
|
|
|
913 |
$this->moveConfigSettingForScope(
|
914 |
$fromXpath,
|
915 |
$toXpath,
|
@@ -1059,6 +1074,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1059 |
$transactionSave = Mage::getResourceModel('core/transaction');
|
1060 |
|
1061 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
|
|
|
1062 |
foreach ($postnlShipmentCollection as $shipment) {
|
1063 |
try {
|
1064 |
/**
|
@@ -1066,7 +1082,9 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1066 |
*/
|
1067 |
$shipment->getOrderId();
|
1068 |
} catch (Exception $e) {
|
1069 |
-
|
|
|
|
|
1070 |
continue;
|
1071 |
}
|
1072 |
|
@@ -1094,6 +1112,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1094 |
$transactionSave = Mage::getResourceModel('core/transaction');
|
1095 |
|
1096 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
|
|
|
1097 |
foreach ($postnlShipmentCollection as $shipment) {
|
1098 |
try {
|
1099 |
/**
|
@@ -1101,7 +1120,9 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1101 |
*/
|
1102 |
$shipment->getShipmentType();
|
1103 |
} catch (Exception $e) {
|
1104 |
-
|
|
|
|
|
1105 |
continue;
|
1106 |
}
|
1107 |
|
@@ -1127,6 +1148,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1127 |
$transactionSave = Mage::getResourceModel('core/transaction');
|
1128 |
|
1129 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
|
|
|
1130 |
foreach ($postnlShipmentCollection as $shipment) {
|
1131 |
/**
|
1132 |
* Set the 'is_buspakje' flag to false for all existing shipments.
|
@@ -1159,8 +1181,11 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1159 |
* @var Mage_Admin_Model_Rules $role
|
1160 |
*/
|
1161 |
foreach ($adminRoles as $role) {
|
1162 |
-
$rules
|
|
|
|
|
1163 |
$rules->addFieldToFilter('permission', array('eq' => 'allow'));
|
|
|
1164 |
$resources = $rules->getColumnValues('resource_id');
|
1165 |
|
1166 |
/**
|
@@ -1197,10 +1222,12 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1197 |
/**
|
1198 |
* Save the role.
|
1199 |
*/
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
|
|
|
|
1204 |
}
|
1205 |
|
1206 |
return $this;
|
@@ -1285,6 +1312,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1285 |
/**
|
1286 |
* Get all products which are of the specified types.
|
1287 |
*/
|
|
|
1288 |
$productCollection = Mage::getResourceModel('catalog/product_collection')
|
1289 |
->addStoreFilter(Mage_Core_Model_App::ADMIN_STORE_ID)
|
1290 |
->addFieldToFilter(
|
@@ -1297,8 +1325,9 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1297 |
/**
|
1298 |
* Update the attributes of these products.
|
1299 |
*/
|
1300 |
-
|
1301 |
-
|
|
|
1302 |
|
1303 |
return $this;
|
1304 |
}
|
@@ -1349,16 +1378,16 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1349 |
* Store the cron expression in core_config_data.
|
1350 |
*/
|
1351 |
try {
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
} catch (Exception $e) {
|
1363 |
throw new TIG_PostNL_Exception(
|
1364 |
Mage::helper('postnl')->__('Unable to save update_product_attribute cron expression: %s', $cronExpr),
|
@@ -1382,7 +1411,9 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1382 |
try {
|
1383 |
Mage::getResourceModel('postnl_carrier/matrixrate')->import($data);
|
1384 |
} catch (Exception $e) {
|
1385 |
-
|
|
|
|
|
1386 |
}
|
1387 |
|
1388 |
return $this;
|
@@ -1461,11 +1492,15 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1461 |
)
|
1462 |
);
|
1463 |
} catch (Exception $e) {
|
1464 |
-
|
|
|
|
|
1465 |
}
|
1466 |
}
|
1467 |
} catch (Exception $e) {
|
1468 |
-
|
|
|
|
|
1469 |
}
|
1470 |
|
1471 |
return $this;
|
@@ -1495,7 +1530,9 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1495 |
)
|
1496 |
);
|
1497 |
} catch (Exception $e) {
|
1498 |
-
|
|
|
|
|
1499 |
}
|
1500 |
|
1501 |
try {
|
@@ -1525,11 +1562,15 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1525 |
)
|
1526 |
);
|
1527 |
} catch (Exception $e) {
|
1528 |
-
|
|
|
|
|
1529 |
}
|
1530 |
}
|
1531 |
} catch (Exception $e) {
|
1532 |
-
|
|
|
|
|
1533 |
}
|
1534 |
|
1535 |
return $this;
|
@@ -1564,16 +1605,16 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1564 |
* Store the cron expression in core_config_data.
|
1565 |
*/
|
1566 |
try {
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
} catch (Exception $e) {
|
1578 |
throw new TIG_PostNL_Exception(
|
1579 |
Mage::helper('postnl')->__('Unable to save return_status cron expression: %s', $cronExpr),
|
@@ -1630,16 +1671,15 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1630 |
* Store the cron expression in core_config_data.
|
1631 |
*/
|
1632 |
try {
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
Mage::getModel('core/config_data')
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
->save();
|
1643 |
} catch (Exception $e) {
|
1644 |
throw new TIG_PostNL_Exception(
|
1645 |
Mage::helper('postnl')->__('Unable to save update_date_time_zone cron expression: %s', $cronExpr),
|
@@ -1678,7 +1718,79 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
|
1678 |
)
|
1679 |
);
|
1680 |
} catch (Exception $e) {
|
1681 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1682 |
}
|
1683 |
|
1684 |
return $this;
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
235 |
$moduleConfig = $this->_moduleConfig;
|
236 |
|
237 |
$dbVer = $resource->getDbVersion($this->_resourceName);
|
238 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
239 |
$configVer = (string) $moduleConfig->version;
|
240 |
|
241 |
$this->setDbVer($dbVer);
|
252 |
public function applyDataUninstall()
|
253 |
{
|
254 |
$dataVer = $this->_getResource()->getDataVersion($this->_resourceName);
|
255 |
+
/** @noinspection PhpUndefinedFieldInspection */
|
256 |
$configVer = (string)$this->_moduleConfig->version;
|
257 |
|
258 |
if ($dataVer !== false) {
|
278 |
$this->_checkVersionCompatibility();
|
279 |
$this->_checkMemoryRequirement();
|
280 |
|
281 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
282 |
$helper = Mage::helper('postnl');
|
283 |
|
284 |
+
/** @var TIG_PostNL_Model_Admin_Inbox $inbox */
|
285 |
$inbox = Mage::getModel('postnl_admin/inbox');
|
286 |
if ($dbVer) {
|
287 |
$title = '['
|
299 |
$url = $helper->getErrorUrl(self::SUCCESSFUL_INSTALL_ERROR_CODE );
|
300 |
}
|
301 |
|
302 |
+
/** @noinspection HtmlUnknownTarget */
|
303 |
$message = $helper->__(
|
304 |
'You can read the release notes in the <a href="%s" target="_blank" title="TIG knowledgebase">TIG ' .
|
305 |
'knowledgebase</a>.',
|
390 |
try {
|
391 |
switch ($fileType) {
|
392 |
case 'php':
|
393 |
+
/** @noinspection PhpIncludeInspection */
|
394 |
$result = include $fileName;
|
395 |
break;
|
396 |
case 'sql':
|
519 |
* Store the cron expression in core_config_data.
|
520 |
*/
|
521 |
try {
|
522 |
+
/** @var Mage_Core_Model_Config_Data $configData */
|
523 |
+
$configData = Mage::getModel('core/config_data')->load(self::SHIPPING_STATUS_CRON_STRING_PATH, 'path');
|
524 |
+
$configData->setValue($cronExpr)
|
525 |
+
->setPath(self::SHIPPING_STATUS_CRON_STRING_PATH)
|
526 |
+
->save();
|
527 |
+
|
528 |
+
$configData = Mage::getModel('core/config_data')->load(self::SHIPPING_STATUS_CRON_MODEL_PATH, 'path');
|
529 |
+
$configData->setValue((string) Mage::getConfig()->getNode(self::SHIPPING_STATUS_CRON_MODEL_PATH))
|
530 |
+
->setPath(self::SHIPPING_STATUS_CRON_MODEL_PATH)
|
531 |
+
->save();
|
532 |
} catch (Exception $e) {
|
533 |
throw new TIG_PostNL_Exception(
|
534 |
Mage::helper('postnl')->__('Unable to save shipping_status cron expression: %s', $cronExpr),
|
566 |
* Store the cron expression in core_config_data
|
567 |
*/
|
568 |
try {
|
569 |
+
/** @var Mage_Core_Model_Config_Data $configData */
|
570 |
+
$configData = Mage::getModel('core/config_data')->load(self::UPDATE_STATISTICS_CRON_STRING_PATH, 'path');
|
571 |
+
$configData->setValue($cronExpr)
|
572 |
+
->setPath(self::UPDATE_STATISTICS_CRON_STRING_PATH)
|
573 |
+
->save();
|
574 |
+
|
575 |
+
$configData = Mage::getModel('core/config_data')->load(self::UPDATE_STATISTICS_CRON_MODEL_PATH, 'path');
|
576 |
+
$configData->setValue((string) Mage::getConfig()->getNode(self::UPDATE_STATISTICS_CRON_MODEL_PATH))
|
577 |
+
->setPath(self::UPDATE_STATISTICS_CRON_MODEL_PATH)
|
578 |
+
->save();
|
579 |
} catch (Exception $e) {
|
580 |
throw new TIG_PostNL_Exception(
|
581 |
Mage::helper('postnl')->__('Unable to save update_statistics cron expression: %s', $cronExpr),
|
599 |
return $this;
|
600 |
}
|
601 |
|
602 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
603 |
$helper = Mage::helper('postnl');
|
604 |
if ($helper->isEnterprise()) {
|
605 |
$edition = 'enterprise';
|
607 |
$edition = 'community';
|
608 |
}
|
609 |
|
610 |
+
$supportedVersions = Mage::getConfig()->getNode('tig/compatibility/postnl/magento/' . $edition);
|
611 |
if ($supportedVersions === false) {
|
612 |
$this->_addUnsupportedVersionMessage();
|
613 |
|
639 |
*/
|
640 |
protected function _addUnsupportedVersionMessage()
|
641 |
{
|
642 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
643 |
$helper = Mage::helper('postnl');
|
644 |
|
645 |
$title = '['
|
654 |
|
655 |
$url = $helper->getErrorUrl(self::UNSUPPORTED_MAGENTO_VERSION_ERROR_CODE );
|
656 |
|
657 |
+
/** @var TIG_PostNL_Model_Admin_Inbox $inbox */
|
658 |
$inbox = Mage::getModel('postnl_admin/inbox');
|
659 |
$inbox->addCritical(
|
660 |
$title,
|
678 |
return $this;
|
679 |
}
|
680 |
|
681 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
682 |
$helper = Mage::helper('postnl');
|
683 |
|
684 |
if ($helper->getMemoryLimit() < self::MIN_SERVER_MEMORY) {
|
694 |
$memoryMb
|
695 |
);
|
696 |
|
697 |
+
/** @var TIG_PostNL_Model_Admin_Inbox $inbox */
|
698 |
$inbox = Mage::getModel('postnl_admin/inbox');
|
699 |
$inbox->addCritical(
|
700 |
$title,
|
766 |
try {
|
767 |
$adminUser->saveExtra($extra);
|
768 |
} catch (Exception $e) {
|
769 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
770 |
+
$helper = Mage::helper('postnl');
|
771 |
+
$helper->logException($e);
|
772 |
}
|
773 |
|
774 |
return $this;
|
834 |
public function installTestPassword()
|
835 |
{
|
836 |
$testPassword = self::DEFAULT_TEST_PASSWORD;
|
837 |
+
/** @var Mage_Core_Helper_Data $helper */
|
838 |
+
$helper = Mage::helper('core');
|
839 |
+
$encryptedPassword = $helper->encrypt($testPassword);
|
840 |
|
841 |
+
/** @var Mage_Core_Model_Config_Data $config */
|
|
|
|
|
842 |
$config = Mage::getModel('core/config_data')
|
843 |
->load(self::XPATH_TEST_PASSWORD, 'path');
|
844 |
|
857 |
public function installWebshopId()
|
858 |
{
|
859 |
$testWebshopId = self::DEFAULT_WEBSHOP_ID;
|
860 |
+
/** @var Mage_Core_Helper_Data $helper */
|
861 |
+
$helper = Mage::helper('core');
|
862 |
+
$encryptedWebshopId = $helper->encrypt($testWebshopId);
|
863 |
|
864 |
+
/** @var Mage_Core_Model_Config_Data $config */
|
|
|
|
|
865 |
$config = Mage::getModel('core/config_data')
|
866 |
->load(self::XPATH_WEBSHOP_ID, 'path');
|
867 |
|
903 |
foreach ($stores as $store) {
|
904 |
$scopeId = $store->getId();
|
905 |
|
906 |
+
/** @noinspection PhpDeprecationInspection */
|
907 |
$this->moveConfigSettingForScope($fromXpath, $toXpath, $scope, $scopeId, $removeOldValue, $defaultValue);
|
908 |
}
|
909 |
|
917 |
foreach ($websites as $website) {
|
918 |
$scopeId = $website->getId();
|
919 |
|
920 |
+
/** @noinspection PhpDeprecationInspection */
|
921 |
$this->moveConfigSettingForScope($fromXpath, $toXpath, $scope, $scopeId, $removeOldValue, $defaultValue);
|
922 |
}
|
923 |
|
924 |
/**
|
925 |
* Finally, try to move the config setting for the default scope.
|
926 |
*/
|
927 |
+
/** @noinspection PhpDeprecationInspection */
|
928 |
$this->moveConfigSettingForScope(
|
929 |
$fromXpath,
|
930 |
$toXpath,
|
1074 |
$transactionSave = Mage::getResourceModel('core/transaction');
|
1075 |
|
1076 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
|
1077 |
+
/** @var Mage_Sales_Model_Order_Shipment $shipment */
|
1078 |
foreach ($postnlShipmentCollection as $shipment) {
|
1079 |
try {
|
1080 |
/**
|
1082 |
*/
|
1083 |
$shipment->getOrderId();
|
1084 |
} catch (Exception $e) {
|
1085 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1086 |
+
$helper = Mage::helper('postnl');
|
1087 |
+
$helper->logException($e);
|
1088 |
continue;
|
1089 |
}
|
1090 |
|
1112 |
$transactionSave = Mage::getResourceModel('core/transaction');
|
1113 |
|
1114 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
|
1115 |
+
/** @var TIG_PostNL_Model_Core_Shipment $shipment */
|
1116 |
foreach ($postnlShipmentCollection as $shipment) {
|
1117 |
try {
|
1118 |
/**
|
1120 |
*/
|
1121 |
$shipment->getShipmentType();
|
1122 |
} catch (Exception $e) {
|
1123 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1124 |
+
$helper = Mage::helper('postnl');
|
1125 |
+
$helper->logException($e);
|
1126 |
continue;
|
1127 |
}
|
1128 |
|
1148 |
$transactionSave = Mage::getResourceModel('core/transaction');
|
1149 |
|
1150 |
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
|
1151 |
+
/** @var TIG_PostNL_Model_Core_Shipment $shipment */
|
1152 |
foreach ($postnlShipmentCollection as $shipment) {
|
1153 |
/**
|
1154 |
* Set the 'is_buspakje' flag to false for all existing shipments.
|
1181 |
* @var Mage_Admin_Model_Rules $role
|
1182 |
*/
|
1183 |
foreach ($adminRoles as $role) {
|
1184 |
+
/** @var Mage_Admin_Model_Resource_Rules_Collection $rules */
|
1185 |
+
$rules = Mage::getResourceModel('admin/rules_collection');
|
1186 |
+
$rules->getByRoles($role->getId());
|
1187 |
$rules->addFieldToFilter('permission', array('eq' => 'allow'));
|
1188 |
+
|
1189 |
$resources = $rules->getColumnValues('resource_id');
|
1190 |
|
1191 |
/**
|
1222 |
/**
|
1223 |
* Save the role.
|
1224 |
*/
|
1225 |
+
/** @var Mage_Admin_Model_Rules $rulesModel */
|
1226 |
+
$rulesModel = Mage::getModel('admin/rules');
|
1227 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1228 |
+
$rulesModel->setRoleId($role->getId())
|
1229 |
+
->setResources($resources)
|
1230 |
+
->saveRel();
|
1231 |
}
|
1232 |
|
1233 |
return $this;
|
1312 |
/**
|
1313 |
* Get all products which are of the specified types.
|
1314 |
*/
|
1315 |
+
/** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
|
1316 |
$productCollection = Mage::getResourceModel('catalog/product_collection')
|
1317 |
->addStoreFilter(Mage_Core_Model_App::ADMIN_STORE_ID)
|
1318 |
->addFieldToFilter(
|
1325 |
/**
|
1326 |
* Update the attributes of these products.
|
1327 |
*/
|
1328 |
+
/** @var Mage_Catalog_Model_Product_Action $productAction */
|
1329 |
+
$productAction = Mage::getSingleton('catalog/product_action');
|
1330 |
+
$productAction->updateAttributes($productCollection->getAllIds(), $attributesData, Mage_Core_Model_App::ADMIN_STORE_ID);
|
1331 |
|
1332 |
return $this;
|
1333 |
}
|
1378 |
* Store the cron expression in core_config_data.
|
1379 |
*/
|
1380 |
try {
|
1381 |
+
/** @var Mage_Core_Model_Config_Data $configData */
|
1382 |
+
$configData = Mage::getModel('core/config_data')->load(self::UPDATE_PRODUCT_ATTRIBUTE_STRING_PATH, 'path');
|
1383 |
+
$configData->setValue($cronExpr)
|
1384 |
+
->setPath(self::UPDATE_PRODUCT_ATTRIBUTE_STRING_PATH)
|
1385 |
+
->save();
|
1386 |
+
|
1387 |
+
$configData = Mage::getModel('core/config_data')->load(self::UPDATE_PRODUCT_ATTRIBUTE_MODEL_PATH, 'path');
|
1388 |
+
$configData->setValue((string) Mage::getConfig()->getNode(self::UPDATE_PRODUCT_ATTRIBUTE_MODEL_PATH))
|
1389 |
+
->setPath(self::UPDATE_PRODUCT_ATTRIBUTE_MODEL_PATH)
|
1390 |
+
->save();
|
1391 |
} catch (Exception $e) {
|
1392 |
throw new TIG_PostNL_Exception(
|
1393 |
Mage::helper('postnl')->__('Unable to save update_product_attribute cron expression: %s', $cronExpr),
|
1411 |
try {
|
1412 |
Mage::getResourceModel('postnl_carrier/matrixrate')->import($data);
|
1413 |
} catch (Exception $e) {
|
1414 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1415 |
+
$helper = Mage::helper('postnl');
|
1416 |
+
$helper->logException($e);
|
1417 |
}
|
1418 |
|
1419 |
return $this;
|
1492 |
)
|
1493 |
);
|
1494 |
} catch (Exception $e) {
|
1495 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1496 |
+
$helper = Mage::helper('postnl');
|
1497 |
+
$helper->logException($e);
|
1498 |
}
|
1499 |
}
|
1500 |
} catch (Exception $e) {
|
1501 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1502 |
+
$helper = Mage::helper('postnl');
|
1503 |
+
$helper->logException($e);
|
1504 |
}
|
1505 |
|
1506 |
return $this;
|
1530 |
)
|
1531 |
);
|
1532 |
} catch (Exception $e) {
|
1533 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1534 |
+
$helper = Mage::helper('postnl');
|
1535 |
+
$helper->logException($e);
|
1536 |
}
|
1537 |
|
1538 |
try {
|
1562 |
)
|
1563 |
);
|
1564 |
} catch (Exception $e) {
|
1565 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1566 |
+
$helper = Mage::helper('postnl');
|
1567 |
+
$helper->logException($e);
|
1568 |
}
|
1569 |
}
|
1570 |
} catch (Exception $e) {
|
1571 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1572 |
+
$helper = Mage::helper('postnl');
|
1573 |
+
$helper->logException($e);
|
1574 |
}
|
1575 |
|
1576 |
return $this;
|
1605 |
* Store the cron expression in core_config_data.
|
1606 |
*/
|
1607 |
try {
|
1608 |
+
/** @var Mage_Core_Model_Config_Data $configData */
|
1609 |
+
$configData = Mage::getModel('core/config_data')->load(self::RETURN_STATUS_CRON_STRING_PATH, 'path');
|
1610 |
+
$configData->setValue($cronExpr)
|
1611 |
+
->setPath(self::RETURN_STATUS_CRON_STRING_PATH)
|
1612 |
+
->save();
|
1613 |
+
|
1614 |
+
$configData = Mage::getModel('core/config_data')->load(self::RETURN_STATUS_CRON_MODEL_PATH, 'path');
|
1615 |
+
$configData->setValue((string) Mage::getConfig()->getNode(self::RETURN_STATUS_CRON_MODEL_PATH))
|
1616 |
+
->setPath(self::RETURN_STATUS_CRON_MODEL_PATH)
|
1617 |
+
->save();
|
1618 |
} catch (Exception $e) {
|
1619 |
throw new TIG_PostNL_Exception(
|
1620 |
Mage::helper('postnl')->__('Unable to save return_status cron expression: %s', $cronExpr),
|
1671 |
* Store the cron expression in core_config_data.
|
1672 |
*/
|
1673 |
try {
|
1674 |
+
/** @var Mage_Core_Model_Config_Data $configData */
|
1675 |
+
$configData = Mage::getModel('core/config_data')->load(self::UPDATE_DATE_TIME_ZONE_STRING_PATH, 'path');
|
1676 |
+
$configData->setValue($cronExpr)
|
1677 |
+
->setPath(self::UPDATE_DATE_TIME_ZONE_STRING_PATH)
|
1678 |
+
->save();
|
1679 |
+
$configData = Mage::getModel('core/config_data')->load(self::UPDATE_DATE_TIME_ZONE_MODEL_PATH, 'path');
|
1680 |
+
$configData->setValue((string) Mage::getConfig()->getNode(self::UPDATE_DATE_TIME_ZONE_MODEL_PATH))
|
1681 |
+
->setPath(self::UPDATE_DATE_TIME_ZONE_MODEL_PATH)
|
1682 |
+
->save();
|
|
|
1683 |
} catch (Exception $e) {
|
1684 |
throw new TIG_PostNL_Exception(
|
1685 |
Mage::helper('postnl')->__('Unable to save update_date_time_zone cron expression: %s', $cronExpr),
|
1718 |
)
|
1719 |
);
|
1720 |
} catch (Exception $e) {
|
1721 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1722 |
+
$helper = Mage::helper('postnl');
|
1723 |
+
$helper->logException($e);
|
1724 |
+
}
|
1725 |
+
|
1726 |
+
return $this;
|
1727 |
+
}
|
1728 |
+
|
1729 |
+
/**
|
1730 |
+
* Set the shipping duration to -1 for all products that currently use 'use config'.
|
1731 |
+
*
|
1732 |
+
* @return $this
|
1733 |
+
*/
|
1734 |
+
public function setUseConfigShippingDuration()
|
1735 |
+
{
|
1736 |
+
$conn = $this->getConnection();
|
1737 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */
|
1738 |
+
$attribute = Mage::getResourceModel('catalog/product')->getAttribute('postnl_shipping_duration');
|
1739 |
+
|
1740 |
+
$conn->update(
|
1741 |
+
$attribute->getResource()->getTable(
|
1742 |
+
array(
|
1743 |
+
$attribute->getEntity()->getEntityTablePrefix(),
|
1744 |
+
$attribute->getBackendType()
|
1745 |
+
)
|
1746 |
+
),
|
1747 |
+
array(
|
1748 |
+
'value' => -1,
|
1749 |
+
),
|
1750 |
+
array(
|
1751 |
+
'attribute_id = ?' => $attribute->getAttributeId(),
|
1752 |
+
'value IS NULL OR value = ?' => '',
|
1753 |
+
)
|
1754 |
+
);
|
1755 |
+
|
1756 |
+
return $this;
|
1757 |
+
}
|
1758 |
+
|
1759 |
+
/**
|
1760 |
+
* @param array $data
|
1761 |
+
*
|
1762 |
+
* @return $this
|
1763 |
+
* @throws Exception
|
1764 |
+
* @throws TIG_PostNL_Exception
|
1765 |
+
*/
|
1766 |
+
public function updateAttributeData(array $data)
|
1767 |
+
{
|
1768 |
+
foreach ($data as $attributeCode => $attributeData) {
|
1769 |
+
/**
|
1770 |
+
* Load the attribute by the specified attribute code.
|
1771 |
+
*/
|
1772 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */
|
1773 |
+
$attribute = Mage::getResourceModel('catalog/product')->getAttribute($attributeCode);
|
1774 |
+
if (!$attribute || !$attribute->getId()) {
|
1775 |
+
/**
|
1776 |
+
* If the attribute could not be found, throw an exception.
|
1777 |
+
*/
|
1778 |
+
/** @var TIG_PostNL_Helper_Data $helper */
|
1779 |
+
$helper = Mage::helper('postnl');
|
1780 |
+
throw new TIG_PostNL_Exception(
|
1781 |
+
$helper->__('No attribute found with attribute code %s.', $attributeCode),
|
1782 |
+
'POSTNL-0241'
|
1783 |
+
);
|
1784 |
+
}
|
1785 |
+
|
1786 |
+
/**
|
1787 |
+
* Set the specified attribute data.
|
1788 |
+
*/
|
1789 |
+
foreach ($attributeData as $key => $value) {
|
1790 |
+
$attribute->setDataUsingMethod($key, $value);
|
1791 |
+
}
|
1792 |
+
|
1793 |
+
$attribute->save();
|
1794 |
}
|
1795 |
|
1796 |
return $this;
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_System_Config_Backend_Checkbox extends Mage_Core_Model_Config_Data
|
@@ -52,4 +52,4 @@ class TIG_PostNL_Model_System_Config_Backend_Checkbox extends Mage_Core_Model_Co
|
|
52 |
|
53 |
return parent::_beforeSave();
|
54 |
}
|
55 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
class TIG_PostNL_Model_System_Config_Backend_Checkbox extends Mage_Core_Model_Config_Data
|
52 |
|
53 |
return parent::_beforeSave();
|
54 |
}
|
55 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
@@ -68,4 +68,4 @@ class TIG_PostNL_Model_System_Config_Source_Testlive
|
|
68 |
);
|
69 |
return $array;
|
70 |
}
|
71 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
68 |
);
|
69 |
return $array;
|
70 |
}
|
71 |
+
}
|
@@ -33,7 +33,7 @@
|
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
-
* @copyright Copyright (c)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
@@ -60,4 +60,4 @@ class TIG_PostNL_Model_System_Config_Source_Yesno
|
|
60 |
);
|
61 |
return $array;
|
62 |
}
|
63 |
-
}
|
33 |
* versions in the future. If you wish to customize this module for your
|
34 |
* needs please contact servicedesk@tig.nl for more information.
|
35 |
*
|
36 |
+
* @copyright Copyright (c) 2016 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
*/
|
39 |
|
60 |
);
|
61 |
return $array;
|
62 |
}
|
63 |
+
}
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2015 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Test_Block_DeliveryOptions_Checkout_AddPhoneNumberTest extends TIG_PostNL_Test_Framework_TIG_Test_TestCase
|
40 |
+
{
|
41 |
+
protected $_class = 'TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber';
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber
|
45 |
+
*/
|
46 |
+
protected function _getInstance()
|
47 |
+
{
|
48 |
+
return new $this->_class();
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @test
|
53 |
+
*/
|
54 |
+
public function blockShouldBeTheRightInstance()
|
55 |
+
{
|
56 |
+
$block = $this->_getInstance();
|
57 |
+
|
58 |
+
$this->assertInstanceOf($this->_class, $block);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @test
|
63 |
+
*/
|
64 |
+
public function shouldGetTemplatePath()
|
65 |
+
{
|
66 |
+
$block = $this->_getInstance();
|
67 |
+
|
68 |
+
$template = $block->getTemplate();
|
69 |
+
$this->assertEquals('TIG/PostNL/delivery_options/addphonenumber.phtml', $template);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @test
|
74 |
+
*/
|
75 |
+
public function templateSHouldBeSettable()
|
76 |
+
{
|
77 |
+
$block = $this->_getInstance();
|
78 |
+
$block->setTemplate('test');
|
79 |
+
|
80 |
+
$template = $block->getTemplate();
|
81 |
+
$this->assertEquals('test', $template);
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @test
|
86 |
+
*/
|
87 |
+
public function shouldGetPhoneNumber()
|
88 |
+
{
|
89 |
+
$block = $this->_getInstance();
|
90 |
+
|
91 |
+
$block->setPhoneNumber('test');
|
92 |
+
|
93 |
+
$this->assertEquals('test', $block->getPhoneNumber());
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* @test
|
98 |
+
*/
|
99 |
+
public function shouldGetPhoneFromAddress()
|
100 |
+
{
|
101 |
+
$block = $this->_getInstance();
|
102 |
+
|
103 |
+
$mockAddress = $this->getMock('Mage_Sales_Model_Quote_Address', array('getTelephone'));
|
104 |
+
$mockAddress->expects($this->once())
|
105 |
+
->method('getTelephone')
|
106 |
+
->will($this->returnValue('testNumber'));
|
107 |
+
|
108 |
+
$block->setShippingAddress($mockAddress);
|
109 |
+
|
110 |
+
$this->assertEquals('testNumber', $block->getPhoneNumber());
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* @test
|
115 |
+
*/
|
116 |
+
public function shouldGetEmptyPhoneFromAddressWhenPhoneIsASingleDash()
|
117 |
+
{
|
118 |
+
$block = $this->_getInstance();
|
119 |
+
|
120 |
+
$mockAddress = $this->getMock('Mage_Sales_Model_Quote_Address', array('getTelephone'));
|
121 |
+
$mockAddress->expects($this->once())
|
122 |
+
->method('getTelephone')
|
123 |
+
->will($this->returnValue('-'));
|
124 |
+
|
125 |
+
$block->setShippingAddress($mockAddress);
|
126 |
+
|
127 |
+
$this->assertEquals('', $block->getPhoneNumber());
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* @test
|
132 |
+
*/
|
133 |
+
public function shouldGetAddressFromQuote()
|
134 |
+
{
|
135 |
+
$block = $this->_getInstance();
|
136 |
+
|
137 |
+
$mockAddress = $this->getMock('Mage_Sales_Model_Quote_Address');
|
138 |
+
|
139 |
+
$mockQuote = $this->getMock('Mage_Sales_Model_Quote');
|
140 |
+
$mockQuote->expects($this->once())
|
141 |
+
->method('getShippingAddress')
|
142 |
+
->will($this->returnValue($mockAddress));
|
143 |
+
|
144 |
+
$block->setQuote($mockQuote);
|
145 |
+
|
146 |
+
$this->assertInstanceOf('Mage_Sales_Model_Quote_Address', $block->getShippingAddress());
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* @test
|
151 |
+
*/
|
152 |
+
public function shouldGetEmptyAddressWithoutAQuote()
|
153 |
+
{
|
154 |
+
$block = $this->_getInstance();
|
155 |
+
|
156 |
+
$block->setQuote('');
|
157 |
+
|
158 |
+
$this->assertInstanceOf('Mage_Sales_Model_Quote_Address', $block->getShippingAddress());
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @test
|
163 |
+
*/
|
164 |
+
public function shouldGetQuoteFromSession()
|
165 |
+
{
|
166 |
+
$this->markTestSkipped('Skip this test');
|
167 |
+
|
168 |
+
$block = $this->_getInstance();
|
169 |
+
|
170 |
+
$this->registerMockSessions(array('checkout'));
|
171 |
+
|
172 |
+
$mockQuote = $this->getMock('Mage_Sales_Model_Quote');
|
173 |
+
|
174 |
+
$mockSession = Mage::getSingleton('checkout/session');
|
175 |
+
$mockSession->expects($this->once())
|
176 |
+
->method('getQuote')
|
177 |
+
->will($this->returnValue($mockQuote));
|
178 |
+
|
179 |
+
$this->assertInstanceOf('Mage_Sales_Model_Quote', $block->getQuote());
|
180 |
+
}
|
181 |
+
}
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2015 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Test_Block_DeliveryOptions_JsTest extends TIG_PostNL_Test_Framework_TIG_Test_TestCase
|
40 |
+
{
|
41 |
+
protected $_class = 'TIG_PostNL_Block_DeliveryOptions_Js';
|
42 |
+
|
43 |
+
protected function _getInstance()
|
44 |
+
{
|
45 |
+
return new $this->_class;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @test
|
50 |
+
*/
|
51 |
+
public function apiKeyShouldBeReturned()
|
52 |
+
{
|
53 |
+
$block = $this->_getInstance();
|
54 |
+
|
55 |
+
$block->setApiKey('test');
|
56 |
+
|
57 |
+
$this->assertEquals('test', $block->getApiKey());
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @test
|
62 |
+
*/
|
63 |
+
public function apiKeyShouldBeReturnedFromConfig()
|
64 |
+
{
|
65 |
+
$storeCode = Mage::app()->getStore()->getCode();
|
66 |
+
Mage::app()->getConfig()->setNode("stores/{$storeCode}/postnl/google_maps/api_key", 'keyTest');
|
67 |
+
|
68 |
+
$block = $this->_getInstance();
|
69 |
+
|
70 |
+
$this->assertEquals('keyTest', $block->getApiKey());
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @test
|
75 |
+
*
|
76 |
+
* @dataProvider trueAndFalse
|
77 |
+
*/
|
78 |
+
public function shouldOnlyRenderIfDeliveryOptionsAreAvailable($returnValue)
|
79 |
+
{
|
80 |
+
$this->markTestSkipped('Skip this test');
|
81 |
+
|
82 |
+
$this->registerMockSessions(array('checkout'));
|
83 |
+
|
84 |
+
$mockQuote = $this->getMock('Mage_Sales_Model_Quote');
|
85 |
+
|
86 |
+
$mockSession = Mage::getSingleton('checkout/session');
|
87 |
+
$mockSession->expects($this->once())
|
88 |
+
->method('getQuote')
|
89 |
+
->will($this->returnValue($mockQuote));
|
90 |
+
|
91 |
+
$mockHelper = $this->getMock('TIG_PostNL_Helper_DeliveryOptions', array('canUseDeliveryOptions'));
|
92 |
+
$mockHelper->expects($this->once())
|
93 |
+
->method('canUseDeliveryOptions')
|
94 |
+
->withAnyParameters()
|
95 |
+
->will($this->returnValue($returnValue));
|
96 |
+
|
97 |
+
$this->setHelperMock('postnl/deliveryOptions', $mockHelper);
|
98 |
+
|
99 |
+
$html = $this->_getInstance()->toHtml();
|
100 |
+
|
101 |
+
if ($returnValue === false) {
|
102 |
+
$this->assertTrue(empty($html), 'Expected script to not render');
|
103 |
+
} else {
|
104 |
+
$rendered = strpos($html, '<script');
|
105 |
+
$this->assertTrue($rendered !== false, 'Expected script to render');
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* @return array
|
111 |
+
*/
|
112 |
+
public function trueAndFalse()
|
113 |
+
{
|
114 |
+
return array(
|
115 |
+
array(true),
|
116 |
+
array(false),
|
117 |
+
);
|
118 |
+
}
|
119 |
+
}
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2015 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Test_Controllers_AddressValidationControllerTest extends TIG_PostNL_Test_Framework_TIG_Test_TestCase
|
40 |
+
{
|
41 |
+
protected $_class = 'TIG_PostNL_AddressValidationController';
|
42 |
+
|
43 |
+
public static function setUpBeforeClass()
|
44 |
+
{
|
45 |
+
require_once(__DIR__ . '/../../controllers/AddressValidationController.php');
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _getInstance($data = array())
|
49 |
+
{
|
50 |
+
$this->prepareFrontendDispatch();
|
51 |
+
$request = Mage::app()->getRequest();
|
52 |
+
$request->setPost($data);
|
53 |
+
|
54 |
+
$response = Mage::app()->getResponse();
|
55 |
+
|
56 |
+
return new $this->_class($request, $response);
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @test
|
61 |
+
*/
|
62 |
+
public function shouldBeTheRightClass()
|
63 |
+
{
|
64 |
+
$controller = $this->_getInstance();
|
65 |
+
|
66 |
+
$this->assertInstanceOf('TIG_PostNL_AddressValidationController', $controller);
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @test
|
71 |
+
*/
|
72 |
+
public function shouldRejectWithoutAjax()
|
73 |
+
{
|
74 |
+
$controller = $this->_getInstance(array('postcode' => '1043AJ', 'housenumber' => 8));
|
75 |
+
$controller->postcodeCheckAction();
|
76 |
+
|
77 |
+
$body = Mage::app()->getResponse()->getBody();
|
78 |
+
$dataMissing = strpos($body, 'missing_data');
|
79 |
+
|
80 |
+
$this->assertTrue($dataMissing !== false, 'Check AJAX fails!');
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @test
|
85 |
+
*/
|
86 |
+
public function shouldRejectWithoutPostcode()
|
87 |
+
{
|
88 |
+
$controller = $this->_getInstance(array('isAjax' => true));
|
89 |
+
$controller->postcodeCheckAction();
|
90 |
+
|
91 |
+
$body = Mage::app()->getResponse()->getBody();
|
92 |
+
$dataMissing = strpos($body, 'missing_data');
|
93 |
+
|
94 |
+
$this->assertTrue($dataMissing !== false, 'Check data fails!');
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @test
|
99 |
+
*/
|
100 |
+
public function shouldValidatePostcodeSuccess()
|
101 |
+
{
|
102 |
+
$controller = $this->_getInstance();
|
103 |
+
|
104 |
+
$valid = $controller->validatePostcode('1043AJ', 8);
|
105 |
+
$this->assertTrue($valid, 'Failed to validate postcode');
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @test
|
110 |
+
*
|
111 |
+
* @dataProvider validatePostcodeFailures
|
112 |
+
*/
|
113 |
+
public function shouldValidatePostcodeFail($data)
|
114 |
+
{
|
115 |
+
$controller = $this->_getInstance();
|
116 |
+
$valid = $controller->validatePostcode($data[0], $data[1]);
|
117 |
+
$this->assertTrue(!$valid, 'Failed to validate postcode failure');
|
118 |
+
}
|
119 |
+
|
120 |
+
public function validatePostcodeFailures()
|
121 |
+
{
|
122 |
+
return array(
|
123 |
+
array('1043 AJ', 8),
|
124 |
+
array('1043AJ', 'test'),
|
125 |
+
array('1043AJ', '8f'),
|
126 |
+
array('1043', 8)
|
127 |
+
);
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* @test
|
132 |
+
*/
|
133 |
+
public function shouldValidateResultSuccess()
|
134 |
+
{
|
135 |
+
$controller = $this->_getInstance();
|
136 |
+
|
137 |
+
$data = new StdClass();
|
138 |
+
$data->woonplaats = 'test';
|
139 |
+
$data->straatnaam = 'teststraat';
|
140 |
+
|
141 |
+
$valid = $controller->validateResult($data);
|
142 |
+
|
143 |
+
$this->assertTrue($valid, 'Failed to validate result');
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @test
|
148 |
+
*/
|
149 |
+
public function shouldValidateResultFail()
|
150 |
+
{
|
151 |
+
$controller = $this->_getInstance();
|
152 |
+
|
153 |
+
$data = new StdClass();
|
154 |
+
$data->woonplaats = '';
|
155 |
+
$data->straatnaam = '';
|
156 |
+
|
157 |
+
$valid = $controller->validateResult($data);
|
158 |
+
|
159 |
+
$this->assertTrue(!$valid, 'Failed to invalidate result');
|
160 |
+
}
|
161 |
+
}
|
@@ -0,0 +1,559 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2015 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Test_Controllers_DeliveryOptionsControllerTest extends TIG_PostNL_Test_Framework_TIG_Test_TestCase
|
40 |
+
{
|
41 |
+
protected $_class = 'TIG_PostNL_DeliveryOptionsController';
|
42 |
+
|
43 |
+
public static function setUpBeforeClass()
|
44 |
+
{
|
45 |
+
require_once(__DIR__ . '/../../controllers/DeliveryOptionsController.php');
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @param array $data
|
50 |
+
*
|
51 |
+
* @return TIG_PostNL_DeliveryOptionsController
|
52 |
+
*/
|
53 |
+
protected function _getInstance($data = array())
|
54 |
+
{
|
55 |
+
$this->prepareFrontendDispatch();
|
56 |
+
$request = Mage::app()->getRequest();
|
57 |
+
$request->setPost($data);
|
58 |
+
|
59 |
+
$response = Mage::app()->getResponse();
|
60 |
+
|
61 |
+
return new $this->_class($request, $response);
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @test
|
66 |
+
*/
|
67 |
+
public function shouldBeTheRightClass()
|
68 |
+
{
|
69 |
+
$controller = $this->_getInstance();
|
70 |
+
|
71 |
+
$this->assertInstanceOf('TIG_PostNL_DeliveryOptionsController', $controller);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @test
|
76 |
+
*/
|
77 |
+
public function shouldGetValidTypes()
|
78 |
+
{
|
79 |
+
$controller = $this->_getInstance();
|
80 |
+
|
81 |
+
$validTypes = $controller->getValidTypes();
|
82 |
+
$this->assertTrue(is_array($validTypes));
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @test
|
87 |
+
*/
|
88 |
+
public function shouldGetSpecificValidTypes()
|
89 |
+
{
|
90 |
+
$controller = $this->_getInstance();
|
91 |
+
|
92 |
+
$controller->setValidTypes(array('test'));
|
93 |
+
$validTypes = $controller->getValidTypes();
|
94 |
+
|
95 |
+
$this->assertTrue(in_array('test', $validTypes));
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @test
|
100 |
+
*/
|
101 |
+
public function saveSelectedOptionActionShouldBeCallable()
|
102 |
+
{
|
103 |
+
$instance = $this->_getInstance();
|
104 |
+
$isCallable = is_callable((array($instance, 'saveSelectedOptionAction')));
|
105 |
+
|
106 |
+
$this->assertTrue($isCallable);
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* @test
|
111 |
+
*
|
112 |
+
* @depends saveSelectedOptionActionShouldBeCallable
|
113 |
+
*/
|
114 |
+
public function shouldRejectSaveSelectedOptionActionWithoutAjax()
|
115 |
+
{
|
116 |
+
$controller = $this->_getInstance();
|
117 |
+
$controller->setCanUseDeliveryOptions(true);
|
118 |
+
$controller->saveSelectedOptionAction();
|
119 |
+
|
120 |
+
$body = Mage::app()->getResponse()->getBody();
|
121 |
+
$dataMissing = strpos($body, 'not_allowed');
|
122 |
+
|
123 |
+
$this->assertTrue($dataMissing !== false, 'Check AJAX fails!');
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* @test
|
128 |
+
*
|
129 |
+
* @depends saveSelectedOptionActionShouldBeCallable
|
130 |
+
*/
|
131 |
+
public function shouldRejextSaveSelectedOptionActionIfUnableToUseDeliveryOptions()
|
132 |
+
{
|
133 |
+
$this->markTestSkipped('Skip this test');
|
134 |
+
|
135 |
+
$controller = $this->_getInstance(array('isAjax' => true));
|
136 |
+
$controller->setCanUseDeliveryOptions(false);
|
137 |
+
$controller->saveSelectedOptionAction();
|
138 |
+
|
139 |
+
$body = Mage::app()->getResponse()->getBody();
|
140 |
+
$dataMissing = strpos($body, 'not_allowed');
|
141 |
+
|
142 |
+
$this->assertTrue($dataMissing !== false);
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* @param $data
|
147 |
+
* @param $success
|
148 |
+
*
|
149 |
+
* @test
|
150 |
+
*
|
151 |
+
* @depends saveSelectedOptionActionShouldBeCallable
|
152 |
+
*
|
153 |
+
* @dataProvider saveSelectedPostDataWithoutAddressProvider
|
154 |
+
*/
|
155 |
+
public function shouldValidatePostDataWithoutAnAddress($data, $success)
|
156 |
+
{
|
157 |
+
$this->markTestSkipped('Skip this test');
|
158 |
+
|
159 |
+
$controller = $this->_getInstance($data);
|
160 |
+
|
161 |
+
$mockService = $this->getMock('TIG_PostNL_Model_DeliveryOptions_Service');
|
162 |
+
if ($success) {
|
163 |
+
$mockService->expects($this->once())
|
164 |
+
->method('saveDeliveryOption')
|
165 |
+
->withAnyParameters()
|
166 |
+
->will($this->returnSelf());
|
167 |
+
}
|
168 |
+
|
169 |
+
$mockCoreHelper = $this->getMock('Mage_Core_Helper_Data');
|
170 |
+
$mockCoreHelper->expects($this->any())
|
171 |
+
->method('jsonDecode')
|
172 |
+
->withAnyParameters()
|
173 |
+
->will($this->returnArgument(0));
|
174 |
+
$this->setHelperMock('core', $mockCoreHelper);
|
175 |
+
|
176 |
+
$controller->setService($mockService);
|
177 |
+
|
178 |
+
$controller->setCanUseDeliveryOptions(true);
|
179 |
+
|
180 |
+
$controller->saveSelectedOptionAction();
|
181 |
+
|
182 |
+
$body = Mage::app()->getResponse()->getBody();
|
183 |
+
|
184 |
+
if ($success) {
|
185 |
+
$this->assertTrue(strpos($body, 'OK') !== false);
|
186 |
+
} else {
|
187 |
+
$this->assertTrue(strpos($body, 'invalid_data') !== false);
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* @return array
|
193 |
+
*/
|
194 |
+
public function saveSelectedPostDataWithoutAddressProvider()
|
195 |
+
{
|
196 |
+
return array(
|
197 |
+
array(
|
198 |
+
'data' => array(
|
199 |
+
'isAjax' => true,
|
200 |
+
'type' => 'PGE',
|
201 |
+
'date' => '18-03-2014',
|
202 |
+
'costs' => array(
|
203 |
+
'incl' => 1,
|
204 |
+
'excl' => 0.5
|
205 |
+
),
|
206 |
+
),
|
207 |
+
true
|
208 |
+
),
|
209 |
+
array(
|
210 |
+
'data' => array(
|
211 |
+
'isAjax' => true,
|
212 |
+
'type' => 'testfail',
|
213 |
+
'date' => '18-03-2014',
|
214 |
+
'costs' => array(
|
215 |
+
'incl' => 1,
|
216 |
+
'excl' => 0.5
|
217 |
+
),
|
218 |
+
),
|
219 |
+
false
|
220 |
+
),
|
221 |
+
array(
|
222 |
+
'data' => array(
|
223 |
+
'isAjax' => true,
|
224 |
+
'type' => 'PGE',
|
225 |
+
'date' => '180-03-2014',
|
226 |
+
'costs' => array(
|
227 |
+
'incl' => 1,
|
228 |
+
'excl' => 0.5
|
229 |
+
),
|
230 |
+
),
|
231 |
+
false
|
232 |
+
),
|
233 |
+
array(
|
234 |
+
'data' => array(
|
235 |
+
'isAjax' => true,
|
236 |
+
'type' => 'PGE',
|
237 |
+
'date' => '18-03-2014',
|
238 |
+
'costs' => array(
|
239 |
+
'incl' => '1,50',
|
240 |
+
'excl' => '1,50'
|
241 |
+
),
|
242 |
+
),
|
243 |
+
false
|
244 |
+
),
|
245 |
+
);
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* @test
|
250 |
+
*/
|
251 |
+
public function saveOptionCostsActionShouldBeCallable()
|
252 |
+
{
|
253 |
+
$instance = $this->_getInstance();
|
254 |
+
$isCallable = is_callable((array($instance, 'saveOptionCostsAction')));
|
255 |
+
|
256 |
+
$this->assertTrue($isCallable);
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* @test
|
261 |
+
*
|
262 |
+
* @depends saveOptionCostsActionShouldBeCallable
|
263 |
+
*/
|
264 |
+
public function shouldRejectSaveOptionCostsActionWithoutAjax()
|
265 |
+
{
|
266 |
+
$this->markTestSkipped('Skip this test');
|
267 |
+
|
268 |
+
$controller = $this->_getInstance();
|
269 |
+
$controller->setCanUseDeliveryOptions(true);
|
270 |
+
$controller->saveOptionCostsAction();
|
271 |
+
|
272 |
+
$body = Mage::app()->getResponse()->getBody();
|
273 |
+
$dataMissing = strpos($body, 'not_allowed');
|
274 |
+
|
275 |
+
$this->assertTrue($dataMissing !== false, 'Check AJAX fails!');
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* @test
|
280 |
+
*
|
281 |
+
* @depends saveSelectedOptionActionShouldBeCallable
|
282 |
+
*/
|
283 |
+
public function shouldRejectSaveOptionCostsActionIfUnableToUseDeliveryOptions()
|
284 |
+
{
|
285 |
+
$this->markTestSkipped('Skip this test');
|
286 |
+
|
287 |
+
$controller = $this->_getInstance(array('isAjax' => true));
|
288 |
+
$controller->setCanUseDeliveryOptions(false);
|
289 |
+
$controller->saveOptionCostsAction();
|
290 |
+
|
291 |
+
$body = Mage::app()->getResponse()->getBody();
|
292 |
+
$dataMissing = strpos($body, 'not_allowed');
|
293 |
+
|
294 |
+
$this->assertTrue($dataMissing !== false);
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* @test
|
299 |
+
*
|
300 |
+
* @depends saveOptionCostsActionShouldBeCallable
|
301 |
+
*
|
302 |
+
* @dataProvider saveOptionCostsDataProvider
|
303 |
+
*/
|
304 |
+
public function shouldValidatePostDataForSaveOptionCostsAction($data, $success)
|
305 |
+
{
|
306 |
+
$this->markTestSkipped('Skip this test');
|
307 |
+
|
308 |
+
$controller = $this->_getInstance($data);
|
309 |
+
|
310 |
+
$mockService = $this->getMock('TIG_PostNL_Model_DeliveryOptions_Service');
|
311 |
+
if ($success) {
|
312 |
+
$mockService->expects($this->once())
|
313 |
+
->method('saveOptionCosts')
|
314 |
+
->withAnyParameters()
|
315 |
+
->will($this->returnSelf());
|
316 |
+
}
|
317 |
+
|
318 |
+
$mockCoreHelper = $this->getMock('Mage_Core_Helper_Data');
|
319 |
+
$mockCoreHelper->expects($this->any())
|
320 |
+
->method('jsonDecode')
|
321 |
+
->withAnyParameters()
|
322 |
+
->will($this->returnArgument(0));
|
323 |
+
$this->setHelperMock('core', $mockCoreHelper);
|
324 |
+
|
325 |
+
$controller->setService($mockService);
|
326 |
+
|
327 |
+
$controller->setCanUseDeliveryOptions(true);
|
328 |
+
|
329 |
+
$controller->saveOptionCostsAction();
|
330 |
+
|
331 |
+
$body = Mage::app()->getResponse()->getBody();
|
332 |
+
|
333 |
+
if ($success) {
|
334 |
+
$this->assertTrue(strpos($body, 'OK') !== false);
|
335 |
+
} else {
|
336 |
+
$this->assertTrue(strpos($body, 'invalid_data') !== false);
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* @return array
|
342 |
+
*/
|
343 |
+
public function saveOptionCostsDataProvider()
|
344 |
+
{
|
345 |
+
return array(
|
346 |
+
array(
|
347 |
+
'data' => array(
|
348 |
+
'isAjax' => true,
|
349 |
+
'costs' => array(
|
350 |
+
'incl' => 1,
|
351 |
+
'excl' => 0.5
|
352 |
+
),
|
353 |
+
),
|
354 |
+
'success' => true
|
355 |
+
),
|
356 |
+
array(
|
357 |
+
'data' => array(
|
358 |
+
'isAjax' => true,
|
359 |
+
'costs' => array(
|
360 |
+
'incl' => 1,
|
361 |
+
'excl' => 0.5
|
362 |
+
),
|
363 |
+
),
|
364 |
+
'success' => true
|
365 |
+
),
|
366 |
+
array(
|
367 |
+
'data' => array(
|
368 |
+
'isAjax' => true,
|
369 |
+
'costs' => array(
|
370 |
+
'incl' => 1,
|
371 |
+
'excl' => 0.5
|
372 |
+
),
|
373 |
+
),
|
374 |
+
'success' => true
|
375 |
+
),
|
376 |
+
array(
|
377 |
+
'data' => array(
|
378 |
+
'isAjax' => true,
|
379 |
+
'costs' => array(
|
380 |
+
'incl' => 3,
|
381 |
+
'excl' => 3
|
382 |
+
),
|
383 |
+
),
|
384 |
+
'success' => false
|
385 |
+
),
|
386 |
+
array(
|
387 |
+
'data' => array(
|
388 |
+
'isAjax' => true,
|
389 |
+
'costs' => array(
|
390 |
+
'incl' => 'test',
|
391 |
+
'excl' => 'test'
|
392 |
+
),
|
393 |
+
),
|
394 |
+
'success' => false
|
395 |
+
),
|
396 |
+
array(
|
397 |
+
'data' => array(
|
398 |
+
'isAjax' => true,
|
399 |
+
'costs' => array(
|
400 |
+
'incl' => '1test',
|
401 |
+
'excl' => '1test'
|
402 |
+
),
|
403 |
+
),
|
404 |
+
'success' => false
|
405 |
+
),
|
406 |
+
array(
|
407 |
+
'data' => array(
|
408 |
+
'isAjax' => true,
|
409 |
+
'costs' => array(),
|
410 |
+
),
|
411 |
+
'success' => false
|
412 |
+
),
|
413 |
+
);
|
414 |
+
}
|
415 |
+
|
416 |
+
/**
|
417 |
+
* @test
|
418 |
+
*/
|
419 |
+
public function savePhoneActionShouldBeCallable()
|
420 |
+
{
|
421 |
+
$instance = $this->_getInstance();
|
422 |
+
$isCallable = is_callable((array($instance, 'savePhoneNumberAction')));
|
423 |
+
|
424 |
+
$this->assertTrue($isCallable);
|
425 |
+
}
|
426 |
+
|
427 |
+
/**
|
428 |
+
* @test
|
429 |
+
*
|
430 |
+
* @depends savePhoneActionShouldBeCallable
|
431 |
+
*/
|
432 |
+
public function shouldRejectSavePhoneActionWithoutAjax()
|
433 |
+
{
|
434 |
+
$controller = $this->_getInstance();
|
435 |
+
$controller->setCanUseDeliveryOptions(true);
|
436 |
+
$controller->savePhoneNumberAction();
|
437 |
+
|
438 |
+
$body = Mage::app()->getResponse()->getBody();
|
439 |
+
$dataMissing = strpos($body, 'not_allowed');
|
440 |
+
|
441 |
+
$this->assertTrue($dataMissing !== false, 'Check AJAX fails!');
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* @test
|
446 |
+
*
|
447 |
+
* @depends savePhoneActionShouldBeCallable
|
448 |
+
*/
|
449 |
+
public function shouldRejectSavePhoneActionIfUnableToUseDeliveryOptions()
|
450 |
+
{
|
451 |
+
$controller = $this->_getInstance(array('isAjax' => true));
|
452 |
+
$controller->setCanUseDeliveryOptions(false);
|
453 |
+
$controller->savePhoneNumberAction();
|
454 |
+
|
455 |
+
$body = Mage::app()->getResponse()->getBody();
|
456 |
+
$dataMissing = strpos($body, 'not_allowed');
|
457 |
+
|
458 |
+
$this->assertTrue($dataMissing !== false);
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* @test
|
463 |
+
*
|
464 |
+
* @depends savePhoneActionShouldBeCallable
|
465 |
+
*
|
466 |
+
* @dataProvider savePhoneDataProvider
|
467 |
+
*/
|
468 |
+
public function shouldValidatePostDataForSavePhoneAction($data, $success)
|
469 |
+
{
|
470 |
+
$controller = $this->_getInstance($data);
|
471 |
+
|
472 |
+
$mockService = $this->getMock('TIG_PostNL_Model_DeliveryOptions_Service');
|
473 |
+
if ($success) {
|
474 |
+
$mockService->expects($this->once())
|
475 |
+
->method('saveMobilePhoneNumber')
|
476 |
+
->withAnyParameters()
|
477 |
+
->will($this->returnSelf());
|
478 |
+
}
|
479 |
+
|
480 |
+
$controller->setService($mockService);
|
481 |
+
|
482 |
+
$controller->setCanUseDeliveryOptions(true);
|
483 |
+
|
484 |
+
$controller->savePhoneNumberAction();
|
485 |
+
|
486 |
+
$body = Mage::app()->getResponse()->getBody();
|
487 |
+
|
488 |
+
if ($success) {
|
489 |
+
$this->assertTrue(strpos($body, 'OK') !== false);
|
490 |
+
} else {
|
491 |
+
$this->assertTrue(strpos($body, 'invalid_data') !== false);
|
492 |
+
}
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* @return array
|
497 |
+
*/
|
498 |
+
public function savePhoneDataProvider()
|
499 |
+
{
|
500 |
+
return array(
|
501 |
+
array(
|
502 |
+
'data' => array(
|
503 |
+
'isAjax' => true,
|
504 |
+
'number' => '0612345678'
|
505 |
+
),
|
506 |
+
true,
|
507 |
+
),
|
508 |
+
array(
|
509 |
+
'data' => array(
|
510 |
+
'isAjax' => true,
|
511 |
+
'number' => '0031612345678'
|
512 |
+
),
|
513 |
+
true,
|
514 |
+
),
|
515 |
+
array(
|
516 |
+
'data' => array(
|
517 |
+
'isAjax' => true,
|
518 |
+
'number' => '+31612345678'
|
519 |
+
),
|
520 |
+
true,
|
521 |
+
),
|
522 |
+
array(
|
523 |
+
'data' => array(
|
524 |
+
'isAjax' => true,
|
525 |
+
'number' => '061234567'
|
526 |
+
),
|
527 |
+
false,
|
528 |
+
),
|
529 |
+
array(
|
530 |
+
'data' => array(
|
531 |
+
'isAjax' => true,
|
532 |
+
'number' => '061 234567'
|
533 |
+
),
|
534 |
+
false,
|
535 |
+
),
|
536 |
+
array(
|
537 |
+
'data' => array(
|
538 |
+
'isAjax' => true,
|
539 |
+
'number' => '06-1234567'
|
540 |
+
),
|
541 |
+
false,
|
542 |
+
),
|
543 |
+
array(
|
544 |
+
'data' => array(
|
545 |
+
'isAjax' => true,
|
546 |
+
'number' => ''
|
547 |
+
),
|
548 |
+
false,
|
549 |
+
),
|
550 |
+
array(
|
551 |
+
'data' => array(
|
552 |
+
'isAjax' => true,
|
553 |
+
'number' => 'test'
|
554 |
+
),
|
555 |
+
false,
|
556 |
+
),
|
557 |
+
);
|
558 |
+
}
|
559 |
+
}
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2015 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Test_Framework_TIG_Test_Config extends Mage_Core_Model_Config
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var array
|
43 |
+
*/
|
44 |
+
protected $_mockModels = array();
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @var array
|
48 |
+
*/
|
49 |
+
protected $_mockResourceModels = array();
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param string $modelClass
|
53 |
+
* @param object $mock
|
54 |
+
*
|
55 |
+
* @return $this
|
56 |
+
*/
|
57 |
+
public function setModelMock($modelClass, $mock)
|
58 |
+
{
|
59 |
+
$this->_mockModels[$modelClass] = $mock;
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @param string $modelClass
|
65 |
+
* @param object $mock
|
66 |
+
*
|
67 |
+
* @return $this
|
68 |
+
*/
|
69 |
+
public function setResourceModelMock($modelClass, $mock)
|
70 |
+
{
|
71 |
+
$this->_mockResourceModels[$modelClass] = $mock;
|
72 |
+
return $this;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @param string $modelClass
|
77 |
+
* @param array $constructArguments
|
78 |
+
*
|
79 |
+
* @return false|Mage_Core_Model_Abstract
|
80 |
+
*/
|
81 |
+
public function getModelInstance($modelClass = '', $constructArguments = array())
|
82 |
+
{
|
83 |
+
$modelClass = (string) $modelClass;
|
84 |
+
|
85 |
+
if (array_key_exists($modelClass, $this->_mockModels)) {
|
86 |
+
return $this->_mockModels[$modelClass];
|
87 |
+
}
|
88 |
+
|
89 |
+
return parent::getModelInstance($modelClass, $constructArguments);
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Get resource model object by alias
|
94 |
+
*
|
95 |
+
* @param string $modelClass
|
96 |
+
* @param array $constructArguments
|
97 |
+
* @return object
|
98 |
+
*/
|
99 |
+
public function getResourceModelInstance($modelClass='', $constructArguments = array())
|
100 |
+
{
|
101 |
+
$modelClass = (string) $modelClass;
|
102 |
+
|
103 |
+
if (array_key_exists($modelClass, $this->_mockResourceModels)) {
|
104 |
+
return $this->_mockResourceModels[$modelClass];
|
105 |
+
}
|
106 |
+
|
107 |
+
return parent::getResourceModelInstance($modelClass, $constructArguments);
|
108 |
+
}
|
109 |
+
}
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@tig.nl so we can send you a copy immediately.
|
29 |
+
*
|
30 |
+
* DISCLAIMER
|
31 |
+
*
|
32 |
+
* Do not edit or add to this file if you wish to upgrade this module to newer
|
33 |
+
* versions in the future. If you wish to customize this module for your
|
34 |
+
* needs please contact servicedesk@tig.nl for more information.
|
35 |
+
*
|
36 |
+
* @copyright Copyright (c) 2015 Total Internet Group B.V. (http://www.tig.nl)
|
37 |
+
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
+
*/
|
39 |
+
class TIG_PostNL_Test_Framework_TIG_Test_Http_Response extends Mage_Core_Controller_Response_Http
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var bool
|
43 |
+
*/
|
44 |
+
protected $_headersSent = false;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param boolean $headersSent
|
48 |
+
*
|
49 |
+
* @return TIG_Test_Http_Response
|
50 |
+
*/
|
51 |
+
public function setHeadersSent($headersSent)
|
52 |
+
{
|
53 |
+
$this->_headersSent = $headersSent;
|
54 |
+
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @retur
|