Ibby
Forum Replies Created
-
So I’ve managed to do this to an extent. I am using the following snippet:
/** * Change price format from range to "From:" * * @param float $price * @param obj $product * @return str */ function iconic_variable_price_format( $price, $product ) { $prefix = '£'; $min_price_regular = $product->get_variation_regular_price( 'min', true ); $min_price_sale = $product->get_variation_sale_price( 'min', true ); $max_price = $product->get_variation_price( 'max', true ); $min_price = $product->get_variation_price( 'min', true ); $price = ( $min_price_sale == $min_price_regular ) ? wc_price( $min_price_regular ) : '<del>' . wc_price( $min_price_regular ) . '</del>' . '<ins>' . wc_price( $min_price_sale ) . '</ins>'; return ( $min_price == $max_price ) ? $price : sprintf('<img src="https://hillfarmfinest.com/wp-content/uploads/2018/12/per-piece.png"> %s%s / <img src="https://hillfarmfinest.com/wp-content/uploads/2018/12/per-kilogram.png"> %s%s', $prefix, $min_price, $prefix, $max_price); } add_filter( 'woocommerce_variable_sale_price_html', 'iconic_variable_price_format', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'iconic_variable_price_format', 10, 2 );I now need to make the sure the sale price comes up correctly. There are two scenarios:
1/ When the per piece price is on sale
2/ When the per kg price is on saleSome more tinkering required hmm…
Forum: Developing with WordPress
In reply to: PHP Variable echo and WP-JSONHonestly, I actually had no idea WP had an in-built class for database connections. Thank you very much to everyone.
I will try to do it this way and create a function which calls the variables Aa, Bb and Cc and see if I get an output in the JSON.
Forum: Developing with WordPress
In reply to: PHP Variable echo and WP-JSON@joyously, sorry my mistake for not explaining fully, that code is placed in the page body area to output the variables onto the actual page. It is those HTML outputs I want to make available via the REST API.
@diondesigns, I am converting all of my code to mysqli, so this will be fixed. Would the REST API not be able to output the echos in this case? The error status was just for debug and I should have deleted it.
Also what you said at the end there has peaked my attention; how do I use the built-in db access available to WP? I am not very experienced with WP-PHP though I knnow my way around. I usually just define a function for the db connection and then call the connection when required. It sounds like I’m doing it wrong from what you said.Forum: Plugins
In reply to: [Page scroll to id] Offsets when using sticky menu and fixed elementThank you very much! Working like a charm.
Forum: Plugins
In reply to: [Page scroll to id] Offsets when using sticky menu and fixed elementStrangely, it’s still not working. I’ve done as you said in footer.php:
</div> <!-- end main-container --> </div> <!-- end site-wrap --> <div id="ps2id-offset-element" style="height:120px;width:0;position:absolute;"></div> <?php wp_footer(); ?> </body> </html>Forum: Plugins
In reply to: [Page scroll to id] Offsets when using sticky menu and fixed elementHi Malihu,
My thanks for your reply. I have tried this, but it seems to think that nothing is in the offset box now as it has defaulted to 0.
Not sure why…
Forum: Plugins
In reply to: [WooCommerce] ‘Place Order’ Button not ClickableOk, so, it turns out, WC seems to really dislike moving the coupon field. I used the following hook in my functions.php to move the coupon code field to after the customer details:
// Add coupon code area above order total, old section hidden via CSS remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'woocommerce_checkout_after_customer_details', 'woocommerce_checkout_coupon_form' );As soon as I add this, the button breaks. I have a feeling this is because my code isn’t removing the original coupon form for some reason even though the
remove_actionis targeting it correctly…
I presume this is because it now thinks there are two coupon code fields and so the fom script breaks.I’ve removed the snippet for now and it is working fine! Now to try and work out why exactly this is happening….
Forum: Plugins
In reply to: [WooCommerce] ‘Place Order’ Button not ClickableThank you very much for having a look. The footer links are not coded to link anywhere just yet. Thanks for confirming it’s not just me!
I tested across four browsers and it’s really left me scratching my head. It’s a pretty standard setup but I might try cleaning out my functions.php and see if it’s one of the scripts I have in there.
I must say I’ve never encountered this with WooCommerce before. Very odd behaviour indeed.
Forum: Plugins
In reply to: [WooCommerce] Checkout page isssuesHi Melinda,
Thanks for the response, I’ll give that a try.
I’m usually quite meticulous with modifying the loops or CSS (I always define my own classes specifically for these sorts of changes) so I’m not sure how I could have affected the native functionality on the checkout page.I’ll give your suggestion a try and see what comes of it.
Thanks.
@icegram,
Thank you for explaining. Can I not build this layout into Rainmaker/Email Subscribers plugin?
I am using those for newsletter subscription already.Hi @icegram,
Thanks for the reply. I can’t see how to import one of the demos. How do I do this?
Forum: Plugins
In reply to: [JWT Authentication for WP REST API] jwt_auth_bad_configThank you very much Kerygmata! This has put me on the right track I think. I tried running a clean install and it logged in straight away. It seems like something to do with the theme is obstructing the JWT output (most likely the token creation).
I’ll look into this further but at least it proves that there’s nothing wrong with the plugin function itself!
Forum: Plugins
In reply to: [JWT Authentication for WP REST API] jwt_auth_bad_configThe key I’m using is from the WordPress salt generator. I guess I can try changing it to another one…
But that’s interesting because the error is thrown due to no secret key hmmm. I wonder what the issue can be.
Forum: Plugins
In reply to: [PHP Everywhere] Blank Screen on Page UpdateSorry for taking so long to reply to this.
The issue I’m having is when connecting to a local server database using the mysql_ method. I have two functions to connect and disconnect from the db table I am retrieving information from:
/*************************************************************** /******************** Connect to Database ********************** /***************************************************************/ if(!session_id ()){ session_start(); } function dbConnect() { /* conecting to the mySQL database */ $db = mysql_connect("localhost","username", "password"); mysql_error(); if(!$db) { echo " An Error has occurred. Unable to connect to the database.\n"; exit; } mysql_select_db ("db_name"); mysql_error(); return $db; } /*************************************************************** /******************** Disconnect to Database ******************* /***************************************************************/ function dbClose($dbConnection) { mysql_close($dbConnection); // Close connection to database. }As soon as this function is called in any page PHP, when I click ‘update’ the page will reload to a blank screen although sometimes the code is changed and saved as well.
Forum: Plugins
In reply to: [Collapse-O-Matic] Roll-your-own with default state collapsedAh yes, sorry, I forgot to disable the coming soon plugin.
I’ve found a work around by setting the default display state to ‘none’. It’s actually working quite nicely!
Thanks for your help.