Perch Shop: If no sale price exists use standard price

  • I have worked around this using a very crude bit of jquery inserted into the back end. Basically checks if the inputs within the fields wraps of the sale and trade price are empty when any price is changed, and if they are it inserts the standard price into the field.


    In theory no price field should now be empty. Meaning sales and promotions shouldn't end up with zero priced items (unless you type a zero into the field).


    I'm not a programmer so this is (very) crude, but it works for adding new products, not sure what I can do for you guys with existing shops though:


    Include this in your backend js (https://docs.grabaperch.com/perch/control-panel/customizing/)

  • Perhaps I'm missing something, but can't you simply check if sale price is populated?


    <perch:if exists="sale_price">


    Another suggestion is to add a checkbox to the template:


    <perch:shop id="on_sale" type="checkbox" value="1" label="Use sale price" suppress="true" />


    And then :


    <perch:if exists="sale_price AND on_sale">

    $<perch:shop id="sale_price" />

    <perch:else />

    $<perch:shop id="price" />


    The benefit here is that you can have a sale price ready to go, and then check box to activate it.

  • JayW I think the problem isn't with displaying the appropriate price (regular/sale/trade), but rather with what price Perch Shop uses for the cart and order. To check the current price of a product as Perch Shop sees it (and would use in cart and order), you can use current_price:

    HTML
    1. <perch:shop id="current_price" type="shop_currency_value">


    If, for instance, you enable the trade price with perch_shop_enable_trade_pricing() and a product has no trade price set, Perch Shop defaults the product's price to 0 instead of falling back to the regular price. Understandably this is not the desired behaviour in most cases.

  • I see. I've built one shop site and never had this issue, but looking on my dev site, yes it does default to zero...


    But only if I deliberately leave the sale_price blank, and also check the box "use sale price"! That's human error. But I suppose it's fair enough to want to defend against human error when the consequence might mean selling an expensive item for $0.

  • Hello both,


    The problem occurs due to the system treating a blank price field as zero (0) when deciding what to value to pass to the basket.


    IMO it should default back to the standard price if the current field is blank in the admin - both for sale and/or trade pricing.


    I've worked around this using javascript on the back end for now when adding a new product, so in theory the field can never be blank if a price is entered for the product.


    Bizarrely making the price fields required, prevents the product form from submitting.