Home Forums WoodMart support forum Woodmart Security Issue Request Error 403

Woodmart Security Issue Request Error 403

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #634820

    codeverseglobal.com
    Participant

    So 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); 
    #634874

    Artem Temos
    Keymaster

    Hello,

    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

    #635150

    codeverseglobal.com
    Participant

    I 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

    #635151

    codeverseglobal.com
    Participant

    The 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 ?

    #635156

    codeverseglobal.com
    Participant

    Ok 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 ?

    #635160

    codeverseglobal.com
    Participant

    Never mind i fixed everything u can close the ticket thank you anyway <3

Viewing 6 posts - 1 through 6 (of 6 total)