custom post types - Add HTML before a specific div?

admin2025-06-04  46

I bought the "Woocommere Checkout Add-Ons" Plugin, which adds upsells to the checkout page - but it only allows to place text after the upsell checkbox.

So I got the idea to add an image with some styled text just above that upsell checkbox, which is wrapped in <div id="wc_checkout_add_ons">.

How would I do this? I read about the_contentbut can't quite figure it out.

I bought the "Woocommere Checkout Add-Ons" Plugin, which adds upsells to the checkout page - but it only allows to place text after the upsell checkbox.

So I got the idea to add an image with some styled text just above that upsell checkbox, which is wrapped in <div id="wc_checkout_add_ons">.

How would I do this? I read about the_contentbut can't quite figure it out.

Share Improve this question asked Jan 8, 2019 at 21:17 Heinrich HeldHeinrich Held 791 gold badge1 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default -1

Seems like jQuery is best for this case. Mainly answering for myself in case I'll need it again in the future:

<head>
<script src="https://ajax.googleapis/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#this_comes_before").insertBefore("#wc_checkout_add_ons");
});
</script>
</head>
<body>

<div id="wc_checkout_add_ons">stuff</div>

<div id="this_comes_before">something</div>

</body>

Edit for future me:

Use this instead you lazy asshole...

add_action( 'woocommerce_checkout_after_customer_details', 'test99' );
function test99() {
echo "your shit";
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749027396a315742.html

最新回复(0)