Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'crypto' custom route issue #154 #156

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

DarrenWestwood
Copy link
Collaborator

Issue #154 - change checkout page URL from
http://localhost/wc-api/WC_Gateway_Blockonomics/?show_order=
to
http://localhost/crypto/?show_order=

@@ -139,7 +139,8 @@ public function process_payment($order_id)
update_option('blockonomics_orders', $blockonomics_orders);
$order_url = WC()->api_request_url('WC_Gateway_Blockonomics');
$order_url = add_query_arg('show_order', $address, $order_url);

$order_url = str_replace('wc-api/WC_Gateway_Blockonomics', 'crypto', $order_url);
Copy link
Owner

Choose a reason for hiding this comment

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

there is no need to first add WC()->api_request_url and then replace it. We should directly use show_order

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do not have any way to directly access show_order as we are not creating any page or post type. We still have to use WC()->api_request_url('WC_Gateway_Blockonomics') to fetch the correct url.

add_action('init', 'custom_rewrite_rules');

/* Custom Rewrite Rule */
function custom_rewrite_rules() {
Copy link
Owner

Choose a reason for hiding this comment

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

Let us show_order . Also don't hardcode wc-api=WC_Gateway_Blockonomics let us use WC()->api_request_url else it won't work for WC < 3.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We cannot use WC()->api_request_url because add_rewrite_rule requires the url to start with index.php. All wordpress urls can be accessed in this manner.
In later versions of woocommerce, they added their own rewrite rules to change the url, however, we still need to access the original page with the form index.php?wc-api=WC_Gateway_Blockonomics

@blockonomics
Copy link
Owner

Does this require customer to manually flush rewrite rules or it will auto work on installation / upgrade ?

@DarrenWestwood
Copy link
Collaborator Author

Does this require customer to manually flush rewrite rules or it will auto work on installation / upgrade ?

Yes this does require a manual flush or flush_rewrite_rules() can be added to the installation / upgrade.

@blockonomics
Copy link
Owner

Does this require customer to manually flush rewrite rules or it will auto work on installation / upgrade ?

Yes this does require a manual flush or flush_rewrite_rules() can be added to the installation / upgrade.

I don't like the thought of rewrite_rules() ...but do the code . Let us see how less complex it is

@blockonomics
Copy link
Owner

Please fix conflicts and other pull request comments

@DarrenWestwood
Copy link
Collaborator Author

DarrenWestwood commented Oct 28, 2019

The current version should work at rewriting the url correctly for all users who have rewrites enabled.
Current functionality of the plugin should not be affected for those who do not have wc-api/WC_Gateway_Blockonomics present in their URL.
This means the current changes will only affect users with newer versions of woocommerce.

Further tests will still be required to check if users with different permalink settings or custom rewrites in .htaccess breaks any functionality for existing users.
Older versions of Woocommerce should also be tested to check functionality once #161 has been resolved
Upgrading users with different setups should also not experience any issues - possibly requires flush_rewrite_rules(true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants