Hi,
The error message you’re encountering (“Could not create snippet. Request failed with status code 403”) indicates that you don’t have the necessary permissions to create a snippet. This could be due to the settings of the plugin or theme you are using to manage snippets.
If you’re unable to create a snippet directly, you might consider adding the code via a child theme’s functions.php
file. Here’s how you can do it:
- Child Theme Setup (if not already done):
Set up a child theme if you haven’t already. This is a safer way to make customizations without affecting the parent theme’s files.
- Locate or Create
functions.php
:
Inside your child theme’s folder, locate the functions.php
file. If it doesn’t exist, you can create one.
- Add the Code:
Open the functions.php
file in a code editor and add the following code:
// Remove the default action that opens the product link
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
// Add custom action to open the product link in a new tab
add_action( 'woocommerce_before_shop_loop_item', 'custom_function_open_new_tab', 10 );
function custom_function_open_new_tab() {
global $product;
echo '<a href="' . get_permalink( $product->get_id() ) . '" target="_blank">';
}
This code removes the default action that opens the product link and replaces it with a custom action that opens the link in a new tab.
- Save and Test:
Save the functions.php
file and then check your shop page to see if the product links are opening in a new tab when clicking on the image or title.
Remember that the exact implementation might depend on your theme and WooCommerce version, and it’s always a good idea to have a backup of your website before making any changes to the code. If you’re not comfortable with code modifications, consider reaching out to a developer for assistance.