Repository Forums Support WooCommerce Extended Coupon Features PRO Polylang Implementation

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1658
    Jonathan Moore
    Participant

    Hi, I am just adding some Coupon handling to Hyyan WooCommerce Polylang Integration which is one of the plugins I contribute to.

    This will allow the coupon strings to be xΒΊ in Polylang String Translation table and admin ui. Apart from registering the coupon names and descriptions for translation, this means calling pll__() instead of __() for the name/description..

    In this context I am wondering, could we have:

    – a filter for coupon_excerpt(): where this is called in update_matched_autocoupons() in WJECF_AutoCoupon l.362 there is no filter possibility.
    Basically instead of returning __( $my_post->post_excerpt, ‘woocommerce-jos-autocoupon’ ); when activated the filter will return pll__($my_post->post_excerpt). I can do this in the cart totals area by hooking woocommerce_cart_totals_coupon_label with higher priority but not here.

    errr.. nothing else I think
    – get_meta( ‘_wjecf_enqueue_message’ ) is filterable by woocommerce_coupon_get__wjecf_enqueue_message which works fine

    I haven’t translated the free products yet but normally this should be doable if needed in similar way

    #1661
    Soft79
    Keymaster

    Would it help if I call get_the_excerpt( $my_post ) instead of $my_post->post_excerpt ?

    (for WP 4.5.0+ only, for older versions I will fallback to post_excerpt)

    #1662
    Jonathan Moore
    Participant

    ooo yes, nice one, that’s a very standard and filterable function, good point πŸ™‚

    #1663
    Jonathan Moore
    Participant

    actually no, it should just use the existing filter woocommerce_coupon_get_description

    the description is the excerpt and all the woo3 get() functions are filterable in this way (in fact I already implemented this one)

    #1664
    Jonathan Moore
    Participant

    so it would be a simple change:

    `
    private function coupon_excerpt($coupon) {
    $my_post = get_post( WJECF_Wrap( $coupon )->get_id() );
    return apply_filters( ‘woocommerce_coupon_get_description’,
    __( $my_post->post_excerpt, ‘woocommerce-jos-autocoupon’ ), $coupon );
    }
    `

    I’ve just tested this and working fine..

    #1665
    Soft79
    Keymaster

    Hey, I wasn’t aware that WC has a WC_Coupon::get_description() now.

    I’ll just call that function for WC3+ and everything will work out fine!

    #1666
    Jonathan Moore
    Participant

    yeah, of course that should work too.. πŸ™‚

    #1667
    Soft79
    Keymaster

    Does polylang work with a separate post per per language like WPML? Then other things need to be considered as well, like in the WJECF_WPML.php file. If you can provide me with the polylang WC plugin I’ll test and fix it here.

    #1669
    Jonathan Moore
    Participant

    This is the non-commercial Hyyan WooCommerce Polylang Integration rather than the new Polylang commercial extension for WooCommerce, but the principles should be the same.

    Coupons were not created as separate posts but Products are, and Terms etc are translated.

    I’ve just checked in the coupons extension into this branch – there’s a coupons.php file:
    https://github.com/hyyan/woo-poly-integration/tree/1.0.2
    Note also documentation:
    https://github.com/hyyan/woo-poly-integration/wiki

    I just took a quick look at WJECF_WPML.php now you mentioned it, and I think it’s already covered within the woo-poly-integration 1.0.2 but your feedback/suggestions welcome.

    #1700
    Soft79
    Keymaster

    Hi, I just sent you the current development version, which uses WC_Coupon::get_description()

    I did not find the time yet to perform any tests yet…

    I hope to finish 2.5.4 within the next two weeks.

    #1702
    Jonathan Moore
    Participant

    received with thanks,
    I also have very limited time for testing, however I did already test and put into production the get_description() change and this seems to be working fine

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.