# Custom element add\_filter / add\_action - $this returns wrong? object

**URL:** <https://forum.bricksbuilder.io/t/custom-element-add-filter-add-action-this-returns-wrong-object/30577>\
**Category:** Developers\
**Created:** [February 25, 2025, 12:34pm UTC](https://forum.bricksbuilder.io/t/custom-element-add-filter-add-action-this-returns-wrong-object/30577 "2025-02-25T12:34:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erehr](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/e/e5b9ba/32.png) [@Erehr](https://forum.bricksbuilder.io/u/Erehr)\
**Post date:** [February 25, 2025, 12:34pm UTC](https://forum.bricksbuilder.io/t/custom-element-add-filter-add-action-this-returns-wrong-object/30577/1 "2025-02-25T12:34:50Z")

</div>

I’m making a custom element for woocommerce checkout (splitting shipping, payment etc.) and having an issue with making fragments refresh. Inside element class I have this functions:

```auto
public function add_filters() {
    add_filter('woocommerce_update_order_review_fragments', [$this,'update_order_review_fragments'], 99 );
}
public function update_order_review_fragments( $fragments ) {
	$data = Helpers::get_element_data( $this->post_id, $this->id );
	$fragments['.brxe-woocommerce-shippment'] = \Bricks\Frontend::render_element( $data['element'] );
    return $fragments;
}

```

$this-\>id outputs randomized ID different from one on frontend (changes on page refresh) and post\_id do nothing.

---

<div class="post-metadata">

**Author:** ![Matej](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/matej/32/20184_2.png) [@Matej](https://forum.bricksbuilder.io/u/Matej)\
**Post date:** [February 28, 2025, 12:39pm UTC](https://forum.bricksbuilder.io/t/custom-element-add-filter-add-action-this-returns-wrong-object/30577/2 "2025-02-28T12:39:22Z")

</div>

Hi @Erehr,

as this is custom code, I’ve moved it outside of the #Bugs category, as I think #Developers category is more suitable for this kind of questions

Additionally, I tried to understand the issue, but I’m still not sure where you have the code and how you call it. For anyone that will help you, it will be good if you post all of the relevant code. That will make solving this easier.

Matej
