emomarina
Forum Replies Created
Viewing 6 replies - 1 through 6 (of 6 total)
-
Forum: Plugins
In reply to: [Contact Form 7] Problem with contact formHi! In the fierst tab – > Form shows an error: 1 error was found while configuring on the panel on the sub window.
Аnd another one: Multiple shape management is in a single element on a label..
Forum: Plugins
In reply to: [Buy one click WooCommerce] Popup form have a problem – no workForum: Plugins
In reply to: [Buy one click WooCommerce] Popup form have a problem – no workHello! I’m sorry! The mistake is mine now the email account is working. Thank you! I hope for your answer. Thank you!
This code working correctly, but button returns me only to the first page of the category..but i want to return the customers in the shop, to the last product category page viewed. I can not understand where i’m wrong.
<?php /* Set up session */ add_action( 'init', 'wp_check_for_product_cat_sess'); function wp_check_for_product_cat_sess(){ if(!session_id()) { session_start(); } /* Set session variable when on Category or Product page */ add_action( 'wp', 'wp_check_for_product_cat'); function wp_check_for_product_cat(){ global $wp_query; if( is_product_category() ){ // This is Category; use my ID $_SESSION['wp_last_cat'] = $wp_query->get_queried_object()->term_id; } if( is_product() ){ // This is Product; use my ID to get my Categories $cats = get_the_terms( $wp_query->get_queried_object(), 'product_cat' ) ; if( count( $cats ) > 0 ){ foreach($cats as $one_cat ){ $_SESSION['wp_last_cat'] = $one_cat->term_id; } } } if( is_cart() ){ // Here we output only on Cart page, as debug tool */ var_dump( $_SESSION['wp_last_cat'] ); } } // add back to store button after cart // ============================================================================= add_action('woocommerce_cart_actions', 'themeprefix_back_to_store'); function themeprefix_back_to_store () { if( isset( $_SESSION['wp_last_cat'] ) ){ $shop_page_url = get_term_link( $_SESSION['wp_last_cat'], 'product_cat' ); } else { $shop_page_url = get_permalink( wc_get_page_id( 'shop' ) ); } echo '<div class="woocommerce-message">'; echo ' <a href="'.$shop_page_url.'">Continue Shopping →</a> Would you like some more prints?'; echo '</div>'; }}
The code now looks like this. var_dump gives me an int error (323) and the button returns me only to the first page of the category.
<?php /** * Note: It's not recommended to add any custom code here. Please use a child theme so that your customizations aren't lost during updates. * Learn more here: https://codex.www.ads-software.com/Child_Themes */ /* Set up session */ add_action( 'init', 'wp_check_for_product_cat_sess'); function wp_check_for_product_cat_sess(){ if(!session_id()) { session_start(); } /* Set session variable when on Category or Product page */ add_action( 'wp', 'wp_check_for_product_cat'); function wp_check_for_product_cat(){ global $wp_query; if( is_product_category() ){ // This is Category; use my ID $_SESSION['wp_last_cat'] = $wp_query->get_queried_object()->term_id; } if( is_product() ){ // This is Product; use my ID to get my Categories $cats = get_the_terms( $wp_query->get_queried_object(), 'product_cat' ) ; if( count( $cats ) > 0 ){ foreach($cats as $one_cat ){ $_SESSION['wp_last_cat'] = $one_cat->term_id; } } } if( is_cart() ){ // Here we output only on Cart page, as debug tool */ var_dump( $_SESSION['wp_last_cat'] ); } } // add back to store button after cart // ============================================================================= add_action('woocommerce_cart_actions', 'themeprefix_back_to_store'); function themeprefix_back_to_store () { if( isset( $_SESSION['wp_last_cat'] ) ){ $shop_page_url = get_term_link( $_SESSION['wp_last_cat'], 'product_cat' ); } else { $shop_page_url = get_permalink( wc_get_page_id( 'shop' ) ); } echo '<div class="woocommerce-message">'; echo ' <a href="'.$shop_page_url.'" class="button wc-forwards">Continue Shopping →</a> Would you like some more prints?'; echo '</div>'; }}
Viewing 6 replies - 1 through 6 (of 6 total)