From e383885c4b39b93d36fa4691cd3f182705e77039 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Tue, 5 May 2015 22:52:36 +0200 Subject: [PATCH] Add readme.txt, fix issues with both versions installed, make it ready for the first release --- .gitignore | 1 + LICENSE.txt | 674 ++++++++++++++++++++++++++ Makefile | 38 ++ README | 12 - assets/css/ordernumber-config.css | 39 ++ assets/images/advlogo100.png | Bin 0 -> 10748 bytes library/ordernumber_helper.php | 90 ++-- ordernumber_helper_woocommerce.php | 1 - ordernumbers_woocommerce.php | 367 ++------------ ordernumbers_woocommerce_basic.php | 460 ++++++++++++++++++ readme.txt | 76 +++ woocommerce-advanced-ordernumbers.php | 28 +- woocommerce-custom-ordernumbers.php | 48 ++ 13 files changed, 1459 insertions(+), 375 deletions(-) create mode 100644 LICENSE.txt create mode 100644 Makefile delete mode 100644 README create mode 100644 assets/css/ordernumber-config.css create mode 100644 assets/images/advlogo100.png create mode 100644 ordernumbers_woocommerce_basic.php create mode 100644 readme.txt create mode 100644 woocommerce-custom-ordernumbers.php diff --git a/.gitignore b/.gitignore index f1abe92..cdaa235 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Material sync.sh +.build diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..089395a --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +BASE=ordernumbers +PLATTFORM=woocommerce +VENDOR=opentools +VERSION=1.0 +DIR = $(shell pwd) + + +BUILDDIR=.build/ +BASICBUILDDIR=$(VENDOR)-$(PLATTFORM)-$(BASE)-basic +ADVBUILDDIR=$(VENDOR)-$(PLATTFORM)-$(BASE)-advanced + +PLUGINFILES=library/ assets/ ordernumber_helper_woocommerce.php ordernumbers_woocommerce_basic.php readme.txt LICENSE.txt +BASICPLUGINFILES=woocommerce-custom-ordernumbers.php +ADVPLUGINFILES=woocommerce-advanced-ordernumbers.php ordernumbers_woocommerce.php + +TRANSLATIONS= + +ZIPFILE=$(VENDOR)-$(PLATTFORM)-$(BASE)-basic_v$(VERSION).zip +ADVZIPFILE=$(VENDOR)-$(PLATTFORM)-$(BASE)-advanced_v$(VERSION).zip + +all: zip + +zip: $(PLUGINFILES) $(ADVPLUGINFILES) $(BASICPLUGINFILES) $(TRANSLATIONS) + echo $(DIR) + @echo "Packing basic plugin version into distribution file $(ZIPFILE):" + mkdir -p $(BUILDDIR)/$(BASICBUILDDIR) + cp --parents -r $(PLUGINFILES) $(BASICPLUGINFILES) $(TRANSLATIONS) $(BUILDDIR)/$(BASICBUILDDIR) + cd $(BUILDDIR) && zip -r $(DIR)/$(ZIPFILE) $(BASICBUILDDIR) +# @zip -r + mkdir -p $(BUILDDIR)/$(ADVBUILDDIR) + echo `pwd`mak + cp --parents -r $(PLUGINFILES) $(ADVPLUGINFILES) $(TRANSLATIONS) $(BUILDDIR)/$(ADVBUILDDIR) + cp readme-adv.txt $(BUILDDIR)/$(ADVBUILDDIR)/readme.txt + cd $(BUILDDIR) && zip -r $(DIR)/$(ADVZIPFILE) $(ADVBUILDDIR) + cd $(DIR) + +clean: + rm -f $(ZIPFILE) $(ADVZIPFILE) $(BUILDDIR) $(ADVBUILDDIR) diff --git a/README b/README deleted file mode 100644 index 2b3e21e..0000000 --- a/README +++ /dev/null @@ -1,12 +0,0 @@ -=== Advanced Ordernumbers === -Contributors: opetools -Tags: WooCommerce, Order numbers, orders -Requires at least: 4.0 -Tested up to: 4.1.1 -Stable tag: trunk -License: GPLv2 - -Freely customize order numbers in WooCommerce. Lots of variables and counter settings can be used in the order number format. - -== Description == -Freely customize order numbers in WooCommerce. Lots of variables and counter settings can be used in the order number format. \ No newline at end of file diff --git a/assets/css/ordernumber-config.css b/assets/css/ordernumber-config.css new file mode 100644 index 0000000..d14a995 --- /dev/null +++ b/assets/css/ordernumber-config.css @@ -0,0 +1,39 @@ +div#opentools-ordernumber-upgrade { +/* margin-top: 1em; */ +/* padding-left: 15px; */ +/* border-radius: 5px; */ +/* border: 1px solid red; */ +/* background: #ff8080; */ + padding: 5px 10px; +} +div#opentools-ordernumber-upgrade.postbox { + display: inline-block; +} +div#opentools-ordernumber-upgrade h3 { + margin-top: 5px; + margin-bottom: 5px; + padding: 0px 10px 5px 10px; + border-bottom: 1px solid #e0e0e0; +} +div#opentools-ordernumber-upgrade ul { + list-style: disc; +/* list-style-position: inside; */ + margin-left: 5px; + padding-left: 5px; +} +div#opentools-ordernumber-upgrade li { + margin-left: 2em; +} +div#opentools-ordernumber-upgrade .column1, div#opentools-ordernumber-upgrade .column2 { + float: left; +} + +div#opentools-ordernumber-upgrade .logoleft { + float: left; + padding-right: 10px; + position: absolute; + left: 15px; +} +div#opentools-ordernumber-upgrade .contents { + padding-left: 120px; +} \ No newline at end of file diff --git a/assets/images/advlogo100.png b/assets/images/advlogo100.png new file mode 100644 index 0000000000000000000000000000000000000000..81b67365165ea85ca458c7da4932b804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ps(1JzPYx~~)XH1s3DpzBn{*Qryfx*+&&t;ucLK6UYpj)i~ literal 0 HcmV?d00001 diff --git a/library/ordernumber_helper.php b/library/ordernumber_helper.php index 6b92639..bd06344 100644 --- a/library/ordernumber_helper.php +++ b/library/ordernumber_helper.php @@ -9,6 +9,10 @@ if ( !defined( 'ABSPATH' ) && !defined('_JEXEC') ) { die( 'Direct Access to ' . basename( __FILE__ ) . ' is not allowed.' ); } +// NULL function to indicate translatable strings without actually doing any translation +function trl($string) { + return $string; +} class OrdernumberHelper { static $_version = "0.1"; @@ -19,6 +23,9 @@ class OrdernumberHelper { 'variable-table-class' => "", 'variable-table-style' => "", ); + protected $flags = array( + 'extract-counter-settings' => 1, + ); /** * An array containing all language keys for the translations used in the JavaScript code. * Make sure to set those in the ajax_ordernumber JavaScript array! @@ -46,6 +53,20 @@ class OrdernumberHelper { } return $helper; } + + public function setFlag($flag, $value) { + $this->flags[$flag] = $value; + } + public function getFlag($flag, $default) { + if (isset($this->flags[$flag])) { + return $this->flags[$flag]; + } else { + return $default; + } + } + public function unsetFlat($flag) { + unset($this->flags[$flag]); + } function getStyle($key) { if (isset($this->_styles[$key])) { @@ -206,7 +227,7 @@ class OrdernumberHelper { return self::randomString ($alphabet, $len); } - protected function setupDateTimeReplacements (&$reps, $details, $nrtype) { + public function setupDateTimeReplacements (&$reps, $details, $nrtype) { $utime = microtime(true); $reps["[year]"] = date ("Y", $utime); $reps["[year2]"] = date ("y", $utime); @@ -314,41 +335,44 @@ class OrdernumberHelper { } protected function extractCounterSettings ($fmt, $type, $ctrsettings) { - // First, extract all counter settings, i.e. all strings of the form [#####:startval/increment] or [####/increment:startval] - $regexp = '%\[(#+)(/([0-9]+))?(:([0-9]+))?(/([0-9]+))?\]%'; + $parts=array($fmt); + if ($this->getFlag('extract-counter-settings', true)) { + // First, extract all counter settings, i.e. all strings of the form [#####:startval/increment] or [####/increment:startval] + $regexp = '%\[(#+)(/([0-9]+))?(:([0-9]+))?(/([0-9]+))?\]%'; - if (preg_match($regexp, $fmt, $counters)) { - // $counters is an array of the form: - // Array ( - // [0] => [#####:100/3] - // [1] => ##### - // [2] => - // [3] => - // [4] => :100 - // [5] => 100 - // [6] => /3 - // [7] => 3 - // ) - $ctrsettings["${type}_padding"] = strlen($counters[1]); - if (!empty($counters[2])) { - // $counters[2] contains the whole "/n" part, while $counters[3] contains just the step itself - $ctrsettings["${type}_step"] = $counters[3]; - } - if (!empty($counters[4])) { - // $counters[4] contains the whole ":n" part, while $counters[5] contains just the start value itself - $ctrsettings["${type}_start"] = $counters[5]; - } + if (preg_match($regexp, $fmt, $counters)) { + // $counters is an array of the form: + // Array ( + // [0] => [#####:100/3] + // [1] => ##### + // [2] => + // [3] => + // [4] => :100 + // [5] => 100 + // [6] => /3 + // [7] => 3 + // ) + $ctrsettings["${type}_padding"] = strlen($counters[1]); + if (!empty($counters[2])) { + // $counters[2] contains the whole "/n" part, while $counters[3] contains just the step itself + $ctrsettings["${type}_step"] = $counters[3]; + } + if (!empty($counters[4])) { + // $counters[4] contains the whole ":n" part, while $counters[5] contains just the start value itself + $ctrsettings["${type}_start"] = $counters[5]; + } - if (!empty($counters[6])) { - // $counters[6] contains the whole ":n" part, while $counters[7] contains just the start value itself - $ctrsettings["${type}_step"] = $counters[7]; - } + if (!empty($counters[6])) { + // $counters[6] contains the whole ":n" part, while $counters[7] contains just the start value itself + $ctrsettings["${type}_step"] = $counters[7]; + } - $fmt = preg_replace($regexp, "#", $fmt); + $fmt = preg_replace($regexp, "#", $fmt); + } + // Split at a | to get the number format and a possibly different counter increment format + // If a separate counter format is given after the |, use it, otherwise reuse the number format itself as counter format + $parts = explode ("|", $fmt); } - // Split at a | to get the number format and a possibly different counter increment format - // If a separate counter format is given after the |, use it, otherwise reuse the number format itself as counter format - $parts = explode ("|", $fmt); $ctrsettings["${type}_format"] = $parts[0]; $ctrsettings["${type}_counter"] = ($ctrsettings["${type}_global"]=='yes')?"":$parts[(count($parts)>1)?1:0]; @@ -469,7 +493,7 @@ class OrdernumberHelper { 'variables_ifvar' => $this->__('PLG_ORDERNUMBER_REPL_IFVAR'), 'variables_ifop' => '', 'variables_ifval' => $this->__('PLG_ORDERNUMBER_REPL_IFVAL'), - 'variables_then' => $this->__(''), + 'variables_then' => '', 'variables_thenvar' => $this->__('PLG_ORDERNUMBER_REPL_SETVAR'), 'variables_thenval' => $this->__('PLG_ORDERNUMBER_REPL_TOVAL'), 'sort' => '', diff --git a/ordernumber_helper_woocommerce.php b/ordernumber_helper_woocommerce.php index a33ab2c..a14c2d0 100644 --- a/ordernumber_helper_woocommerce.php +++ b/ordernumber_helper_woocommerce.php @@ -82,7 +82,6 @@ class OrdernumberHelperWooCommerce extends OrdernumberHelper { if (sizeof($parts)==1) { array_unshift($parts, 'ordernumber'); } -// print("<h1>$type Counter: $name with value $value encountered, prefix=".self::$ordernumber_counter_prefix.", parts=".print_r($parts,1)."</h1>"); if ($parts[0]==$type) { $counters[] = array( 'type' => $parts[0], diff --git a/ordernumbers_woocommerce.php b/ordernumbers_woocommerce.php index 656aa22..213331f 100644 --- a/ordernumbers_woocommerce.php +++ b/ordernumbers_woocommerce.php @@ -9,116 +9,61 @@ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } -class OpenToolsOrdernumbers { - public $ordernumber_meta = "_oton_number_"; - public $ordernumber_new_placeholder = "[New Order]"; - - protected $helper = null; - protected $settings = array(); +if (!class_exists( 'OpenToolsOrdernumbersBasic' )) + require_once (dirname(__FILE__) . '/ordernumbers_woocommerce_basic.php'); +class OpenToolsOrdernumbers extends OpenToolsOrdernumbersBasic { /** * Construct the plugin object */ - public function __construct() - { - $this->helper = OrdernumberHelperWooCommerce::getHelper(); - $this->initializeSettings(); - $this->initializeHooks(); - + public function __construct($basename) { + parent::__construct($basename); + $this->is_advanced = true; + $this->helper->registerCallback('setupStoreReplacements', array($this, 'setupStoreReplacements')); $this->helper->registerCallback('setupOrderReplacements', array($this, 'setupOrderReplacements')); $this->helper->registerCallback('setupUserReplacements', array($this, 'setupUserReplacements')); $this->helper->registerCallback('setupShippingReplacements', array($this, 'setupShippingReplacements')); $this->helper->registerCallback('setupThirdPartyReplacements', array($this, 'setupThirdPartyReplacements')); } - + /** + * Override the initializeBasicSettings method, which restricts some functionality in the basic plugin. + */ + protected function initializeBasicSettings() {} + /** * Install all neccessary filters and actions for this plugin */ protected function initializeHooks() { - $helper = OrdernumberHelperWooCommerce::getHelper(); - // CONFIGURATION SCREENS - add_filter( 'woocommerce_get_sections_checkout', array($this, 'add_admin_section')); - // The checkout settings page assumes all subpages are payment gateways, so we have to override this and manually pass our settings: - add_action( 'woocommerce_settings_checkout', array( $this, 'settings_output' ) ); - add_action( 'woocommerce_settings_save_checkout', array( $this, 'settings_save' ) ); - add_action( 'woocommerce_admin_field_ordernumber_counters', array( $this, 'admin_field_counters' ) ); + parent::initializeHooks(); + + // Custom table widget for custom variable definitions: Hooks for creating and storing values add_action( 'woocommerce_admin_field_ordernumber_variables', array( $this, 'admin_field_variables' ) ); add_action( 'pre_update_option_ordernumber_variables', array( $this, 'update_option_variables')); - - add_action( 'woocommerce_order_actions', array( $this, 'add_order_action_new_number' ) ); - add_action( 'woocommerce_order_action_assign_new_ordernumber', array( $this, 'order_action_assign_new_ordernumber' ) ); - - add_action( 'admin_print_styles-woocommerce_page_wc-settings', array($helper, 'print_admin_styles')); - add_action( 'admin_print_scripts-woocommerce_page_wc-settings', array($this, 'print_admin_scripts')); - - // AJAX counter modifications - add_action( 'wp_ajax_setCounter', array($this, 'counter_set_callback') ); - add_action( 'wp_ajax_addCounter', array($this, 'counter_add_callback') ); - add_action( 'wp_ajax_deleteCounter', array($this, 'counter_delete_callback') ); - - // Add the ordernumber post meta to the search in the backend - add_filter( 'woocommerce_shop_order_search_fields', array($this, 'order_search_fields')); - // Sort the order list in the backend by order number rather than ID, make sure this is called LAST so we modify the defaults passed as arguments - add_filter( 'manage_edit-shop_order_sortable_columns', array( $this, 'modify_order_column_sortkey' ), 9999 ); - // When a new order is created, we immediately assign the order number: - add_action( 'wp_insert_post', array(&$this, 'check_assignNumber'), 10, 3); - // The filter to actually return the order number for the given order - add_filter ('woocommerce_order_number', array(&$this, 'get_ordernumber'), 10, 2/*<= Also get the order object! */); - - + // Install hooks for third-party plugin support: $this->thirdparty_wpo_wcpdf_init(); } - + protected function initializeSettingsGeneral() { + // Remove the NAG screen of the basic version + return array(); + } /** - * Setup all options and the corresponding settings UI to configure this plugin, using the WP settings API + * Return the tooltip for the number format settings textinput (the two plugin versions have different features!) */ - protected function initializeSettings() { - // Init settings - $this->settings = array( - array( - 'name' => $this->helper->__( 'Advanced Order Numbers'), - 'desc' => $this->helper->__( 'Configure the format and the counters of the order numbers in WooCommerce.'), - 'type' => 'title', - 'id' => 'ordernumber_options' - ), - - array( - 'name' => $this->helper->__( 'Customize Order Numbers'), - 'desc' => $this->helper->__( 'Check to use custom order numbers rather than the default wordpress post ID.'), - 'id' => 'customize_ordernumber', - 'type' => 'checkbox', - 'default' => 'no' - ), - array( - 'title' => $this->helper->__( 'Order number format'), - 'desc' => $this->helper->__( 'The format for the order numbers (variables can be entered as [...], the counter is indicated by the #). To use a different counter name than displayed, put the custom counter name after a |, e.g. "[year]-[month]/#|[year]" to use the month in the order number, but reset the counter only yearly. Advanced settings for the counter can be added as [#####:start/step], e.g. [#:100] to start new counters at 100, or [#/5] to increment the counter by 5. The number of # in the format determine how many digits are shown at least, e.g. [########] will always show at least 8 digits for the counter, e.g. 00000014.'), - 'desc_tip' => true, - 'id' => 'ordernumber_format', - 'default' => '#', - 'type' => 'text', - 'css' => 'width: 100%', - ), - array( - 'title' => $this->helper->__( 'Use global counter'), - 'desc' => $this->helper->__( 'A global counter never resets. Non-global counters run within each number format and reset whenever any variable changes.'), - 'id' => 'ordernumber_global', - 'type' => 'checkbox', - 'default' => 'no', - ), - array( - 'name' => $this->helper->__( 'All order number counters'), - 'desc' => $this->helper->__( 'View and modify the current counter values. The counter value is the value used for the previous number. All changes are immediately applied!'), - 'desc_tip' => true, - 'id' => 'ordernumber_counters', - 'type' => 'ordernumber_counters', - 'nrtype' => 'ordernumber', - ), - array( 'type' => 'sectionend', 'id' => 'ordernumber_options' ), - - + protected function getNumberFormatSettingsLabel() { + return $this->helper->__( 'The format for the order numbers (variables can be entered as [...], the counter is indicated by the #). To use a different counter name than displayed, put the custom counter name after a |, e.g. "[year]-[month]/#|[year]" to use the month in the order number, but reset the counter only yearly. Advanced settings for the counter can be added as [#####:start/step], e.g. [#:100] to start new counters at 100, or [#/5] to increment the counter by 5. The number of # in the format determine how many digits are shown at least, e.g. [########] will always show at least 8 digits for the counter, e.g. 00000014.'); + } + protected function initializeSettingsOther() { + return array_merge( + $this->initializeSettingsInvoiceNumbers(), + $this->initializeSettingsReplacements() + ); + } + + protected function initializeSettingsInvoiceNumbers() { + $settings = array( /** * Invoice number settings */ @@ -161,10 +106,17 @@ class OpenToolsOrdernumbers { 'type' => 'ordernumber_counters', 'nrtype' => 'invoice', ), - array( 'type' => 'sectionend', 'id' => 'invoice_options' ), - - // TODO: customize order password, and other numbers! - + array( 'type' => 'sectionend', 'id' => 'invoice_options' ) + ); + + add_option ('customize_invoice', 'no'); + add_option ('invoice_format', "#"); + add_option ('invoice_global', 'no'); + return $settings; + } + + protected function initializeSettingsReplacements() { + $settings = array( array( 'name' => $this->helper->__( 'Custom Variables'), 'desc' => $this->helper->__( 'Define your own (conditional) variables for use in the number formats'), @@ -175,62 +127,13 @@ class OpenToolsOrdernumbers { 'id' => 'ordernumber_variables', 'type' => 'ordernumber_variables', ), - array( 'type' => 'sectionend', 'id' => 'ordernumber_variables' ), - + array( 'type' => 'sectionend', 'id' => 'ordernumber_variables' ) ); - // Default options - - add_option ('customize_ordernumber', 'no'); - add_option ('ordernumber_format', "#"); - add_option ('ordernumber_global', 'no'); - - add_option ('customize_invoice', 'no'); - add_option ('invoice_format', "#"); - add_option ('invoice_global', 'no'); - add_option ('ordernumber_variables', array()); + return $settings; } - /** - * Insert our own section in the checkout setting page. Rearrange the sections array to make sure our settings - * come second place, directly after the default page with the '' key and before all the payment gateways - */ - function add_admin_section($sections) { - $newsections = array(); - foreach ($sections as $sec => $name ) { - $newsections[$sec] = $name; - if ($sec == '') { - $newsections['ordernumber'] = $this->helper->__('Order Numbers'); - } - } - return $newsections; - } - public function settings_output() { - global $current_section; - if ($current_section == 'ordernumber') { - $settings = $this->settings; - WC_Admin_Settings::output_fields( $settings ); - } - } - - public function settings_save() { - global $current_section; - if ($current_section == 'ordernumber') { - $settings = $this->settings; - WC_Admin_Settings::save_fields( $settings ); - } - } - - /** - * Print the JS for the counter values and counter variables tables to the page header in the WC backend admin setting page - */ - public function print_admin_scripts() { - $this->helper->print_admin_scripts(); - wp_register_script( 'ordernumber-admin', plugins_url('assets/js/ordernumber-config.js', __FILE__), array('jquery')); - wp_enqueue_script( 'ordernumber-admin'); - } - /** * Render the Custom Variables configuration table */ @@ -257,102 +160,7 @@ class OpenToolsOrdernumbers { return OrdernumberHelper::transposeCustomVariables($value); } - - /** - * Render the Counter Values modification table - */ - public function admin_field_counters ($settings) { - // Description handling - $field_description = WC_Admin_Settings::get_field_description( $settings ); - extract( $field_description ); - ?> - - <tr valign="top"> - <th scope="row" class="titledesc"> - <label for="<?php echo esc_attr( $settings['id'] ); ?>"><?php echo esc_html( $settings['title'] ); ?></label> - <?php echo $tooltip_html; ?> - </th> - <td class="forminp forminp-<?php echo sanitize_title( $settings['nrtype'] ) ?>"> - <?php - $counters = $this->helper->getAllCounters($settings['nrtype']); - echo $this->helper->counter_modification_create_table($settings['nrtype'], $counters); - ?> - </td> - </tr> - <?php - } - - /** - * Hook to add the order numer post meta field to the searchable field - * (so the admin can search for the order number in the backend) - */ - public function order_search_fields($fields) { - $fields[] = $this->ordernumber_meta; - return $fields; - } - - /** - * Sort the order list's "Order" column by our post meta rather than by ID - */ - public function modify_order_column_sortkey($columns) { - $columns['order_title'] = $this->ordernumber_meta; - return $columns; - } - - /** - * Add the "create new order number" action to the edit order page in the Backend - */ - public function add_order_action_new_number($actions) { - $actions['assign_new_ordernumber'] = $this->helper->__('Assign a new order number'); - return $actions; - } - /** - * Handle the "Assign a new order number" action from the edit order page in the backend - */ - public function order_action_assign_new_ordernumber( $order ) { - $number = $this->generateNumber($order->id, $order, 'ordernumber'); - } - - - /** - * Handle new posts created in the frontend. This action will be called for all posts, - * not only for orders, so we need to check explicitly. Also, this function will be called - * for order updates, so we need to check the update argument, too. - */ - public function check_assignNumber($post_id, $post, $update) { - // Is the post really an order? - // Order numbers are only assigned to orders on creation, not when updating! - if ($post->post_type != 'shop_order') { - return; - } else { - // Handle new admin-created orders, where the address is entered later on! - // Assign an order number: - $number = $this->assign_new_ordernumber($post_id, $post, $update); - } - } - - /** - * AJAX Counter handling (simple loading/storing counters), storing them as options - */ - - public function counter_delete_callback() { - $json = $this->helper->ajax_counter_delete($_POST['nrtype'], $_POST['counter']); - wp_send_json($json); - } - - public function counter_add_callback () { - $json = $this->helper->ajax_counter_add($_POST['nrtype'], $_POST['counter'], isset($_POST['value'])?$_POST['value']:"0"); - wp_send_json($json); - } - - public function counter_set_callback () { - $json = $this->helper->ajax_counter_set($_POST['nrtype'], $_POST['counter'], $_POST['value']); - wp_send_json($json); - } - - - /** *********************************************************** * * REPLACEMENT FUNCTIONS @@ -447,84 +255,6 @@ class OpenToolsOrdernumbers { $reps = apply_filters( 'opentools_ordernumber_replacements', $reps, $details, $nrtype); } - - function generateNumber($orderid, $order, $type='ordernumber') { - if (get_option('customize_'.$type, 'no')!='no') { - $fmt = get_option ($type.'_format', "#"); - $ctrsettings = array( - "${type}_format" => '', - "${type}_counter" => '', - "${type}_global" => get_option ($type.'_global', 'no'), - "${type}_padding" => 1, - "${type}_step" => 1, - "${type}_start" => 1, - ); - $customvars = get_option ('ordernumber_variables', array()); - - $number = $this->helper->createNumber ($fmt, $type, $order, $customvars, $ctrsettings); - update_post_meta( $orderid, $this->ordernumber_meta.$type, $number ); - return $number; - } else { - return $orderid; - } - } - - /** - * The hook to assign a customized order number (unless the order already has one assigned) - */ - function assign_new_ordernumber($orderid, $order, $update=true) { - if ((!$update) /*&& ($order->post_status == 'auto-draft')*/) { - // New order => assign placeholder, which will later be overwritten the real order number - update_post_meta( $orderid, $this->ordernumber_meta.'ordernumber', $this->ordernumber_new_placeholder ); - } - // If we do not have an order (yet), we cannot proceed. But we probably have created the - // ordernumber placeholder for that post, so this function has done its job and we can return - if (!$order instanceof WC_Order) { - return; - } - $number = get_post_meta( $orderid, $this->ordernumber_meta.'ordernumber', 'true'); - if ($number == $this->ordernumber_new_placeholder && $order->post_status != 'auto-draft') { - $number = $this->generateNumber($orderid, $order, 'ordernumber'); - // Assign a new number - } - return $number; - } - - function get_or_create_number($orderid, $order, $type = 'ordernumber') { - $stored_number = get_post_meta( $orderid, $this->ordernumber_meta.$type, true); - if (!empty($stored_number)) { - return $stored_number; - } else { - return $this->generateNumber($orderid, $order, $type); - } - } - - /** - * The generic function to retrieve a particular number - */ - function get_number($orderid, $order, $type = 'ordernumber') { - $stored_number = get_post_meta( $orderid, $this->ordernumber_meta.$type, 'true'); - if ($stored_number == $this->ordernumber_new_placeholder) { - // Check whether the order was now really created => create order number now - return $this->assign_new_ordernumber($orderid, $order, $type); - } elseif (!empty($stored_number)) { - // Order number already exists => simply return it - return $stored_number; - } else { - // No order number was created for this order, so simply use the orderid as default. - return $orderid; - } - } - - /** - * Callback function for Woocommerce to retrieve the ordernumber for an order - * The hook to customize order numbers (requests the order number from the database; - * creates a new ordernumber if no entry exists in the database) - */ - function get_ordernumber($orderid, $order) { - return $this->get_number($orderid, $order, 'ordernumber'); - } - /** ************************************************************ * Support for WPO WooCommerce PDF Invoices and Packaging Slips ** ************************************************************ @@ -591,8 +321,5 @@ class OpenToolsOrdernumbers { $wp_settings_fields['wpo_wcpdf_template_settings']['invoice']['display_number']['args']['description'] = $this->helper->__('To let the Open Tools ordernumber plugin create invoice numbers with your desired format, please enable invoices in <a href="admin.php?page=wc-settings&tab=checkout§ion=ordernumber">that plugin\'s configuration page</a>.' ); } } - - - - + } diff --git a/ordernumbers_woocommerce_basic.php b/ordernumbers_woocommerce_basic.php new file mode 100644 index 0000000..9825140 --- /dev/null +++ b/ordernumbers_woocommerce_basic.php @@ -0,0 +1,460 @@ +<?php +/** + * This is the actual ordernumber plugin class for WooCommerce. + * Copyright (C) 2015 Reinhold Kainhofer, Open Tools + * Author: Open Tools, Reinhold Kainhofer + * Author URI: http://open-tools.net + * License: GPL2+ +*/ +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} +require_once( plugin_dir_path( __FILE__ ) . '/ordernumber_helper_woocommerce.php'); + +class OpenToolsOrdernumbersBasic { + public $ordernumber_meta = "_oton_number_"; + public $ordernumber_new_placeholder = "[New Order]"; + public $plugin_basename = ''; + + protected $helper = null; + protected $settings = array(); + protected $is_advanced = false; + + /** + * Construct the plugin object + */ + public function __construct($basename) + { + $this->helper = OrdernumberHelperWooCommerce::getHelper(); + $this->plugin_basename = $basename; + $this->initializeBasicSettings(); + $this->initializeSettings(); + $this->initializeHooks(); + } + + /** + * Set up the functionality of the basic version of the plugin + */ + protected function initializeBasicSettings() { + $this->helper->registerCallback('setupDateTimeReplacements', array($this, 'setupDateTimeReplacements')); + + add_filter( 'plugin_row_meta', array( &$this, 'basic_ordernumber_plugin_row_meta' ), 30, 2 ); + add_filter( 'woocommerce_admin_field_opentools_ordernumbers_upgrade', array( &$this, 'admin_field_opentools_ordernumbers_upgrade') ); + $this->helper->setFlag('extract-counter-settings', false); + } + + /** + * Install all neccessary filters and actions for this plugin + */ + protected function initializeHooks() { + $helper = OrdernumberHelperWooCommerce::getHelper(); + // CONFIGURATION SCREENS + add_filter( 'woocommerce_get_sections_checkout', array( &$this, 'add_admin_section')); + // The checkout settings page assumes all subpages are payment gateways, so we have to override this and manually pass our settings: + add_action( 'woocommerce_settings_checkout', array( &$this, 'settings_output' ) ); + add_action( 'woocommerce_settings_save_checkout', array( &$this, 'settings_save' ) ); + add_action( 'woocommerce_admin_field_ordernumber_counters', array( &$this, 'admin_field_counters' ) ); + // Add links to WordPress plugins page + add_filter( 'plugin_action_links_'.$this->plugin_basename, array( &$this, 'ordernumber_add_settings_link' ) ); + add_filter( 'plugin_row_meta', array( &$this, 'ordernumber_plugin_row_meta' ), 10, 2 ); + + add_action( 'woocommerce_order_actions', array( &$this, 'add_order_action_new_number' ) ); + add_action( 'woocommerce_order_action_assign_new_ordernumber', array( &$this, 'order_action_assign_new_ordernumber' ) ); + + add_action( 'admin_print_styles-woocommerce_page_wc-settings', array( &$helper, 'print_admin_styles')); + add_action( 'admin_print_styles-woocommerce_page_wc-settings', array( &$this, 'print_admin_styles')); + add_action( 'admin_print_scripts-woocommerce_page_wc-settings', array( &$this, 'print_admin_scripts')); + + // AJAX counter modifications + add_action( 'wp_ajax_setCounter', array( &$this, 'counter_set_callback') ); + add_action( 'wp_ajax_addCounter', array( &$this, 'counter_add_callback') ); + add_action( 'wp_ajax_deleteCounter', array( &$this, 'counter_delete_callback') ); + + // Add the ordernumber post meta to the search in the backend + add_filter( 'woocommerce_shop_order_search_fields', array( &$this, 'order_search_fields')); + // Sort the order list in the backend by order number rather than ID, make sure this is called LAST so we modify the defaults passed as arguments + add_filter( 'manage_edit-shop_order_sortable_columns', array( &$this, 'modify_order_column_sortkey' ), 9999 ); + + // When a new order is created, we immediately assign the order number: + add_action( 'wp_insert_post', array( &$this, 'check_assignNumber'), 10, 3); + // The filter to actually return the order number for the given order + add_filter ('woocommerce_order_number', array( &$this, 'get_ordernumber'), 10, 2/*<= Also get the order object! */); + + } + + + /** + * Setup all options and the corresponding settings UI to configure this plugin, using the WP settings API + */ + protected function initializeSettings() { + // TODO: Call some virtual function for the upgrade NAG text... + $this->settings = array_merge( + $this->initializeSettingsGeneral(), + $this->initializeSettingsOrderNumbers(), + $this->initializeSettingsOther() + ); + } + + protected function initializeSettingsGeneral() { + // TODO: Add some kind of NAG screen to advertize the premium version + $settings = array( + array( + 'name' => $this->helper->__( 'Upgrade to the ADVANCED VERSION of the OpenTools Ordernumber plugin'), + 'desc' => $this->helper->__( 'This basic version has limited functionality...'), + 'desc_tip' => true, + 'id' => 'opentools_ordernumbers_upgrade', + 'type' => 'opentools_ordernumbers_upgrade', + 'link' => 'http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html', + ), + ); + return $settings; + } + protected function initializeSettingsOrderNumbers() { + $settings = array( + array( + 'name' => $this->helper->__( 'Configure Order Numbers'), + 'desc' => $this->helper->__( 'Configure the format and the counters of the order numbers in WooCommerce. For help, check out the plugin\'s <a href="http://open-tools.net/documentation/advanced-order-numbers-for-woocommerce.html">documentation at OpenTools</a>.'), + 'type' => 'title', + 'id' => 'ordernumber_options' + ), + + array( + 'name' => $this->helper->__( 'Customize Order Numbers'), + 'desc' => $this->helper->__( 'Check to use custom order numbers rather than the default wordpress post ID.'), + 'id' => 'customize_ordernumber', + 'type' => 'checkbox', + 'default' => 'no' + ), + array( + 'title' => $this->helper->__( 'Order number format'), + 'desc' => $this->getNumberFormatSettingsLabel(), + 'desc_tip' => true, + 'id' => 'ordernumber_format', + 'default' => '#', + 'type' => 'text', + 'css' => 'width: 100%', + ), + array( + 'title' => $this->helper->__( 'Use global counter'), + 'desc' => $this->helper->__( 'A global counter never resets. Non-global counters run within each number format and reset whenever any variable changes.'), + 'id' => 'ordernumber_global', + 'type' => 'checkbox', + 'default' => 'no', + ), + array( + 'name' => $this->helper->__( 'All order number counters'), + 'desc' => $this->helper->__( 'View and modify the current counter values. The counter value is the value used for the previous number. All changes are immediately applied!'), + 'desc_tip' => true, + 'id' => 'ordernumber_counters', + 'type' => 'ordernumber_counters', + 'nrtype' => 'ordernumber', + ), + array( 'type' => 'sectionend', 'id' => 'ordernumber_options' ) + ); + add_option ('customize_ordernumber', 'no'); + add_option ('ordernumber_format', "#"); + add_option ('ordernumber_global', 'no'); + return $settings; + } + /** + * Return the tooltip for the number format settings textinput (the two plugin versions have different features!) + */ + protected function getNumberFormatSettingsLabel() { + return $this->helper->__( 'The format for the order numbers: You can choose any text string, where the counter is indicated by # and variables by [...]. In the free version of the plugin, only the [year] and [year2] variables are available. For example, a format "WC-[year2]-#" will create order numbers "WC-15-01", "WC-15-02", "WC-15-03", ...'); + } + + protected function initializeSettingsOther() { + return array(); + } + + /** + * Add settings link to plugins page + */ + public function ordernumber_add_settings_link( $links ) { + $link = '<a href="admin.php?page=wc-settings&tab=checkout§ion=ordernumber">'. $this->helper->__( 'Settings' ) . '</a>'; + array_push( $links, $link ); + return $links; + } + public function ordernumber_plugin_row_meta( $links, $file ) { + if ($file==$this->plugin_basename) { + $links['docs'] = '<a href="' . esc_url( 'http://open-tools.net/documentation/advanced-order-numbers-for-woocommerce.html' ) . '" title="' . esc_attr( $this->helper->__( 'Plugin Documentation' ) ) . '">' . $this->helper->__( 'Plugin Documentation' ) . '</a>'; + $links['support'] = '<a href="' . esc_url( 'http://open-tools.net/support-forum/ordernumbers-for-woocommerce.html' ) . '" title="' . esc_attr( $this->helper->__( 'Support Forum' ) ) . '">' . $this->helper->__( 'Support Forum' ) . '</a>'; + } + return (array)$links; + } + + public function basic_ordernumber_plugin_row_meta( $links, $file ) { + if ($file==$this->plugin_basename && !$this->is_advanced) { + $links['advanced'] = '<a href="' . esc_url( 'http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html' ) . '" title="' . esc_attr( $this->helper->__('Purchase Advanced Version')) . '">' . $this->helper->__('Purchase Advanced Version') . '</a>'; + } + return (array)$links; + } + + /** + * Insert our own section in the checkout setting page. Rearrange the sections array to make sure our settings + * come second place, directly after the default page with the '' key and before all the payment gateways + */ + function add_admin_section($sections) { + $newsections = array(); + foreach ($sections as $sec => $name ) { + $newsections[$sec] = $name; + if ($sec == '') { + $newsections['ordernumber'] = $this->helper->__('Order Numbers'); + } + } + return $newsections; + } + + public function settings_output() { + global $current_section; + if ($current_section == 'ordernumber') { + $settings = $this->settings; + WC_Admin_Settings::output_fields( $settings ); + } + } + + public function settings_save() { + global $current_section; + if ($current_section == 'ordernumber') { + $settings = $this->settings; + WC_Admin_Settings::save_fields( $settings ); + } + } + + /** + * Print the JS for the counter values and counter variables tables to the page header in the WC backend admin setting page + */ + public function print_admin_scripts() { + $this->helper->print_admin_scripts(); + wp_register_script( 'ordernumber-admin', plugins_url('assets/js/ordernumber-config.js', __FILE__), array('jquery')); + wp_enqueue_script( 'ordernumber-admin'); + } + public function print_admin_styles() { + wp_register_style('ordernumber-wc-styles', plugins_url('assets/css/ordernumber-config.css', __FILE__)); + wp_enqueue_style('ordernumber-wc-styles'); + } + + + + + /** + * Render the Counter Values modification table + */ + public function admin_field_counters ($settings) { + // Description handling + $field_description = WC_Admin_Settings::get_field_description( $settings ); + extract( $field_description ); + ?> + + + <tr valign="top"> + <th scope="row" class="titledesc"> + <label for="<?php echo esc_attr( $settings['id'] ); ?>"><?php echo esc_html( $settings['title'] ); ?></label> + <?php echo $tooltip_html; ?> + </th> + <td class="forminp forminp-<?php echo sanitize_title( $settings['nrtype'] ) ?>"> + <?php + $counters = $this->helper->getAllCounters($settings['nrtype']); + echo $this->helper->counter_modification_create_table($settings['nrtype'], $counters); + ?> + </td> + </tr> + <?php + } + + + /** + * Render the UPGRADE TO ADVANCED VERSION nag table in the settings page + */ + public function admin_field_opentools_ordernumbers_upgrade ($settings) { + // Description handling + $field_description = WC_Admin_Settings::get_field_description( $settings ); + extract( $field_description ); + ?> + + + <tr valign="top"> + <td colspan="2"> + <div id="opentools-ordernumber-upgrade" class="postbox"> + <h3><?php echo esc_html($settings['title']); ?></h3> + <div class="contents"> + <div class="logoleft"><a href="<?php echo esc_html($settings['link']); ?>"><img src="<?php echo plugins_url('assets/images/advlogo100.png', __FILE__); ?>"></a></div> + <p>Advanced features not included in the free plugin include:</p> + <ul> + <li><b>Counter formatting</b>: initial value, counter steps, counter padding</li> + <li><b>Many variables</b>: month, day, time, address fields, order properties (amount, # of articles, shipping methods), product categories and tags, etc.</li> + <li>Multiple <b>concurrent counters</b>: Separate counters per country, per product category, etc.</li> + <li><b>Different order number formats</b> for orders with specific properties (e.g. numbers "FREE-#" for free orders)</li> + <li><b>Flexible counter resets</b>: Counter "resets" when any variable changes</li> + <li>Customize <b>invoice numbers</b> (only for the <a href="https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/">"WooCommerce PDF Invoices and Package Slips"</a> plugin)</li> + <li>...</li> + </ul> + <p>More information and purchase: <a class="button-primary" href="<?php echo esc_html($settings['link']); ?>" target="_blank">Get Support and advanced features</a></p> + </div> + </div> + </td> + </tr> + <?php + } + + + /** + * Hook to add the order numer post meta field to the searchable field + * (so the admin can search for the order number in the backend) + */ + public function order_search_fields($fields) { + $fields[] = $this->ordernumber_meta; + return $fields; + } + + /** + * Sort the order list's "Order" column by our post meta rather than by ID + */ + public function modify_order_column_sortkey($columns) { + $columns['order_title'] = $this->ordernumber_meta; + return $columns; + } + + /** + * Add the "create new order number" action to the edit order page in the Backend + */ + public function add_order_action_new_number($actions) { + $actions['assign_new_ordernumber'] = $this->helper->__('Assign a new order number'); + return $actions; + } + /** + * Handle the "Assign a new order number" action from the edit order page in the backend + */ + public function order_action_assign_new_ordernumber( $order ) { + $number = $this->generateNumber($order->id, $order, 'ordernumber'); + } + + /** + * Handle new posts created in the frontend. This action will be called for all posts, + * not only for orders, so we need to check explicitly. Also, this function will be called + * for order updates, so we need to check the update argument, too. + */ + public function check_assignNumber($post_id, $post, $update) { + // Is the post really an order? + // Order numbers are only assigned to orders on creation, not when updating! + if ($post->post_type != 'shop_order') { + return; + } else { + // Handle new admin-created orders, where the address is entered later on! + // Assign an order number: + $number = $this->assign_new_ordernumber($post_id, $post, $update); + } + } + + /** + * AJAX Counter handling (simple loading/storing counters), storing them as options + */ + + public function counter_delete_callback() { + $json = $this->helper->ajax_counter_delete($_POST['nrtype'], $_POST['counter']); + wp_send_json($json); + } + + public function counter_add_callback () { + $json = $this->helper->ajax_counter_add($_POST['nrtype'], $_POST['counter'], isset($_POST['value'])?$_POST['value']:"0"); + wp_send_json($json); + } + + public function counter_set_callback () { + $json = $this->helper->ajax_counter_set($_POST['nrtype'], $_POST['counter'], $_POST['value']); + wp_send_json($json); + } + + + + /** *********************************************************** + * + * REPLACEMENT FUNCTIONS + * + **************************************************************/ + + /* Restrict date variables to years */ + public function setupDateTimeReplacements (&$reps, $details, $nrtype) { + $utime = microtime(true); + $reps["[year]"] = date ("Y", $utime); + $reps["[year2]"] = date ("y", $utime); + } + + function generateNumber($orderid, $order, $type='ordernumber') { + if (get_option('customize_'.$type, 'no')!='no') { + $fmt = get_option ($type.'_format', "#"); + $ctrsettings = array( + "${type}_format" => '', + "${type}_counter" => '', + "${type}_global" => get_option ($type.'_global', 'no'), + "${type}_padding" => 1, + "${type}_step" => 1, + "${type}_start" => 1, + ); + $customvars = get_option ('ordernumber_variables', array()); + + $number = $this->helper->createNumber ($fmt, $type, $order, $customvars, $ctrsettings); + update_post_meta( $orderid, $this->ordernumber_meta.$type, $number ); + return $number; + } else { + return $orderid; + } + } + + /** + * The hook to assign a customized order number (unless the order already has one assigned) + */ + function assign_new_ordernumber($orderid, $order, $update=true) { + if ((!$update) /*&& ($order->post_status == 'auto-draft')*/) { + // New order => assign placeholder, which will later be overwritten the real order number + update_post_meta( $orderid, $this->ordernumber_meta.'ordernumber', $this->ordernumber_new_placeholder ); + } + // If we do not have an order (yet), we cannot proceed. But we probably have created the + // ordernumber placeholder for that post, so this function has done its job and we can return + if (!$order instanceof WC_Order) { + return; + } + $number = get_post_meta( $orderid, $this->ordernumber_meta.'ordernumber', 'true'); + if ($number == $this->ordernumber_new_placeholder && $order->post_status != 'auto-draft') { + $number = $this->generateNumber($orderid, $order, 'ordernumber'); + // Assign a new number + } + return $number; + } + + function get_or_create_number($orderid, $order, $type = 'ordernumber') { + $stored_number = get_post_meta( $orderid, $this->ordernumber_meta.$type, true); + if (!empty($stored_number)) { + return $stored_number; + } else { + return $this->generateNumber($orderid, $order, $type); + } + } + + /** + * The generic function to retrieve a particular number + */ + function get_number($orderid, $order, $type = 'ordernumber') { + $stored_number = get_post_meta( $orderid, $this->ordernumber_meta.$type, 'true'); + if ($stored_number == $this->ordernumber_new_placeholder) { + // Check whether the order was now really created => create order number now + return $this->assign_new_ordernumber($orderid, $order, $type); + } elseif (!empty($stored_number)) { + // Order number already exists => simply return it + return $stored_number; + } else { + // No order number was created for this order, so simply use the orderid as default. + return $orderid; + } + } + + /** + * Callback function for Woocommerce to retrieve the ordernumber for an order + * The hook to customize order numbers (requests the order number from the database; + * creates a new ordernumber if no entry exists in the database) + */ + function get_ordernumber($orderid, $order) { + return $this->get_number($orderid, $order, 'ordernumber'); + } + +} diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..1b9746e --- /dev/null +++ b/readme.txt @@ -0,0 +1,76 @@ +=== WooCommerce Basic Ordernumbers === +Contributors: opentools +Tags: WooCommerce, Order numbers, orders +Requires at least: 4.0 +Tested up to: 4.1.1 +Stable tag: trunk +License: GPLv3 or later +License URI: http://www.gnu.org/licenses/gpl.html + +Customize order numbers for WooCommerce. The order numbers can contain arbitrary text, a running counter and the current year. + + +== Description == +The most flexible and complete solution for your WooCommerce webshop to customize your order numbers! + +By default, WooCommerce uses the WordPress post ID of the order, which result in gaps between the order numbers. With this plugin you can configure the order numbers to have consecutive counters. Furthermore, the order number can contain the year, and the counter can be configured to reset each year. + +The number format is a simple string, where # indicates the counter and [year] or [year2] indicate the year. +To get order numbers like "WC-2015-1", "WC-2015-2", etc., simply set the format to "WC-[year]-#". + +The plugin comes in two flavors: + +* This **free basic version**, which provides **sequential numbers** and allows the **year in the order number** +* The **paid advanced version**, with lots of **additional features**: + * Counter formatting: initial value, counter increments, number padding + * Lots of variables to be used in the formats + - date/time: year, month, day, hour, etc. + - address: customer country, zip, name, etc. + - order-specific: Number of articles, products, order total etc. + - product categories, shipping method + * Custom variable definitions (with conditions on available variables) + * Multiple concurrent counters (e.g. numbering per country, per day, per ZIP, ...) + * Different order numbers for free orders (e.g. "FREE-01" for free orders) + * Different number format for e.g. certain IP addresses (for testing) + * Different number format depending on products, product categories, shipping classes + * Customize invoice numbers (only for the "WooCommerce PDF Invoices and Package Slips" plugin) + +For the full documentation of both the basic and the advanced ordernumbers plugin for WooCommerce, see: +http://open-tools.net/documentation/advanced-order-numbers-for-woocommerce.html + + + +== Installation == + +1. To install the plugin, either: + 1. use WordPress' plugin manager to find it in the WordPress plugin directory and directly install it from the WP plugin manager, or + 1. use WordPress' plugin manager to upload the plugin's zip file. +1. After installation, activate the plugin through the 'Plugins' menu in WordPress +1. Enable the plugin's functionality in the WooCommerce settings (tab "Checkout" -> "Order numbers") + + + +== Frequently Asked Questions == + += How can I create nice order numbers for existing orders? = + +This plugin is intended for future orders. You can, however, create order numbers for existing orders in the order view in the WordPress admin section. In the top right "Order Actions" box select "Assign a new order number" and click "Save Order". Notice, however, that this will create an order number as if the order was created at that very moment. + += What about invoice numbers? = + +The Advanced Ordernumbers for WooCommerce plugin supports some invoicing plugins. This functionality is not available in the free version, though. + + +== Screenshots == + +1. + +== Changelog == + += 1.0 = +* Initial release + +== Upgrade Notice == + +To install the Advanced Ordernumbers for WooCommerce package, proceed as described in the Installation section. +No upgrades yet. diff --git a/woocommerce-advanced-ordernumbers.php b/woocommerce-advanced-ordernumbers.php index 942f529..d535bd3 100644 --- a/woocommerce-advanced-ordernumbers.php +++ b/woocommerce-advanced-ordernumbers.php @@ -1,10 +1,10 @@ <?php /** - * Plugin Name: Advanced Ordernumbers - * Plugin URI: http://open-tools.net/WooCommerce/Advanced-Ordernumbers.php + * Plugin Name: Woocommerce Advanced Ordernumbers + * Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html * Description: Lets the user freely configure the order numbers in WooCommerce. - * Version: 0.1.0 - * Author: Open Tools, Reinhold Kainhofer + * Version: 1.0 + * Author: Open Tools * Author URI: http://open-tools.net * Text Domain: woocommerce-advanced-ordernumbers * Domain Path: @@ -16,19 +16,29 @@ WC tested up to: 2.3 if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } +// Define a global flag so the basic plugin can deactivate itself if this plugin is loaded +if ( !defined('OPENTOOLS_ADVANCED_ORDERNUMBERS') ) { + define ('OPENTOOLS_ADVANCED_ORDERNUMBERS', true); +} + /** * Check if WooCommerce is active **/ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { - require_once( plugin_dir_path( __FILE__ ) . '/ordernumber_helper_woocommerce.php'); - if (!class_exists("OpenToolsOrdernumbers")) { + if (file_exists(plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce.php') && !class_exists("OpenToolsOrdernumbers")) { require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce.php'); - } + } + if (!class_exists("OpenToolsOrdernumbersBasic")) + require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php'); + + // instantiate the plugin class if (class_exists("OpenToolsOrdernumbers")) { - // instantiate the plugin class - $ordernumber_plugin = new OpenToolsOrdernumbers(); + $ordernumber_plugin = new OpenToolsOrdernumbers(plugin_basename(__FILE__)); + } elseif (class_exists("OpenToolsOrdernumbersBasic")) { + $ordernumber_plugin = new OpenToolsOrdernumbersBasic(plugin_basename(__FILE__)); } + } diff --git a/woocommerce-custom-ordernumbers.php b/woocommerce-custom-ordernumbers.php new file mode 100644 index 0000000..ef1630f --- /dev/null +++ b/woocommerce-custom-ordernumbers.php @@ -0,0 +1,48 @@ +<?php +/** + * Plugin Name: WooCommerce Basic Ordernumbers + * Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html + * Description: Lets the user freely configure the order numbers in WooCommerce. + * Version: 1.0 + * Author: Open Tools + * Author URI: http://open-tools.net + * Text Domain: woocommerce-advanced-ordernumbers + * Domain Path: + * License: GPL2+ + WC requires at least: 2.2 +WC tested up to: 2.3 +*/ + +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} +/** + * Check if WooCommerce is active + **/ +if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { + + if (file_exists(plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php') && !class_exists("OpenToolsOrdernumbersBasic") ) { + require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php'); + } + + function ordernumbers_print_basic_admin_notice() { + deactivate_plugins( plugin_basename( __FILE__ ) ); + ?> + <div class="error"> + <p><?php _e( 'The <b>OpenTools Advanced Ordernumbers</b> plugin is <b>installed</b> and activated, the <b>basic ordernumber plugin</b> with similar, but limited functionality will be <b>deactivated</b>.', 'opentools-advanced-ordernumbers' ); ?></p> + </div> + <?php + } + function ordernumbers_check_deactivate() { + if (defined ('OPENTOOLS_ADVANCED_ORDERNUMBERS')) { + add_action( 'admin_notices', 'ordernumbers_print_basic_admin_notice'); + } + } + add_action( 'plugins_loaded', 'ordernumbers_check_deactivate', 99 ); + + // instantiate the plugin class + if (class_exists("OpenToolsOrdernumbersBasic")) { + $ordernumber_plugin = new OpenToolsOrdernumbersBasic(plugin_basename(__FILE__)); + } + +} -- GitLab