WooCommerce Integration – I have read your posts and I have some code to offer
-
Okay I read most of these support forums and you said if someone would produce some code to help integrate your plugin with WooCommerce you might consider making it work?.
Okay here we go. The issue with WooCommerce not working with this plugin, as I understand it, has to do with the endpoints in the my account section I think. Basically woocommerce handles the my account section differently than one would expect if they had only used wordpress and never worked with WooCommerce before. What I was able to do is create a custom endpoint and name it pgp. So now when you go to the my account page you see all of the normal stuff and now there is the additional link named PGP. That link should point to “woocommerce/myaccount/pgp.php” i think based off my code below.
So now I think all that is left is to write 1 file named pgp.php and that file will need to be placed in woocommerce/myaccount. But I do not know PHP very well at all and I have no idea how this plugin receives information. Basically I have a good idea what needs to be done but I do not have the PHP skills to finish.
Here is the code that will allow you to define a custom endpoint and add a link into the My Account menu.
I might be a tiny bit wrong on a few small issues but I think this is the solution and I suspect that once someone is able to write this pgp.php file all of this could be bundled up in a fully functional plugin. It seems like if you create pgp.php and have it populate the fields that the plugin requires then the problem is solved. I promise I am learning PHP as quickly as possible but it just seems like this could be easily fixed in very little time with this information. Maybe there is more to this than I understand and it is REALLY difficult? Please help.
Place this code in functions.php
function my_custom_endpoints() {
add_rewrite_endpoint( ‘pgp’, EP_ROOT | EP_PAGES );
}add_action( ‘init’, ‘my_custom_endpoints’ );
function my_custom_query_vars( $vars ) {
$vars[] = ‘pgp’;return $vars;
}add_filter( ‘query_vars’, ‘my_custom_query_vars’, 0 );
function my_custom_flush_rewrite_rules() {
flush_rewrite_rules();
}add_action( ‘after_switch_theme’, ‘my_custom_flush_rewrite_rules’ );
function my_custom_my_account_menu_items( $items ) {
$items = array(
‘dashboard’ => __( ‘Dashboard’, ‘woocommerce’ ),
‘orders’ => __( ‘Orders’, ‘woocommerce’ ),
//’downloads’ => __( ‘Downloads’, ‘woocommerce’ ),
//’edit-address’ => __( ‘Addresses’, ‘woocommerce’ ),
//’payment-methods’ => __( ‘Payment Methods’, ‘woocommerce’ ),
‘edit-account’ => __( ‘Edit Account’, ‘woocommerce’ ),
‘pgp’ => ‘PGP’,
‘customer-logout’ => __( ‘Logout’, ‘woocommerce’ ),
);return $items;
}
add_filter( ‘woocommerce_account_menu_items’, ‘my_custom_my_account_menu_items’ );
function my_custom_endpoint_content() {
include ‘woocommerce/myaccount/pgp.php’;
}add_action( ‘woocommerce_account_pgp_endpoint’, ‘my_custom_endpoint_content’ );
The page I need help with: [log in to see the link]
- The topic ‘WooCommerce Integration – I have read your posts and I have some code to offer’ is closed to new replies.