Home › Forums › WoodMart support forum › Woodmart Security Issue Request Error 403
Woodmart Security Issue Request Error 403
- This topic has 5 replies, 2 voices, and was last updated 2 hours, 35 minutes ago by codeverseglobal.com.
-
AuthorPosts
-
February 3, 2025 at 4:04 am #634820
codeverseglobal.comParticipantSo ive had a code snippet which i use on all my websites that ive worked on before , its a php snippet that gets the unit count of an item from the item description and divides the price by it to get the unit price of an item and displays this unit price under each card in the shop page . And ive had no issues with the php snippet at all with my other sites however for some reason with woodmart im not able to even save the snippet itself , instead it gives me a request error 403. The code down below is the snippet im talking about
function display_unit_price_on_shop_page() { global $product; // Only show the wholesale price per unit if the user is logged in if (is_user_logged_in()) { // Get the product price $price = $product->get_price(); // Get the product description to extract the quantity $description = $product->get_description(); // Extract the quantity from the description (e.g., "10 per case/box") if (preg_match('/(\d+)\s*per\s*case\/box/i', $description, $matches)) { $quantity = intval($matches[1]); if ($quantity > 0) { // Calculate the unit price $unit_price = $price / $quantity; $unit_price = number_format($unit_price, 2); // Display the unit price for logged-in users echo '<p class="price-per-unit">' . sprintf(__('Wholesale Price: %s per unit', 'woocommerce'), wc_price($unit_price)) . '</p>'; } } } else { // For guest users, show login prompt instead of wholesale price echo '<p><a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">Login to view wholesale prices</a></p>'; } } // Hook the function to display the unit price after the shop loop item title add_action('woocommerce_after_shop_loop_item_title', 'display_unit_price_on_shop_page', 15);
February 3, 2025 at 11:08 am #634874
Artem TemosKeymasterHello,
Thank you so much for contacting our support center.
To better assist you, could you kindly test the functionality with default WordPress themes such as TwentyTwenty or WooCommerce Storefront? This will help us determine whether the issue stems from our theme or elsewhere.
Regards
February 4, 2025 at 5:57 am #635150
codeverseglobal.comParticipantI tried switching and it just said the samething seems like its not from the theme , since i also tried de-activating plugins and it still gave me the error . Thank you for the help . One step closer towards the solution
February 4, 2025 at 6:10 am #635151
codeverseglobal.comParticipantThe issue is , that the snippet Divides the price of the items by the unit count of the product itself , and i need that to be added at the bottom of the product card on the shop page . Although this can be accoumplished thro woodmarts unit of measure however on my import tool i can seem to locate the unit of measure field , So maybe you would know the meta key for the unit of measure since i have 5000 products and it would be imposible to map it one by one ?
February 4, 2025 at 7:59 am #635156
codeverseglobal.comParticipantOk i got the code to work and the output is being displayed in the product description since i dont want to eject it directly onto the shop page so is there anyway i can enable the product description to appear for each product on the shop page ?
February 4, 2025 at 8:30 am #635160
codeverseglobal.comParticipantNever mind i fixed everything u can close the ticket thank you anyway <3
-
AuthorPosts
- You must be logged in to create new topics. Login / Register