Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Polylang Implementation
- This topic has 10 replies, 2 voices, and was last updated 6 years, 2 months ago by Jonathan Moore.
-
AuthorPosts
-
July 19, 2017 at 12:41 pm #1658Jonathan MooreParticipant
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 fineI haven’t translated the free products yet but normally this should be doable if needed in similar way
July 19, 2017 at 3:18 pm #1661Soft79KeymasterWould 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)
July 19, 2017 at 3:22 pm #1662Jonathan MooreParticipantooo yes, nice one, that’s a very standard and filterable function, good point π
July 19, 2017 at 3:29 pm #1663Jonathan MooreParticipantactually 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)
July 19, 2017 at 3:38 pm #1664Jonathan MooreParticipantso 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..
July 19, 2017 at 3:54 pm #1665Soft79KeymasterHey, 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!
July 19, 2017 at 3:57 pm #1666Jonathan MooreParticipantyeah, of course that should work too.. π
July 19, 2017 at 4:05 pm #1667Soft79KeymasterDoes 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.
July 19, 2017 at 4:31 pm #1669Jonathan MooreParticipantThis 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/wikiI 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.
July 21, 2017 at 7:47 pm #1700Soft79KeymasterHi, 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.
July 22, 2017 at 1:55 am #1702Jonathan MooreParticipantreceived 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 -
AuthorPosts
- You must be logged in to reply to this topic.