Skip to content

Refactoring plugin-initial code structure - part 2: Relocating, renaming functions and method.#95

Merged
guzzilar merged 4 commits intomasterfrom
refactoring-plugin-initiating-structure-part2
Jan 21, 2019
Merged

Refactoring plugin-initial code structure - part 2: Relocating, renaming functions and method.#95
guzzilar merged 4 commits intomasterfrom
refactoring-plugin-initiating-structure-part2

Conversation

@guzzilar
Copy link
Copy Markdown
Contributor

@guzzilar guzzilar commented Jan 18, 2019

⚠️ Important: This pull request requires #94: "Refactoring plugin-initial code structure, part 1" to be merged first.

1. Objective

Omise-WooCommerce has always been coupled with WooCommerce plugin, which the plugin cannot be used as a stand-alone plugin and always require WooCommerce plugin to be activated first.
However, the legacy-codebase itself wasn't really aware of a case where WooCommerce plugin is disabled as much as it should be.

Although we have prevented such cases #78, and #83. But by the current design of the plugin-initial step, it still remains some issue (#90) that could be ceased out by redesigning the initial-step with a proper awareness of WooCommerce plugin.

Related issue(s):

2. Description of change

Part 1

See, #94: "Refactoring plugin-initial code structure - part 1: Enhancing the behavior of checking dependency plugin"

Part 2

Chore works in part 2:
Relocating functions, renaming method names to be more generic, and grouping code to a proper place (method).

Part 3

See, #96: "Refactoring plugin-initial code structure - part 3: Organizing Omise_Admin class."

3. Quality assurance

🔧 Environments:

  • WordPress: v5.0.3
  • WooCommerce: v3.5.3
  • PHP version: v5.6.30

✏️ Details:

The main test-case will be separated into 3 cases as follows:

  1. Attempting to install Omise-WooCommerce without WooCommerce should give you a warning message that Omise-WooCommerce requires WooCommerce plugin to be activated first.
    Omise-WooCommerce plugin can be activated, but all functions should be disabled, including no Omise menu at the WordPress admin-sidebar.

screen shot 2562-01-18 at 00 12 26

  1. Install Omise-WooCommere plugin while WooCommerce plugin is enabled should give you a full-access to all Omise-WooCommerce feature, including the setting page.

screen shot 2562-01-17 at 23 32 33

  1. Attempting to disable WooCommerce plugin while Omise-WooCommerce is still enabled should give you a same result as the case [1].

screen shot 2562-01-18 at 00 12 26

  1. After the change, charge must be created, captured, refunded as usual.

4. Impact of the change

No

5. Priority of change

Normal

6. Additional Notes

No

@guzzilar guzzilar force-pushed the refactoring-plugin-initiating-structure-part2 branch from 23ff9f5 to ee84766 Compare January 18, 2019 03:07
@guzzilar guzzilar changed the title Refactoring plugin-initial code structure, part 2 Refactoring plugin-initial code structure - part 2: Relocating, renaming functions and method. Jan 18, 2019
@guzzilar guzzilar requested a review from jacstn January 18, 2019 05:48
Copy link
Copy Markdown

@jonrandy jonrandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't give final approval yet as this looks like it really needs at least a quick test. Can re-review after that, but have left some comments in the mean time

Comment thread omise-woocommerce.php
protected function initiate() {
public function init_error_messages(){
?>
<div class="error">
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa! Inline HTML!?!?! Is this really how things are done in WooCommerce? Feels very wrong - especially the fact the HTML is totally hardcoded

Copy link
Copy Markdown
Contributor Author

@guzzilar guzzilar Jan 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonrandy yeah.. it's WordPress nature of code..
I know how you feel..

Comment thread omise-woocommerce.php
* Omise's charge id as a 'customed-post-meta' in the
* WooCommerce's 'order' post-type instead.
*/
public function register_post_types() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is deprecated? Why is it here? Is it to maintain support for older versions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonrandy Not really for older versions but more like, for old-orders.
For example, those stores that have been using Omise legacy version and later updated to v3.x, those orders that have been created with Omise-WooCommerce below v3.0 will still refer to this custom-post-type.

We may have a migration script to migrate all those data into WooCommerce Order's post meta. But just it's not that high priority, so I choose to leave the code here instead.

…om 'Omise_Payment_Creditcard' class out to the core class.

Here I am trying to separte between a code that taking care of the initiative part and a code that is not.
As registering custom post type is not related and not require for any WooCommerce classes, so I'm relocating it out to the core class.
@guzzilar guzzilar force-pushed the refactoring-plugin-initiating-structure-part2 branch from ee84766 to 363823f Compare January 21, 2019 04:12
@guzzilar guzzilar merged commit 0fde625 into master Jan 21, 2019
@guzzilar guzzilar deleted the refactoring-plugin-initiating-structure-part2 branch January 21, 2019 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants