Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Bag Buttons
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Bag Buttons
- This topic has 25 replies, 5 voices, and was last updated 9 years by Mohammad – SUPPORT.
-
Posted in: Neighborhood
-
October 5, 2015 at 6:23 pm #218602
Hi Guys
Id like to change text and the link on the bag button in the drop down cart, when the cart is empty to a different page other then shop?
Is this possible please?
October 6, 2015 at 10:15 am #218731Hi,
Please attach a marked screenshot to indicate the button link position because i am just little bit confuse.
Thanks
MohammadOctober 11, 2015 at 11:08 pm #219900Hi Mohammad
Apologies for slow reply, out of office.
See attached, I have had to use a screenshot from your demo site as the button is hidden on my site using css. The button which says go to shop -I would like to say ‘Browse’ and I would like to be able to point it to a custom URL.
Is it possible?
Attachments:
You must be logged in to view attached files.October 12, 2015 at 7:38 am #219926Hi,
Please paste this code at functions.php of child theme.function sf_woo_header_add_to_cart_fragment( $fragments ) { global $woocommerce; ob_start(); $cart_total = WC()->cart->get_cart_total(); $cart_count = $woocommerce->cart->cart_contents_count; $cart_count_text = sf_product_items_text($cart_count); $options = get_option('sf_neighborhood_options'); $show_cart_count = false; if (isset($options['show_cart_count'])) { $show_cart_count = $options['show_cart_count']; } ?> <li class="parent shopping-bag-item"> <?php if ($show_cart_count) { ?> <a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping bag', 'swiftframework'); ?>"><i class="sf-cart"></i><?php echo $cart_total; ?> (<?php echo $cart_count; ?>)</a> <?php } else { ?> <a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping bag', 'swiftframework'); ?>"><i class="sf-cart"></i><?php echo $cart_total; ?></a> <?php } ?> <ul class="sub-menu"> <li> <div class="shopping-bag"> <?php if ( sizeof($woocommerce->cart->cart_contents)>0 ) { ?> <div class="bag-header"><?php echo $cart_count_text; ?> <?php _e('in the shopping bag', 'swiftframework'); ?></div> <div class="bag-contents"> <?php foreach ($woocommerce->cart->cart_contents as $cart_item_key => $cart_item) { ?> <?php $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $price = apply_filters( 'woocommerce_cart_item_price', $woocommerce->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); $product_title = $_product->get_title(); $product_short_title = ( strlen( $product_title ) > 25 ) ? substr( $product_title, 0, 22 ) . '...' : $product_title; ?> <?php if ($_product->exists() && $cart_item['quantity']>0) { ?> <div class="bag-product clearfix"> <figure><a class="bag-product-img" href="<?php echo get_permalink($cart_item['product_id']); ?>"><?php echo $_product->get_image(); ?></a></figure> <div class="bag-product-details"> <div class="bag-product-title"> <a href="<?php echo get_permalink($cart_item['product_id']); ?>"> <?php echo apply_filters( 'woocommerce_cart_widget_product_title', $product_short_title, $_product ); ?></a> </div> <div class="bag-product-price"><?php _e("Unit Price:", "swiftframework"); ?> <?php echo $price; ?></div> <div class="bag-product-quantity"><?php _e('Quantity:', 'swiftframework'); ?> <?php echo $cart_item['quantity']; ?></div> </div> <?php echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s">×</a>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __('Remove this item', 'swiftframework') ), $cart_item_key ); ?> </div> <?php } ?> <?php } ?> </div> <div class="bag-buttons"> <a class="sf-roll-button bag-button" href="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>"><span><?php _e('View shopping bag', 'swiftframework'); ?></span><span><?php _e('View shopping bag', 'swiftframework'); ?></span></a> <a class="sf-roll-button checkout-button" href="<?php echo esc_url( $woocommerce->cart->get_checkout_url() ); ?>"><span><?php _e('Proceed to checkout', 'swiftframework'); ?></span><span><?php _e('Proceed to checkout', 'swiftframework'); ?></span></a> </div> <?php } else { ?> <div class="bag-header"><?php _e("0 items in the shopping bag", "swiftframework"); ?></div> <div class="bag-empty"><?php _e('Unfortunately, your shopping bag is empty.','swiftframework'); ?></div> <div class="bag-buttons"> <?php $shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) ); ?> <a class="sf-roll-button shop-button" href="<?php echo esc_url( $shop_page_url ); ?>"><span><?php _e('Go to the shop', 'swiftframework'); ?></span><span><?php _e('Go to the shop', 'swiftframework'); ?></span></a> </div> <?php } ?> </div> </li> </ul> </li> <?php $fragments['.shopping-bag-item'] = ob_get_clean(); return $fragments; }
Now find this code from given code:-
<?php $shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) ); ?>
Change it with your url like:-
<?php $shop_page_url = 'http://www.yoursite.com/'; ?>
Thanks
MohammadOctober 12, 2015 at 4:58 pm #220190This reply has been marked as private.October 13, 2015 at 12:25 pm #220411Hi Ben,
Did you add in these two changes:
Now find this code from given code:-
<?php $shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) ); ?>
Change it with your url like:-
<?php $shop_page_url = 'http://www.yoursite.com/'; ?>
Cheers,
David.October 13, 2015 at 3:40 pm #220521Hi David
Yes I made the changes.
Whats best to explore next?
October 13, 2015 at 3:56 pm #220524October 18, 2015 at 1:20 pm #221387Hi Rui
That is just the page set in woo commerce as shop, so no change.
I have it set in functions to go back to – http://fixers.travel
Any help greatly appreciated.
Thanks
October 19, 2015 at 9:24 am #221462Hi,
Can you provide us ftp access to check your code?
Use the private reply.-Rui
October 21, 2015 at 12:41 am #222058This reply has been marked as private.October 21, 2015 at 10:52 pm #222355Hi,
Well using the admin it works but it’s difficult to edit anything and if something goes wrong the site will totally with the white screen. If you can provide a specific ftp user to that installation it will be great.
Checked the code and that function doesn’t seem to be correct one.
Probably will need to check this tomorrow with our head developer.Will say something tomorrow.
-Rui
November 5, 2015 at 5:11 pm #226317This reply has been marked as private.November 5, 2015 at 5:29 pm #226325Hi,
Apologize, somehow this topic was left behind.
Just forwarded it now to Ed to see if it’s possible to do something.-Rui
November 6, 2015 at 7:50 pm #226786Hi there,
You also need to override this function:
if (!function_exists('sf_get_cart')) { function sf_get_cart() { $cart_output = ""; // Check if WooCommerce is active if ( sf_woocommerce_activated() ) { global $woocommerce; $options = get_option('sf_neighborhood_options'); $show_cart_count = false; if (isset($options['show_cart_count'])) { $show_cart_count = $options['show_cart_count']; } $cart_total = WC()->cart->get_cart_total(); $cart_count = $woocommerce->cart->cart_contents_count; $cart_count_text = sf_product_items_text($cart_count); if ($show_cart_count) { $cart_output .= '<li class="parent shopping-bag-item"><a class="cart-contents" href="'.$woocommerce->cart->get_cart_url().'" title="'.__("View your shopping bag", "swiftframework").'"><i class="sf-cart"></i>'.$cart_total.' ('.$cart_count.')</a>'; } else { $cart_output .= '<li class="parent shopping-bag-item"><a class="cart-contents" href="'.$woocommerce->cart->get_cart_url().'" title="'.__("View your shopping bag", "swiftframework").'"><i class="sf-cart"></i>'.$cart_total.'</a>'; } $cart_output .= '<ul class="sub-menu">'; $cart_output .= '<li>'; $cart_output .= '<div class="shopping-bag">'; if ( sizeof($woocommerce->cart->cart_contents)>0 ) { $cart_output .= '<div class="bag-header">'.$cart_count_text.' '.__('in the shopping bag', 'swiftframework').'</div>'; $cart_output .= '<div class="bag-contents">'; foreach ($woocommerce->cart->cart_contents as $cart_item_key => $cart_item) { $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $price = apply_filters( 'woocommerce_cart_item_price', $woocommerce->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); $product_title = $_product->get_title(); $product_short_title = ( strlen( $product_title ) > 25 ) ? substr( $product_title, 0, 22 ) . '...' : $product_title; if ($_product->exists() && $cart_item['quantity']>0) { $cart_output .= '<div class="bag-product clearfix">'; $cart_output .= '<figure><a class="bag-product-img" href="'.get_permalink($cart_item['product_id']).'">'.$_product->get_image().'</a></figure>'; $cart_output .= '<div class="bag-product-details">'; $cart_output .= '<div class="bag-product-title"><a href="'.get_permalink($cart_item['product_id']).'">' . apply_filters('woocommerce_cart_widget_product_title', $product_short_title, $_product) . '</a></div>'; $cart_output .= '<div class="bag-product-price">'.__("Unit Price:", "swiftframework").' '.$price.'</div>'; $cart_output .= '<div class="bag-product-quantity">'.__('Quantity:', 'swiftframework').' '.$cart_item['quantity'].'</div>'; $cart_output .= '</div>'; $cart_output .= apply_filters( 'woocommerce_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s">×</a>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __('Remove this item', 'swiftframework') ), $cart_item_key ); $cart_output .= '</div>'; } } $cart_output .= '</div>'; $cart_output .= '<div class="bag-buttons">'; $cart_output .= '<a class="sf-roll-button bag-button" href="'.esc_url( $woocommerce->cart->get_cart_url() ).'"><span>'.__('View shopping bag', 'swiftframework').'</span><span>'.__('View shopping bag', 'swiftframework').'</span></a>'; $cart_output .= '<a class="sf-roll-button checkout-button" href="'.esc_url( $woocommerce->cart->get_checkout_url() ).'"><span >'.__('Proceed to checkout', 'swiftframework').'</span><span>'.__('Proceed to checkout', 'swiftframework').'</span></a>'; $cart_output .= '</div>'; } else { $cart_output .= '<div class="bag-header">'.__("0 items in the shopping bag", "swiftframework").'</div>'; $cart_output .= '<div class="bag-empty">'.__('Unfortunately, your shopping bag is empty.','swiftframework').'</div>'; $shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) ); $cart_output .= '<div class="bag-buttons">'; $cart_output .= '<a class="sf-roll-button shop-button" href="'.esc_url( $shop_page_url ).'"><span>'.__('Go to the shop', 'swiftframework').'</span><span>'.__('Go to the shop', 'swiftframework').'</span></a>'; $cart_output .= '</div>'; } $cart_output .= '</div>'; $cart_output .= '</li>'; $cart_output .= '</ul>'; $cart_output .= '</li>'; } return $cart_output; } }
– Ed
-
Posted in: Neighborhood
You must be logged in and have valid license to reply to this topic.