WooCommerce Theme (Magique) Intergration via Hooks
-
I am quite new to WordPress and would like someone to help show me how to implement WooCommerce via hooks to the Magique theme? WooCommerce describes this as a simple implementation and hopefully once I see exactly what you have done I will be able to replicate that in the future.
Implementation instructions from WooCommerce:
By inserting a few lines in your theme’s functions.php file, First unhook the WooCommerce wrappers;
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
Then hook in your own functions to display the wrappers your theme requires;
add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10); add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10); function my_theme_wrapper_start() { echo '<section id="main">'; } function my_theme_wrapper_end() { echo '</section>'; }
The current contents of my functions.php file:
<?php /** * @package WordPress * @subpackage Magique * @since Magique 1.0 * * Main Theme Functions File * Created by CMSMasters * */ // WooCommerce Setup remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10); add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10); function my_theme_wrapper_start() { echo '<section id="main">'; } function my_theme_wrapper_end() { echo '</section>'; // Removes non-supported theme banner add_theme_support( 'woocommerce' ); } // Current Theme Constants define('CMSMS_SHORTNAME', 'magique'); define('CMSMS_FULLNAME', 'Magique'); // CMSMasters Framework Directories Constants define('CMSMS_FRAMEWORK', get_template_directory() . '/framework'); define('CMSMS_ADMIN', CMSMS_FRAMEWORK . '/admin'); define('CMSMS_COMPOSER', CMSMS_ADMIN . '/composer'); define('CMSMS_SETTINGS', CMSMS_ADMIN . '/settings'); define('CMSMS_OPTIONS', CMSMS_ADMIN . '/options'); define('CMSMS_ADMIN_INC', CMSMS_ADMIN . '/inc'); define('CMSMS_CLASS', CMSMS_FRAMEWORK . '/class'); define('CMSMS_FUNCTION', CMSMS_FRAMEWORK . '/function'); // Load Theme Local File $locale = get_locale(); if (is_admin()) { load_theme_textdomain('cmsmasters', CMSMS_ADMIN_INC . '/languages'); $locale_file = CMSMS_ADMIN_INC . '/languages/' . $locale . '.php'; } else { load_theme_textdomain('cmsmasters', CMSMS_FRAMEWORK . '/languages'); $locale_file = CMSMS_FRAMEWORK . '/languages/' . $locale . '.php'; } if (is_readable($locale_file)) { require_once($locale_file); } // Load Framework Parts require_once(CMSMS_SETTINGS . '/cmsms-theme-settings.php'); require_once(CMSMS_OPTIONS . '/cmsms-theme-options.php'); require_once(CMSMS_COMPOSER . '/cmsms-content-composer.php'); require_once(CMSMS_ADMIN_INC . '/editor-additions.php'); require_once(CMSMS_ADMIN_INC . '/admin-scripts.php'); require_once(CMSMS_CLASS . '/projects-posttype.php'); require_once(CMSMS_CLASS . '/widgets-default.php'); require_once(CMSMS_CLASS . '/widgets.php'); require_once(CMSMS_CLASS . '/shortcodes.php'); require_once(CMSMS_CLASS . '/likes.php'); require_once(CMSMS_FUNCTION . '/breadcrumbs.php'); require_once(CMSMS_FUNCTION . '/pagination.php'); require_once(CMSMS_FUNCTION . '/single-comment.php'); require_once(CMSMS_FUNCTION . '/theme-functions.php'); require_once(CMSMS_FUNCTION . '/template-functions.php'); // Framework Activation Import if (is_admin() && isset($_GET['activated']) && $pagenow == 'themes.php') { cmsms_add_global_options(); require_once(CMSMS_ADMIN_INC . '/database-import.php'); } // Theme Settings System Fonts List function cmsms_system_fonts_list() { $fonts = array( 'Arial' => "Arial, Helvetica, 'Nimbus Sans L', sans-serif", 'Calibri' => "Calibri, 'AppleGothic', 'MgOpen Modata', sans-serif", 'Trebuchet MS' => "'Trebuchet MS', Helvetica, Garuda, sans-serif", 'Comic Sans MS' => "'Comic Sans MS', Monaco, 'TSCu_Comic', cursive", 'Georgia' => "Georgia, Times, 'Century Schoolbook L', serif", 'Verdana' => "Verdana, Geneva, 'DejaVu Sans', sans-serif", 'Tahoma' => "Tahoma, Geneva, Kalimati, sans-serif", 'Lucida Sans' => "'Lucida Sans Unicode', 'Lucida Grande', Garuda, sans-serif", 'Times New Roman' => "'Times New Roman', Times, 'Nimbus Roman No9 L', serif", 'Courier New' => "'Courier New', Courier, 'Nimbus Mono L', monospace" ); return $fonts; } // Theme Settings Google Fonts List function cmsms_google_fonts_list() { $fonts = array( 'Open Sans' => 'Open+Sans:400,400italic,700,700italic', 'Droid Sans' => 'Droid+Sans:400,700', 'Droid Serif' => 'Droid+Serif:400,400italic,700,700italic', 'Headland One' => 'Headland+One', 'Lobster' => 'Lobster', 'PT Sans' => 'PT+Sans:400,400italic,700,700italic', 'Ubuntu' => 'Ubuntu:400,400italic,700,700italic', 'Open Sans Condensed' => 'Open+Sans+Condensed:300,300italic,700', 'Lato' => 'Lato:400,400italic,700,700italic', 'PT Sans Narrow' => 'PT+Sans+Narrow:400,700', 'Cuprum' => 'Cuprum:400,400italic,700,700italic' ); return $fonts; } // Theme Settings Font Weights List function cmsms_font_weight_list() { $list = array( 'normal', '100', '200', '300', '400', '500', '600', '700', '800', '900', 'bold', 'bolder', 'lighter' ); return $list; } // Theme Settings Font Styles List function cmsms_font_style_list() { $list = array( 'normal', 'italic', 'oblique', 'inherit' ); return $list; }
and the contents of my page.php file:
<?php /** * @package WordPress * @subpackage Magique * @since Magique 1.0 * * Default Page Template * Created by CMSMasters * */ get_header(); $cmsms_layout = get_post_meta(get_the_ID(), 'cmsms_layout', true); if (!$cmsms_layout) { $cmsms_layout = 'r_sidebar'; } echo '<!--_________________________ Start Content _________________________ -->' . "\n"; if ($cmsms_layout == 'r_sidebar') { echo '<section id="content" role="main">' . "\n"; } elseif ($cmsms_layout == 'l_sidebar') { echo '<section id="content" class="fr" role="main">' . "\n"; } else { echo '<section id="middle_content" role="main">' . "\n"; } if (have_posts()) : the_post(); if (has_post_thumbnail() || get_the_content() != '') { echo '<div class="entry">' . "\n"; if (has_post_thumbnail()) { if ($cmsms_layout == 'r_sidebar' || $cmsms_layout == 'l_sidebar') { echo '<div class="cmsms_media">' . "\n\t"; cmsms_thumb(get_the_ID(), 'post-thumbnail', false, 'img_' . get_the_ID(), true, false, true, true, false); echo "\r" . '</div>'; } else { echo '<div class="cmsms_media">' . "\n\t"; cmsms_thumb(get_the_ID(), 'full-thumb', false, 'img_' . get_the_ID(), true, false, true, true, false); echo "\r" . '</div>'; } } if (get_the_content() != '') { echo '<div class="entry-content">' . "\n"; the_content(); echo '</div>' . "\n"; wp_link_pages(array( 'before' => '<div class="subpage_nav" role="navigation">' . '<strong>' . __('Pages', 'cmsmasters') . ':</strong>', 'after' => '</div>' . "\n", 'link_before' => ' [ ', 'link_after' => ' ] ' )); } echo '</div>' . "\n"; } endif; cmsms_content_composer(get_the_ID()); comments_template(); echo '</section>' . "\n" . '<!-- _________________________ Finish Content _________________________ -->' . "\n\n"; if ($cmsms_layout == 'r_sidebar') { echo "\n" . '<!-- _________________________ Start Sidebar _________________________ -->' . "\n" . '<section id="sidebar" role="complementary">' . "\n"; get_sidebar(); echo "\n" . '</section>' . "\n" . '<!-- _________________________ Finish Sidebar _________________________ -->' . "\n"; } elseif ($cmsms_layout == 'l_sidebar') { echo "\n" . '<!-- _________________________ Start Sidebar _________________________ -->' . "\n" . '<section id="sidebar" class="fl" role="complementary">' . "\n"; get_sidebar(); echo "\n" . '</section>' . "\n" . '<!-- _________________________ Finish Sidebar _________________________ -->' . "\n"; } get_footer();
If you require anything else please let me know. Any and all help would be hugely appreciated and if I can do anything more to articulate my question and increase its understandability just let me know. Thank you!
- The topic ‘WooCommerce Theme (Magique) Intergration via Hooks’ is closed to new replies.