Menus & WooCommerce pages
-
Hello;
I’m using the OCDI plugin to import demo for my theme that I developed, but I’m facing 2 issues:
1-When I import demo the first time, some menus and widgets doesn’t appear till I import the demo for the second time.
2-The pages are well imported, but they are not linked on advanced section of WooCommerce, I mean the cart page is imported but when I go to advanced section in WooCommerce, I find that the cart page is not mentionned there.
How can I fixe this 2 issues, please?
Regards.
Amine.
- This topic was modified 1 week, 5 days ago by ablamohamedamine.
-
Hi there @ablamohamedamine,
Thanks for reaching out. I wonder if your server may be terminating the process early. When you get a moment, try running an import while the WordPress debug feature is turned on. That way we can find out if you might be running into any errors when the plugin runs.
Check out this guide on our site. It goes over some of the issues you might encounter. It also provides some recommended settings for things like max_input_time and max_execution_time.
As for the WooCommerce issue, the pages are imported but we don’t automatically assign them in your WooCommerce settings. To do that, you would need to write a custom function to update the settings after the import runs.
Check out our advanced integration guide here. It provides information on the after_import function and how you can use it to run custom PHP after the importer runs. You could use it to to find your WooCommerce pages and then update the options with the correction IDs.
Check out this snippet for a better idea of what I mean. We haven’t tested it, but it should help get you pointed in the right direction:
function my_custom_ocdi_after_import_setup() {
$pages = get_pages();
foreach ($pages as $page) {
switch ($page->post_title) {
case 'Cart':
update_option('woocommerce_cart_page_id', $page->ID);
break;
case 'Checkout':
update_option('woocommerce_checkout_page_id', $page->ID);
break;
case 'My Account':
update_option('woocommerce_myaccount_page_id', $page->ID);
break;
case 'Terms and Conditions':
update_option('woocommerce_terms_page_id', $page->ID);
break;
}
}
}
add_action( 'ocdi/after_import', 'my_custom_ocdi_after_import_setup' );I hope that helps! Have a great day!
Dear @dpinson ; thanks a lot for your answers an efforts.
I’ll try why you suggest for me and come back to you as soon as possible.
Regards.
Amine.
Hi again @dpinson ;
1-I make sure that the recomendation is good in my host and I activate the debug, any issue was displayed, I always should upload the demo twice.
2-It works thank you, but “My Account” page get the ID of an other page, I don’t know why.
Anyway here’s the file’s code to check it if you can:
?function dziridemo_ocdi_plugin_notice() {
? ? $installed_plugins = get_plugins();
? ? if ( !isset( $installed_plugins['one-click-demo-import/one-click-demo-import.php'] ) ) {
? ? ? ? $install_url = wp_nonce_url(
? ? ? ? ? ? self_admin_url( 'update.php?action=install-plugin&plugin=one-click-demo-import/one-click-demo-import.php' ),
? ? ? ? ? ? 'install-plugin_one-click-demo-import/one-click-demo-import.php/one-click-demo-import.php');
? ? ? ? ?>
? ? ? ? ? ? <div class="notice error is-dismissible">
? ? ? ? ? ? ? ? <p><?php echo __( 'The plugin <strong> Dziri Demo </strong> require One Click Demo Import' ); ?></p>
? ? ? ? ? ? ? ? <p><a href="<?php echo esc_url( $install_url ); ?>" class="button-primary"><?php echo __( 'Install One Click Demo Import' ); ?></a></p>
? ? ? ? ? ? </div>
? ? ? ? <?php
? ? }
? ? else if ( ! is_plugin_active( 'one-click-demo-import/one-click-demo-import.php' ) ) {
? ? ? ? $activate_url = wp_nonce_url(
? ? ? ? ? ? self_admin_url( 'plugins.php?action=activate&plugin=one-click-demo-import/one-click-demo-import.php' ),
? ? ? ? ? ? 'activate-plugin_one-click-demo-import/one-click-demo-import.php');
? ? ? ? ?>
? ? ? ? ? ? <div class="notice notice-warning is-dismissible">
? ? ? ? ? ? ? ? <p><?php echo __( 'One Click Demo Import is installed but not activated. Please activate One Click Demo Import to use th plugin <strong> Dziri Demo </strong>' ); ?></p>
? ? ? ? ? ? ? ? <p><a href="<?php echo esc_url( $activate_url ); ?>" class="button-primary"><?php echo __( 'Activate One Click Demo Import' ); ?></a></p>
? ? ? ? ? ? </div>
? ? ? ? <?php
? ? }
}
add_action( 'admin_notices', 'dziridemo_ocdi_plugin_notice' );
// One Click Demo Import Plugins
function dziridemo_register_required_plugins( $plugins ) {
? ? $theme_plugins = [
? ? ? ? [ // WooCommerce
? ? ? ? ? ? 'name' ? ? => 'WooCommerce',
? ? ? ? ? ? 'slug' ? ? => 'woocommerce',
? ? ? ? ? ? 'required' => true
? ? ? ? ],
? ? ? ? [ // Contact Form 7
? ? ? ? ? ? 'name' ? ? => 'Contact Form 7',
? ? ? ? ? ? 'slug' ? ? => 'contact-form-7',
? ? ? ? ? ? 'required' => true
? ? ? ? ],
? ? ];
? ? return array_merge( $plugins, $theme_plugins );
}
add_filter( 'ocdi/register_plugins', 'dziridemo_register_required_plugins' );
// Remove Pages
function dziridemo_remove_pages( $selected_import ) {
? ? $pages = get_posts( array(
? ? ? ? 'post_type' => 'page',
? ? ? ? 'numberposts' => -1,
? ? ? ? 'post_status' => 'any'
? ? ));
? ? foreach ($pages as $page) {
? ? ? ? wp_delete_post($page->ID, true);
? ? }
}
add_action( 'ocdi/before_content_import', 'dziridemo_remove_pages' );
// Remove Sidebares Content
function dziridemo_before_widgets_import( $selected_import ) {
? ? $sidebars_widgets = get_option('sidebars_widgets');
? ? foreach ($sidebars_widgets as $sidebar_id => $widgets) {
? ? ? ? if ($sidebar_id != 'wp_inactive_widgets') {
? ? ? ? ? ? $sidebars_widgets[$sidebar_id] = array();
? ? ? ? }
? ? }
? ? update_option('sidebars_widgets', $sidebars_widgets);
}
add_action( 'ocdi/before_widgets_import', 'dziridemo_before_widgets_import' );
function dziridemo_import_demo() {
? ? return [
? ? ? ? [
? ? ? ? ? ? 'import_file_name' ? ? ? ? ? => 'Dziri Demo',
? ? ? ? ? ? 'import_file_url' ? ? ? ? ? ?=> plugin_dir_url(__FILE__) . '/demo/dziri.WordPress.xml',
? ? ? ? ? ? 'import_widget_file_url' ? ? => plugin_dir_url(__FILE__) . '/demo/dziri.widgets.wie',
? ? ? ? ? ? 'import_customizer_file_url' => plugin_dir_url(__FILE__) . '/demo/dziri-export.dat',
? ? ? ? ? ? 'import_preview_image_url' ? => plugin_dir_url(__FILE__) . '/demo/dziri-screenshot.png',
? ? ? ? ? ? 'preview_url' ? ? ? ? ? ? ? ?=> 'https://dziri.teamine.agency/',
? ? ? ? ],
? ? ];
}
add_filter( 'ocdi/import_files', 'dziridemo_import_demo' );
// One Click Demo Import Settings
function dziridemo_after_import_setup() {
? ? $main_menu = get_term_by( 'name', 'Main Menu', 'nav_menu' );
? ? set_theme_mod( 'nav_menu_locations', array(
? ? ? ? ? ? 'header-menu' => $main_menu->term_id,
? ? ? ? )
? ? );
? ? update_option( 'show_on_front', 'page' );
? ? $pages = get_pages();
? ? foreach ($pages as $page) {
? ? ? ? switch ($page->post_title) {
? ? ? ? ? ? case 'Home':
? ? ? ? ? ? ? ? update_option('page_on_front', $page->ID);
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? case 'Blog':
? ? ? ? ? ? ? ? update_option('page_for_posts', $page->ID);
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? case 'Cart':
? ? ? ? ? ? ? ? update_option('woocommerce_cart_page_id', $page->ID);
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? case 'Checkout':
? ? ? ? ? ? ? ? update_option('woocommerce_checkout_page_id', $page->ID);
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? case 'My Account':
? ? ? ? ? ? ? ? update_option('woocommerce_myaccount_page_id', $page->ID);
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? case 'Terms and Conditions':
? ? ? ? ? ? ? ? update_option('woocommerce_terms_page_id', $page->ID);
? ? ? ? ? ? ? ? break;
? ? ? ? }
? ? }
}
add_action( 'ocdi/after_import', 'dziridemo_after_import_setup' );
- You must be logged in to reply to this topic.