Skip to content

Tag: php

Programmatically creating new order in Woocommerce

I am having the hardest time programmatically creating an order in WooCommerce. I am using the code below and is DOES create an order BUT I cannot get customer information OR product line items added to the order. The new order that is create is simply as Guest with no items, user information, etc. The issue …

Get user role by ID WordPress

I need to somehow check someone’s role with only their id. I have found the current_user_can() check. But this only works for people that are logged in. How would I check for this if that user isn’t the current user? I am using a phone order system but that uses the admin/specific account to order…

PHP foreach not looping

I’m new in programming and just started php like two months ago. So far I seemed to understand it more and more. But now I am stumped. I have a foreach loop that won’t loop through the array I’m feeding it. I have checked the syntax and logic over and over again and can’t find the prob…

What is the actual memory cost of storing an integer?

lets say I just do this So I store 10 integers in an array. If the integer is a 32b one, the memory cost should be 40 bytes. Problem is, I didn’t tell php that it is an integer so it either has to store it as something else? (js likes to make doubles for example) or keep extra data

How to validate a sale with PayPal REST API and IPN

I currently have a fully working cart and checkout process through PayPal _xcart method, but I want to migrate it to REST API, mainly because I want to mitigate the possibility of price-jacking. Currently my IPN does check for price jack and sets the according flags so the product doesn’t get downloaded…

Remove tag, in submitting data to Soap Server with PHP

Actual result: Expected result without <return xsi:type=”SOAP-ENC:Struct”></return> tag. I am doing it first time, and actually I know almost nothing about Soap Server, could you tell me, how can I remove return tag ? this is the code on server side: Answer In order to do what you want…

Prevent symfony serializer to certain attributes

I acknowledge of the existence of $normalizer->setIgnoredAttributes but I have the following problem. I have an entity Product with attributes ‘prices’ (related with another entity) and ‘complements’ (which is a self reference relation). When I get the a product I need the prices, b…